Showing posts with label developer. Show all posts
Showing posts with label developer. Show all posts

Tuesday, November 25, 2008

Flash Catalyst Tutorial: Weather Widget, Part 2

Download the current .fxp file here: weatherWidget_2.fxp


To view part 1 of this tutorial, click here.


Designing the Second State

In this part of our project, the designer is planning on adding some more elements to our wireframe to begin to flesh out the experience design (XD) of the application. In the iPhone and Dashboard versions of the weather widget, the 'back side' of the application has a function to choose which cities you'd like to track the weather for. Our designer decides to begin with this part of the app.

In Flash Catalyst, our designer opens up the .fxp file and creates a new blank state by clicking on the 'New Blank Slate' button in the Pages/States panel. Interface elements are placed in the new state and a state title of 'chooseCity' is given to this second state. In the chooseCity state the user is presented with a list of current cities that are being tracked in a scrolling list. Each item in this list has the name of the city and a button to remove the city from the list. There is also a button to add a new city at the top of the interface as well as a button to go back to the previous view. All of the UI elements are placed on the stage. 


Adobe Flash Catalyst - weatherWidget_2
Uploaded with plasq's Skitch!

Next, our designer realizes that the scrolling list will have more than one city listed for a typical user. Since the items in the list will be similar, he decides to make this a Custom Component... good call! We create the custom component in the same way we created the dayComponent in the first part - select all the items for the component (remove button, city title, surrounding box) and click on the 'Convert Artwork to Component > Custom/Generic Component' in the heads up display (HUD).

Now that our second state wireframe is complete, we'll build the transition from one state to the next. For those of you that attended MAX in San Francisco and were lucky enough to get into the hands-on lab with Catalyst, you'll recognize the transition we're going to build. It is a rotational transition that makes the application flip over like a card to show the 'back side' of the app. This is the same transition that Apple uses on the iPhone and in Dashboard.

Begin by having the Timeline panel viewable - double clicking on the tab works if it's collapsed. Because we had Auto Effects for New Transitions checked by default in Flash Catalyst (it's in the Timelines menu) you should see some standard fade transitions between the 2 states. All the way to the left in the Timeline panel you will see 2 State Transitions - View City > Choose City and Choose City > View City. These represent the names of the 2 view states we've defined so far. We added 2 actions to each state transition - Rotate 3D - by clicking on the row for the item to be transitions (city and cityListGroup) and then clicking on the 'Add Action > Rotate 3D' button. We then selected each Rotate transition and changed the values to the ones in the diagrams below in the HUD. For the second state transition (the one that goes back to the viewCity state) we just reversed the order of the transitions.


transition_1
Uploaded with plasq's Skitch!

transition_2
Uploaded with plasq's Skitch!

To trigger the interactivity for the transitions, our designer selects the round button in the first state, and adds a transition to second state interaction. On the second state, the back button is selected and an interaction is set to go back to the first state. If you run the application, you will see a transition like the one below. (click image to play movie)










Handoff to the Developer

The designer is satisfied with the transitions and basic wireframe positioning of elements and saves his .fxp and hands off to the developer again. Our developer realizes that some changes have been made to our project with a warning presented to him in Gumbo on import of our updated .fxp file. He accepts the changes as none are critical to the functionality already built.

The first thing our developer does is to rename the newCustomComponent that our designer created in Catalyst - I'm hoping that Catalyst will allow you to declare class names in the future so as not to require that as part of the workflow - so that our naming conventions are consistent with one another.

weatherWidgetTutorial_2_4
Uploaded with plasq's Skitch!

After digging into the created code a bit, our developer realizes that the button component that our designer created to transition from state 1 to state 2 is just 'floating' in state 1 and not part of a group or custom component. He thinks that might not be the best way to have this button represented and decides to place it into the group on state 1. The problem is, when doing this, it becomes difficult to access the state transition that occurs 1 level up in the display list chain. There is no event that would allow us to track this user interaction so a custom event class is created: FlipEvent.

weatherWidget_tutorial_2_5
Uploaded with plasq's Skitch!

Our developer opens the cityComponent class and adds a few lines of code to include the new custom FlipEvent we've created. He ties that to the button - hmm, gotta' rename that button ;) - which triggers a function to dispatch our new event.

weatherWidget_tutorial_2_6
Uploaded with plasq's Skitch!

Because our cityComponent is now set up to dispatch our 'flip' event, we can listen for that event in our application! In the weatherWidget_2 file, we add some code to listen for the event to be triggered. Rather than setting up a function to be called to switch the states of the app, we're using a shorthand for that by using the {} with our expression embedded in it to switch the currentState property.

Flex Development - weatherWidget_2/src/weatherWidget_2.mxml - Flex Builder Gumbo - /Users/erik/Documents/Gumbo MAX Preview
Uploaded with plasq's Skitch!

When we test our application now, we have the same effect as displayed in Catalyst, but we are now using a custom event to trigger our transition.

Part 3 - Let's get some skin on this sucker!

Monday, September 22, 2008

Working with XML Namespaces in Flash

Today I was having some issues with parsing RSS/ATOM feeds in Flash. I forgot to factor in the fact that both use namespaces in the XML. Here's a simple block of code I used to handle the namespaces and parse the XML into Value Objects:


public function xmlLoaded(event:Event):void

