• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Q&A

Q1:I'm having trouble figuring out why I keep getting the following error: “Statement must appear within on/onClipEvent handler”. What does that mean, and how do I avoid it?
A1: That's one of the most common errors. Basically, it's saying that the code you've directly attached to a button or Movie Clip instance must appear within an event sandwich. That is, for buttons between on(someEvent){ and } or, for Movie Clip instances between onClipEvent(someEvent){ and }. Note that this doesn't apply to code placed in keyframes—only when you select the button or clip and type into the Actions panel.
Q2:I'm not clear which method is better: putting code right on buttons or putting everything in a keyframe. Is one better, and, can I mix and match?
A2: Whichever one you're more comfortable with is better for you. Personally, I put all my code in a keyframe (or in external .as files which is another topic altogether). I like having everything in one place. The only hassle is that you have to name all the button instances (in order to refer to them and assign the onPress behavior from inside a keyframe). You can mix and match. You can even have both at once, code in a keyframe and on buttons—they'll both execute.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint