Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Flash ActionScript

Posted on 2016-11-07
6
Medium Priority
?
94 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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

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.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

722 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