Solved

Flash ActionScript

Posted on 2016-11-07
6
89 Views
Last Modified: 2016-11-08
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
Comment
Question by:AXISHK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:quizengine
ID: 41878284
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
 

Author Comment

by:AXISHK
ID: 41878322
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
 
LVL 19

Expert Comment

by:quizengine
ID: 41878332
"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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:AXISHK
ID: 41878339
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
 
LVL 19

Accepted Solution

by:
quizengine earned 500 total points
ID: 41878355
_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
 

Author Closing Comment

by:AXISHK
ID: 41879780
Thx
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question