360Flex Brain Dump
The following is a brain dump of my notes from 360Flex. I’ll have more to say on some of these topics in later posts.
Things I found out about Apollo
I asked Robert Mike Downey if there would be any way to send/receive data through the attached USB devices with Apollo 1.0. He said “no” but it’s on the plate for the update. Hopefully that will come when they support Linux.
The things we will be able to do with Files is going to be amazing. Yes, you know we’ll be able to open files from the file system. Yeah. But that’s just the start. Apollo supports the byteArray type. We’ll be able to open any file. And read it bit-by-bit if you want. Why would you want to. Well, the example that they showed in the ByteArray 101 session was to open up an MP3 file, parse through the ID3 tags and pull out the string that represents the Album art and send that to the Load class to be displayed.
If you’re a Flash developer like me who gradually learned to program as the Flash player evolved then that might sound like a pretty complex bit of code. I can tell you that it really isn’t that hard. The byteArray is just like any other array that might have a length of 100,000,000. But hey, it isn’t like you have to read that array yourself. Essentially all you have to do is start reading the byteArray from the beginning while looking for certain markers – you find those markers from reading the specks on the filetype you loaded. Once you find a marker you look to read some meta-data encoded there. If that meta data tells you that what follows is going to be album art then grab the bytes until the next meta-data block starts. Otherwise skip to the next meta-data block and read again. It’s that easy. When you have bytes you can simply send it to a loader. It doesn’t know the difference between bits that came from a server or your byteArry. Ta’da, you have a picture. You can apply this technique to any filetype that you have the specks for.
Flex 3 IS Apollo. The new and improved Flex Builder, or plugin for Eclipse, will be your Apollo IDE. They are one and the same. Look for them late this summer.
Here’s a few other upgrades to the Flex IDE that is slated for Flex 3. Note: they stated over and over that this is all subject to change.
- Refactor – you have a method or property name that you don’t like? Change it, everywhere, across all project files with one command. Sweet.
- Integrated Profiler: look at what your code is doing inside the Flash player. Very handy.
Flex Details
I was a little confused about the way the components are created for display. If you dig around you can find files in the FlexBuilder program folder that are FLA/SWFs full of symbols that make up the Flex components. You’ll see things like scrollbars, button fills, borders, everything.
However, none of that stuff gets used unless you tell your application to use it. My understanding is that those files are there if you want to create a new skin for Flex and embed it. I haven’t done any skinning myself yet so I’m not certain. What I do know is that the standard components that you see in Flex are all created at runtime with the graphicsAPI. None of those symbols are used. And when you use styles/css to skin your Flex app you are affecting how the graphicsAPI draws. It’s that simple. Those symbols don’t get used unless you embed them but that’s a different story.
When you think of it that makes a lot of since because you wouldn’t be able to change the corner size of a symbol once it is drawn. Not without some wacky transformations going on. But it’s simple to do if you’re creating everything programatically.
Deepa Subramaniam – software engineer for the Flex SDK – reminded us that if there is something about the Flex API that we don’t like then just hack it. (Okay, she didn’t say it exactly like that.) All the source code is right there for us to have our way with.
When you use binding expressions in Flex you are essentially using watch(). It’s that simple.
Very important tip: if you need to update the display on startup then use the initialize() event on the Application tag. Reason being is that if you wait until after the rendering has all been calculated to layout the display and then do something like use creationComplete() to change something then the layout engine has to go back and do a lot of work over again to make sure the display is correct. That’s going to waste a lot of cycles right as your app is starting and make the user wait longer than necessary.
Random notes and thoughts
There is only one difference between Jesse Warden and a madman. Jesse isn’t mad. :-) I didn’t get a chance to talk to him but I attended his session on Flex and Flash together. Wow. That guy runs in the fast lane.
The grid layout container is the most cycles expensive of all the layout containers. If you don’t need the grid then use something else.
If you are moving a component around with an animation and you want it to run more smoothly then try this: on Effect.start make any of the small elements visible=false. That way the layout manager doesn’t account for them. Then when the animation is over call Effect.end and make your elements visible=true. In many cases the user won’t notice that something disappeared during the animation and you get better performance out because there are less objects to display.
A Flex application is a 2 frame FLA. The first frame is the loading process and when all is loaded it goes to frame 2. That’s where the application is initiated.
If you are thinking about building any applications that require a mapping service then you probably think that Google and Yahoo are your only options. Not quite. Take a look at ESRI. They have a lot of basic stuff for free and their paid service will knock your socks off. Even if you don’t use their mapping service you should definitely check out their framework. Great stuff.
If you want to do some computations when the Flash player is idling then you could try a few different approaches.
- You could listen for mouseMovement and when it isn’t moving then start a timer. When that timer reaches an interval you feel is sufficient then you can assume the user is reading something and not interacting with the application. That’s a good time to start doing computationally complex code and then stop again when the user moves the mouse.
- Another approach would be to listen for the updateComplete event. That’s called when the Flash player has finished updating the display for that onEnterFrame event. Hopefully there will be a few milliseconds for you to run some code until the onEnterFrame fires and the player starts working on the display again.
- You can also use callLater() which queues a function to be called later. Look it up in the help to get more.
In discussions with various developers at they suggested that using the Flex plugin for Eclipse is the best option because you can update Eclipse apart from Flex. Plus it’s easier to use other plugins for Eclipse. However, it’s a slightly more complicated process for setting up the plugin version over the Flex Builder version. I’m going to switch over myself probably this weekend.
A few cool Flex Builder/Eclipse shortcuts that I found out about:
- ctrl + shift + P : Move to the matching brace
- ctrl + T : list all types
- ctrl : hold down the ctrl button and mouse over an identifier and it turns into a link to the class.
- ctrl + O : Open the outline panel inline
- ctrl + D : ASdoc comments
You can change the color coding for Eclipse but not in the application. You have to go through an XML file located in a JAR file, bla, bla, bla. At least it’s possible and I know where to look for it. I’ve looked all over the web for info on doing that and never found anything. When I get my code colors changed I’ll post the full instructions on it.
If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.






