Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 98
  • Last Modified:

Flash ActionScript

Any idea when the script "gotoAndPlay("menuClose")" at Frame 12 be executed ? In AS layer, frame 12 ha execute "stop". It seems that code at frame 12 never be executed. Any idea ?

Thx
001.fla
0
AXISHK
Asked:
AXISHK
  • 3
  • 3
1 Solution
 
quizengineCommented:
1. Open the fla. You will need to do this in Flash CS6 (or earlier version) as the file is Actionscript 2, and versions of Flash and Animate after CS6 don't support Actionscript 2.

2. Double click the 'menu' movieclip (the one that has the text 'Photos' in it)

3. Single click the button (that also has 'Photos' text on it).

4. Look at the 'Actions' panel (F9 if it isn't open).

5. You will see the code
   on(release){
         gotoAndPlay("menuOpen");
   }
This shows that when that button is clicked, this timeline will advance to the 'menuOpen' label (frame 2) and play, The playhead will  continue until it reaches frame 12 where it will stop, because of the 'stop();' command on frame 12 (AS layer).

6. Here's the crucial bit... The three layers 'hit text', 'sub btn' and 'btn' each have something interesting to look at.

7. btn layer. Single click the ''Photos' button. Look at the Actions panel. You will see
on(release){
               gotoAndPlay("menuClose");
}
This is one answer to your question about when the code will run. Answer - when this button is clicked.

8. sub btn layer. Click on either the button labelled  '001' or '002' and look at the Actions panel. On the '001' button you will see the code...
on (release) {
      _parent.gotoAndStop("f5");
      gotoAndPlay("menuClose");
}

and on the '002' button you will see the code

on (release) {
      _parent.gotoAndStop("f10");
      gotoAndPlay("menuClose");
}

In both cases, part of the code that's run is 'gotoAndPlay("menuClose");'
(NOTE, You must click the blue BOX that forms the button, and NOT the actual '001' or '002' text, which is just text, and not a button)

9. Lastly, the 'hit text' layer. In the version of the fla that I downloaded, this layer is locked. You will need to unlock it (click the padlock) to see this next bit.
Click anywhere over any part of the content on the stage, and you will select an invisible (alpha = 0) box. Look at the Actions panel. You will see

onClipEvent (enterFrame) {
      if (this.hitTest(_root._xmouse, _root._ymouse, true) != true) {
            delete onEnterFrame;
            _parent.play();
      }
}

This code is responsible for the runtime behaviour "If, after clicking the 'photos' button, you DON'T click again, but just move your mouse pointer away from all of the buttons, the menu 'collapses').

Hope that all helps.
0
 
AXISHKAuthor Commented:
What's the meaning of "delete onEnterFrame;" ? For " _parent.play();" does it mean flash will continue to play the remaining frames where it  previously stop ?

"this.hitTest(_root._xmouse, _root._ymouse, true) != true" - How does it check the mouse position ? For "this" and "_root", does it refers to hit text and scene1 respectively ?


Thx.
0
 
quizengineCommented:
"delete onEnterFrame;"

An "onEnterFrame" event, runs all of the time, at the frame rate of the Flash movie. This means it is consuming 'resources' all the time it runs. So it's good programming practice to get rid of these events, once they're no longer useful. That's what "delete onEnterFrame;" does - it deletes 'itself'.

"_parent.play();"

Do you know 'Russian Dolls'? How you can have a doll inside a doll inside a doll (etc etc).

Well, Flash movieclips are the same. Think of the timeline that were working in, as a russian doll... It can have smaller dolls (other movieclips) inside of itself . These are called 'children'. And it works the other way too - if you are the 'child' of a movieclip, then it's your 'parent'.

Have a look here to learn more about this.

https://helpx.adobe.com/animate/using/multiple-timelines.html
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001345.html
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AXISHKAuthor Commented:
How about "this" and "_root" mean ?

The frame delete itselft - do you mean it will not run the the code inside that frame ?

Thx
0
 
quizengineCommented:
_root is the 'top' movieclip / timeline - if you like, the 'biggest' of the russian dolls. This is a quick way for a very 'buried' (nested) movieclip to refer to the 'top' parent. (Otherwise a movieclip that was buried might have to use something like _parent._parent._parent,_parent... etc)

 The onEnterframe code continues to run UNTIL the test

       if (this.hitTest(_root._xmouse, _root._ymouse, true) != true)

comes out as 'true', and then the code

     delete onEnterFrame;

runs, which deletes this whole block of code.
0
 
AXISHKAuthor Commented:
Thx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now