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.
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.
The above is an Inverse Kinematics example authored with Flash CS4 that doesn’t use any (of my) code. The robot just seemed fitting with the domain.
Having looked at David Stiller’s tutorial and Lee Brimelow’s blog on the subject, I decided to see how easy it would be to do something similar to David Stiller’s puppet of Tom but allow the user to drag the pieces around like in Lee Brimelow’s example. After hunting around for the way to make the pieces draggable without using any code, it turns out it’s really easy: look at the Property panel on the Armature layer and change “Type” from “Authortime” to “Runtime.” Probably this is in the help somewhere, but I just stumbled across it on my own.
Note: I have recently updated the swf so it uses vectors rather than bitmaps so you can more easily do the selection. If anyone can figure out how to combine the runtime method with the authortime method so you can have your puppet fly in and then allow the user to move it around, please let me know — I was having difficulties with this. I assume it can be done by using several swf files rather than a single one. Also I found out that skewed movieclips in your armature can have unwanted side effects.