Archive

Archive for the ‘Actionscript 3.0’ Category

MVC Pattern in AS3

October 31st, 2009

Just some random thoughts this morning, following a discussion with a colleague at work.

Perhaps it gets overused, and sometimes abused, but I find the MVC pattern a rather useful way of dividing up code.  By using the pattern, I formalize what I would otherwise try to do anyway: separate my data from the graphical display, and make it easy to switch different views for the same data.  And although with MVC you should be able to set up your data model so the actual data can take several forms, XML is so easy to parse with e4x that it’s really not worth the effort to create a separate class to act as a parser.   So now I think I will call the data “model” the XML format itself.  This does mean, however, that if data is actually stored in some other way, say in the database, a serializer will need to be created to generate this data model.  This way the View in MVC can just parse the data format directly.  The Controller’s role is usually limited to locating the xml file and instantiating the View, passing it the xml.

Or I could just wing it…

admin Actionscript 3.0, Flash CS4 ,

Crash Alert: flash10 wmode “transparent” can crash FF3 & IE7

March 5th, 2009
Get Adobe Flash player

I ran into a bug yesterday for flash 10 swf files that really had me scratching my head.  I narrowed the bug down to the following: filters applied at runtime to a SimpleButton that has been moved in 3D will crash the browser if embedded into html with wmode tranparent.  I guess it sounds really specific, but I think it’s pretty likely someone else will run into this soon if they haven’t already.   Download the example.

In the example, If you run cs4crashtest.html in firefox3 or IE7, and you move the mouse over the flash icon, cs4crashtest.html will crash (I haven’t tested other browsers).

The workaround I used for this example was to apply the filter to the over state of the SimpleButton class (btn.overState.filters). See cs4crashfix.html in the example.

Of course, if set wmode to something other than transparent, you won’t experience these issues.  You can also apply filters using the Flash CS4 IDE instead of using code, this seems to cause no problems.  Hope this helps someone avoid some debugging time.

admin Actionscript 3.0, Flash CS4 , , , , ,