Ok, I'm a little slow to adopt all of the nifty cool features of CS3 -- just
now taking advantage of "Copy Motion to Actionscript 3.0" where it gens the
Animator AS3 code for you. Nice.

It works if you place the code on the timeline/frame. Fantastic.

But to really put this to use, I need it to work in a class... So, I created
a simple fla, with a document class (I know it's wired up correctly, with a
trace("crack") in the constructor, which is coming back. Added the public
var for the clip on the stage "mcTest" -- and just under the trace("crack"),
added mcText.alpha = 1; (it's alpha 0 on the stage)... and that worked... so
I know the doc class is wired to the stage instance. (BTW: AS3 settings,
"Auto declare stage instances" : unchecked....)  so we're all good

Now the fun part: paste the same Animator code into the constructor,
verifying the correct instance name on the stage -- (making sure to execute
the play method... duh) and the animation *does not play*.

Then I stumbled on this from :
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/motion/Animator.html

"If you plan to call methods of the Animator class within a function,
declare the Animator instance outside of the function so the scope of the
object is not restricted to the function itself. If you declare the instance
within a function, Flash Player deletes the Animator instance at the end of
the function as part of Flash Player's routine "garbage collection" and the
target object will not animate."

So that's it! The animator instance must be a global member to the class...
and presto! It works.

Hope this helps others...
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to