Pain Relief > Motrin 400mg Pills (Generic) > 30 Pills > $81.00

ActionScript 3.0 Flash

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 This topic came up when someone asked me how (if it was possible) to instruct one movie clip to start playing after another has stopped.  For example, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 the main timeline does its thing, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 humming along, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 when it suddenly comes to a keyframe that contains a nested movie clip.  A simple stop() action in that keyframe tells the main timeline to rest where it is, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 and the nested movie clip starts playing on its own.  When the nested clip hits the last frame of its own timeline … that’s when the main timeline needs to start moving again.  How to do that?

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 In my reply, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 I said there were a number of possible ways.  You could set up a loop, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 for example — MovieClip.onEnterFrame (AS2) or Event.ENTER_FRAME (AS3), pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 maybe setInterval() (AS2) or the Timer class (AS3) — and in that loop, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 check the current frame of the nested movie clip against the number of its total frames.  In AS2, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that would be a comparison of _currentframe to _totalframes; in AS3, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 currentFrame to totalFrames.  When the former equals the latter, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 invoke MovieClip.play() on the main timeline and quit the loop.

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 But much easier than that, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 and less processor intensive, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 is simply to put a keyframe script in the last frame of the nested movie clip, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 telling its parent (the main timeline) to play.  In AS2, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that would be this._parent.play();.  In AS3, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 this.parent.play(); (no underscore on parent).  Ah, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 but there lies a problem.  The AS3 version, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 which is technically correct, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 causes a compiler warning:  1061: Call to a possibly undefined method play through a reference with static type flash.display:DisplayObjectContainer.  What on earth? 

What’s going on?

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 Thankfully, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that error message gives a very useful clue.  Forget the cryptic 1061, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 forget “static type” blah blah.  The useful parts are “undefined method play” and “DisplayObjectContainer.”  Essentially, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 this is saying, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 “Hey, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 you’re pointing me to an instance of the DisplayObjectContainer class and asking me to invoke a play() method on it.  There is no play() method in this class, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 bub, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 so what am I supposed to do?”

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 If you look up the DisplayObjectContainer class in the ActionScript 3.0 Language and Components Reference, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 you’ll find that indeed, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 the class doesn’t support the method play().  That’s a MovieClip method.  But wait … shouldn’t the expression this.parent — as stated by a movie clip in the main timeline — point to a valid MovieClip reference?  To be fair, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 DisplayObjectContainer is indeed an ancestor in MovieClip’s family tree.  MovieClip extends Sprite, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 which extends DisplayObjectContainer, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 but the main timeline certainly is a movie clip.  In fact, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 you can prove it.

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 Create a new ActionScript 3.0 FLA, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 draw a quick shape and convert it to a movie clip symbol.  Enter its timeline and, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 in frame 1, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 type trace(this.parent is MovieClip); (is replaces instanceof in AS3).  Test your movie and keep an eye on the Output panel.  Sure enough, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 Output panel says true.

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 So what gives?  If the expression this.parent points to a valid MovieClip instance, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 why isn’t Flash smart enough to allow for the invocation of a MovieClip method, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 such as play(), pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 on that instance?  Honestly, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that’s a good question.  It’s so good, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 I can’t answer it.  But I do know how to get around it.  ;)

The “unsafe” workaround

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 That overly cautious error message is the result of Flash CS3’s default strict mode for the compiler.  I don’t recommend the following change, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 but if you simply want to turn off the warning (along with a bunch of other useful warnings, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 all in one shot), pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 head over to File > Publish Settings > Flash tab, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 then click the Settings button.  Remove the checkmark from Strict Mode and you’re done.  Test your code and it’ll work just fine — because (in this context) this.parent really is a MovieClip reference.

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 Again, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 experiment with that if you like, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 but I really don’t recommend it.  By turning off strict mode, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 you may be tempting yourself to write lazy code, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 and sooner or later, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 especially in AS3, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that will bite you with a set of sharp teeth.  And it’ll happen on a day when your boss is breathing down your neck.

The better workaround

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 I call this one “better” because, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 by using it, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 you end up demonstrating that you know how to be sensitive to the compiler, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 paranoid as it may occasionally be.  The better you know what the compiler needs, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 the likelier you’ll master the language.

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 We already know, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 even if the compiler doesn’t seem to, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that the expression this.parent — in this context! — does refer to a MovieClip instance.  We’re simply going to tell the compiler that.  By casting that expression as a MovieClip, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 you’re effectively saying, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 “Trust me on this one; this is a MovieClip.”  Casting is done like this:

MovieClip(this.parent).play();

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 Note that only the object reference, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 this.parent, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 goes inside the parentheses.  The new combined expression, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 MovieClip(this.parent) gets .play() (with the leading dot) tacked on to the end, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 and even with strict mode on, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 that’ll do it.

Pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 That goes for any MovieClip class member, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 by the way, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 not just play().  All the cast does is let the compiler know it’s truly dealing with a MovieClip, pain relief > motrin 400mg pills (generic) > 30 pills > $81.00 so any MovieClip feature is covered.

Average Rating: 4.7 out of 5 based on 220 user reviews.

Leave a Reply