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
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

791 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