At 12/18/08 10:25 PM, Afro-Ninja wrote:
so, I've been working with AS3 a lot lately
Hmm do I smell a flash off?
For those using AS3, does anyone find the timeline system to be very finicky, particularly with the displayList? it seems that modifying the display list at the wrong times will result in null value errors. I know I'm still AS3 noobish but I've tested out some very basic examples of timeline manipulation and ran into errors with it, such as adding a new empty sprite to the display list and immediately switching back a frame.
Ya, the thing is the order in which things happened were switched around:
AS2:
1. gotoAndPlay
2. Frame is unloaded
3. New frame is loaded
4. Rest of code
AS3:
1. gotoAndPlay
2. Frame is unloaded
3. Rest of code
4. New frame is loaded
Well that's the effect anyway. It makes it a pain to reference things immediately after swapping frames, it's not a HUGE deal if you wrap your entire code in a try{ }catch(e:Error){} block
Now working around this is a chore, but it's not HORRIBLE. You need to set up a RENDER event (Event.RENDER i think). Anything in this block gets executed AFTER the new frames are loaded, however for it to be triggered you have to call Stage.invalidate() after your gotoAndPlay()'s (if you need to use it every frame you can just put it at the bottom of your code once).
I haven't yet tried calling Stage.invalidate() within a RENDER event if you need to chain them, but I'd imagine it would work. You'd probably need to keep a counter so you know which iteration of render you're on.