Solved

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

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

[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

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…
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…
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 what frame rate is, how to control it and what effect it has on the video.

691 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