Why flex? Why actionscript? Why flash?

Why flex? Why actionscript? Why flash?

Having done close to 4 years of flex programming I’ve been asked frequently ‘why use flex?’.

My normal response is well flex is for programmers and flash is for designers (generally speaking). But having never created a proper flash project I’ve not had a proper insight into flash, but that’s changed a wee bit in the past few days. How? Well I’ve been doing an actionscript only project so that it could be imported into a flash project.

I’m really surpised about all the stuff I take and use in flex that I just couldn’t use in the project code that was just for flash.

Main Issues & work arounds (if possible)

 

Embedded assets (ByteArrayAsset & BitmapAsset etc issues)
  • Why when you wish to use something from the start of your app should you have to load the asset. Well I’m sure if you’ve done flash for a while you’re used to either pulling something onto the stage or using the loader method if using actionscript.
  • Well I’m used to using the [Embed] metadata but try using that and you’ll find that it requires the flexSDK. Why!!! If you’re trying to do everything without flex then you’ll actually find that the reason it requires the flexSDK is as follows –

    IFlexAsset is a marker interface with the following meaning: if a class declares that it implements IFlexAsset, then that class represents an asset — such as a bitmap, a font, or a sound — that has been embedded in a Flex application. This interface does not define any properties or methods that the class must actually implement.

    So the reason you’ll find that you can’t use the [Embed] tag in a pure actionscript project is NO REASON. So should you get an error after using the [Embed] tag then all you need to do is create an empty class of whatever it can’t find and place it in a folder mx/core/ 

Tweens
  • There is a considerable difference between tweens for flex and tweens for flash. The flash tween isn’t anywhere near as flexible as the flex version 🙂. If you wish to change a value from say 0 to 100 using an easing function then in flex you just tell the tween here is the start value ‘0’ and here is the end value ‘100’ and I want the duration to be say 700 milliseconds. Then every time this updates I can do other things and on the last call I can make sure that the end value is what I’m expecting (see previous post on fuzzyness after rotations for why this is a good thing).  But with the flash versioned Tween I can’t do this.  The property I change must be part of an object and it must be changed using either seconds! or the timeline.  The flash tween does have a update event that you could listen to but I like the flex version that has a function that gets called for each update and an end update function call for the last value update.

    So what can you do, well flex is open source, so just take a look at the flex tween class and copy/paste and remove all flexEvent references and change any mx_internal to private.  If you still wish to use the flexEvents then just create your own event and fire them. Job done 🙂

Code hinting
  • Dammit why??? Surely they can put code hinting into CS4, why not? The lack of code hinting really must be to turn programmers away from CS4 and to use flexbuilder or simialr. No workaround for this other than if you want code hinting use flexbuilder.  You can edit your AS files that are in your flash project using flexbuilder, but why can’t you do this in CS4?
SWC’s
  • I belive its possible to create a SWC in flexbuilder and then load it into flash CS but I’ve not managed it yet. (when I do I’ll blog that)
Conclusion

If you can develop in flex, the do. Your life will be sooo much easier.

If you need code for a flash project then use flexbuilder to make it, try to keep as much of it separate from your flash project as possible. e.g. In my case my actionscript project accepted a Sprite from whatever the designer was doing in CS4 and that’s all it cared about so I could develop it 100% in flexbuilder using an actionscript project. (Then just pass code over to flash project to insert into project – use of a SWC would make this process better, working on it)

If you know the flex libraries and flash doesn’t have something but flex does then chances are you can just remove any mx.* references or fudge it (as in the case of the or tween issues)

If your designing something, then sure stick to flash.

[ad]

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.