{

trace("done loading");

theXML = XML(myLoader.data);

var ns:Namespace = theXML.namespace();


for each (var property:XML in theXML..item)

{

var atom:Namespace = property.namespace("atom");


var fVO:FeatureVO = new FeatureVO();

fVO.pubDate = property.pubDate;

fVO.updated = property.atom::updated;

fVO.category = property.category;

fVO.title = property.title;

fVO.summary = property.atom::summary;

fVO.link = property.link;

fVO.enclosure = property.enclosure.@url;

fVO.xmlData = property;

model.featuresArray.push(fVO);


trace("creating featureVO "+fVO.enclosure);

}


This is what the sample xml looked like from Blogger's RSS/ATOM feed:

<rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' version='2.0'>

<channel>

<atom:id>tag:blogger.com,1999:blog-</atom:id>

<lastBuildDate>Wed, 10 Sep 2008 19:07:53 +0000</lastBuildDate>

<title></title>

<description></description>

<link>asdfasdf.com/</link>

<managingEditor>noreply@blogger.com (Erik Loehfelm)</managingEditor>

<generator>Blogger</generator>

<openSearch:totalResults>9</openSearch:totalResults>

<openSearch:startIndex>1</openSearch:startIndex>

<openSearch:itemsPerPage>25</openSearch:itemsPerPage>

<item>

<guid isPermaLink='false'>tag:blogger.com,1999:blog-</guid>

<pubDate>Wed, 10 Sep 2008 19:07:00 +0000</pubDate>

<atom:updated>2008-09-10T15:07:53.696-04:00</atom:updated>

<category domain='http://www.blogger.com/atom/ns#'>feature</category>

<title>People Singing</title>

<atom:summary>This is going to be a feature for the portal.v/atom:summary>

<link>asdfasdfasdf.html</link>

<enclosure type='image/jpeg' url='http://msnbcmedia.msn.com/j/msnbc/Components/Slideshows/_production/ss-080522-idolfinale/ss-080522-idolfinale-09.hmedium.jpg' length='0'/>

<author>noreply@blogger.com (Erik Loehfelm)</author>

</item>

</channel>

</rss>


You can see the syntax to be used on the 2 lines highlighted in bold above. The first defines the namespace (atom) and the second shows how you access elements in the xml that have the atom namespace applied to them.

Monday, June 11, 2007

iPhone Application Development

Today was the opening day of the WWDC (worldwide developer's conference) for Apple and Stevie boy announced that 3rd party application development would be supported on the iPhone in the form of Web 2.0/AJAX applications running in Safari. They also announced the release of Safari for Windows.

All that I have heard in response to this news is how badly it sucks. I don't get it? May be I'm biased since that's mostly what we build - rich-internet applications and web 2.0 stuff - but I think this is a great step! What exactly do the nay sayers plan on creating for a phone anyway? Halo 5 mobile? Let's be real for a second. Probably the most valuable applications that you'll find on a phone are going to be data mashup type applications that a user can get a bit of info on, make a quick - and small - reaction to and get out. I never thought I would want to be editing excel spreadsheets on my phone. Anyone that does, I've got an idea for your portable spreadsheet work, it's called a laptop.

The form factor of a phone sized device must be strongly considered in the type of application that you build. I've had a Palm for as long as they've been around and I think I opened a Word document all of once on it. Never edited it. I think I was just seeing if it worked, actually. Same goes for my Blackberry. Can I open and edit documents - yes. Have I ever, no. May be I'm in the minority, but I don't think I am. The ability to send and receive email and attachments that are images and sound files seems to be more important for a phone device.

Lets make a few assumptions for a moment. Let's assume that it truly is a full version of Safari that is running on the iPhone. It has been stated that the OS is a FULL version of OS X on the device. Obviously, the interface elements that are in the desktop version are not on the phone nor are they required but the core kernel is - at least, that's what Steve Jobs said at the D:All things digital conference a few weeks ago. So, if it's a full version of Safari running on the Apple WebKit, then it should support plug-ins. If it supports plug-ins, it should support Flash. If that's the case, we can develop applications in Flash and Flex and deploy them to the iPhone! That's all we needed to hear. To extend that a bit, I read a lot of complaints about developing games for the phone. If it supports Flash, your golden. There's plenty of game content developed in Flash. If it truly supports all types of plug-ins, you could develop a game in Director or Unity and deploy it to those plug-ins as well.

Now, it would be nice to have a little icon on the phone like the other applications, but that's not going to keep us from developing for it. If a user has to bookmark my app to get to it, so be it. Maybe Apple can extend the concept they're starting with by embracing their own Widget model of development. The existing apps that come on the phone look as though they are identical to the Widget versions of applications on the desktop OS so it doesn't seem like it would be too far off to support that. Again, it would be leveraging AJAX and the Safari WebKit to do so.

This morning there was a lot of buzz on the announcements from Adobe and Apple. The Adobe boards were buzzing with 'wait till you hear the news from Apple' chatter. We were kind of thinking that the iPhone would somehow support installed applications with Adobe's new AIR (Apollo). It seemed like the timing on it was right and knowing how the .air files install into the AIR framework, it seemed like a possibility. There was no announcement from either Apple or Adobe though, so I guess that's not going to happen. But, it seems like if the assumptions from above hold true, it could possibly happen in the future. Now that would be cool! They could keep the iPhone system hooks to a minimum for security reasons and have an installation option for applications on the phone. That would probably be a really nice way to satisfy a decent amount of people and protect the phone's stability. We'll have to see I guess.

So, if the assumptions above hold true, and developing an application in Flex (or AJAX or Flash) and deploying it to an iPhone through Safari on the phone is possible, it sounds like it's time to scheme up a few nice little apps for the end of June!