Solved

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

Posted on 2008-10-31
2
1,005 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now