Solved

What is different in actionscript 3 with regard to the stop() action?

Posted on 2008-10-31
2
1,009 Views
Last Modified: 2013-11-11
Greetings Experts,

I am having difficulty preventing Flash scenes from looping in AS3.  I have a very simple test file with two scenes (Scene 1 and Scene 2).  I have a button in Scene 1 that when clicked, loads Scene 2.  This works correctly in AS2 but in AS3 the two scenes just continuously loop.  AS3 seems to be ignoring my stop() action (or I am doing something wrong).

Scene 1 frame 1 actions:
btnSubmit.onRelease = function() {
     gotoAndPlay("Scene 2", 1);
}

Scene 1 frame 2 actions:
stop();

Scene 2 frame 1 actions:
stop();

Can someone please help me understand what I'm doing wrong?  Please elaborate on the "why" behind your solution.

Thanks!
0
Comment
Question by:bham3dman
[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
2 Comments
 
LVL 2

Accepted Solution

by:
jordanaustin earned 500 total points
ID: 22859423
bham3dman,
I'd venture to say that it's not the way the stop action is effecting this, its the way you've scripted your button ActionScript. That would work correctly in AS2 but for AS3 you'll need to open an event listener.

Try using this code:

btnSubmit.addEventListener(MouseEvent.CLICK,btnSubmit_CLICK);

function btnSubmit_CLICK (e:MouseEvent):void
{
btnSubmit.gotoAndPlay"Scene 2", 1);
}
stop();

Let me know if that works.

-jordan
0
 
LVL 5

Author Comment

by:bham3dman
ID: 22863086
Thanks for the response Jordan.  Your solution pointed me in the right direction.  However, I did have to modify your code in order for it to work.

The following code worked:

btnSubmit.addEventListener(MouseEvent.CLICK, btnSubmit_CLICK);

function btnSubmit_CLICK (event:MouseEvent):void
{
gotoAndPlay(1, "Scene 2");
}

stop();

Thanks!
0

Featured Post

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!

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,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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 what frame rate is, how to control it and what effect it has on the video.

756 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