how do I stop a scene and play the next scene in adobe flash cs6 actionscript 3.0 - actionscript-3

I'm trying to make a loop animation scene where its like an eye opening and closing. I have one black rectangle that goes down and meets with another black rectangle going up to create the blink effect. Then in the middle I have a button that the viewer can click to go to the next scene. The problem is that before and after the button is pressed both scenes play simultaneously. How can I play the first loop scene and then stop it to play the next scene when a user presses that button? Thanks.

You need to tell your respective scenes to stop. Otherwise flash player will just move on to the next scene automatically after the last frame of the previous scene (and loop back to the first scene after the last frame of the final scene).
In flash, open your first scene and open the timeline view. scroll to the very end of your timeline, add a new layer, on the very last frame of your timeline on your new layer, create a keyframe (F6 on windows). With that new keyframe selected, open the code editor (F9 on windows) and put in the command stop(); OR if you want the current scene to keep looping (without moving on the next scene) put in the command gotoAndPlay(1);
If you want your other scene to stop as well at the end, repeat the above steps on it's timeline.

Related

How to make a movieclip play on a specific frame in AS3?

I'm incredibly rusty at Flash having not touched it in probably 10 years and can't seem to figure this out, or find it online:
I have a MovieClip with two layers, each having a Shape Tween. Basically its a Door that opens and closes.
I dropped it onto the main timeline but now I need it to start and stop. This is where I'm now struggling since the last time I used Flash actions could go on specific keyframes.
I made a new layer called actions just to keep things organized and currently have:
barrier1.stop();
I just want something that lets me state a frame, say 57 to have barrier1 start playing on. Tried using play(); and Event.ENTER_FRAME with no luck. How would I set this up?
Well it is easy with the instance name of your movieClip
barrier1.stop(); // Stops the movieClip
barrier1.play(); // Resumes
barrier1.gotoAndStop(12) // Goes to 12nd frame and stop
barrier1.gotoAndPlay(12) // Goes to 12nd frame and play
barrier1.currentFrame // returns barrier currentframe
For capturing frame from scene level:
this.addEventListener(Event.ENTER_FRAME,onLoop);
function onLoop(event:Event){
if(barrier1.currentFrame == 57){
trace("BARRIER is in 57. frame");
}
}
Inside on the animation clip on the first frame
var root:MovieClip = this.parent as MovieClip
root.makeStartSceneAnimation()
**in timeline scene level [root]**
function makeStartSceneAnimation(){
/// barrier started to play
}
If you are using timeline, you can add Key frame on the desired frame, and then add stop(); as Action in the action layer. But bear in mind that if you do this in the main timeline - it will stop everything. If you want to stop that MovieClip, then you have to do this inside MoviceClip's timeline.

Flash CS6 AS3 play sound on one frame only, stop when left frame

I have a scene which has a frame for each screen that I want to display to the user. Each frame has a movieclip which contains all the elements for that screen. The first frame's movieclip has frame1 set up with a sound layer. Problem is, when I navigate to a different screen, the music continues to play.
How can I get it to only play whilst the movieclip is visible on the screen? I tried to have an "ENTER_FRAME" listener of the other screens and used SoundMixer.stopAll(); which stopped the music. The only problem is, when I reentered the frame with music, it wouldn't start.
I am using the Sync Setting: Stream.
Flash IDE has a number of different kinds of sounds, the most important being Stream and Event.
It sounds like you're using an Event type sound because the sound continues to play even when you are off the frame. There is no way to stop an Event sound except with SoundMixer.stopAll().
You need to set the sound type to Stream in Flash IDE. Then, place it in a MovieClip and make sure that there enough frames in the clip to last the whole duration of the sound. Then, place that MovieClip in your main scene and it should now stop when you move to a different frame.

Play movie clip on click at mouse coordinates

I'm trying to play a movie clip of a circle expanding and fading away every time a user clicks. I make the movie clip, then I convert it to a movie clip again and create a motion tween making the circle get larger and fade away. But, when I call on the clip it just keeps playing over and over in the last place you click. If I set a stop at the last frame of the tween the next time you click it, it won't play.
fs15secTapBtn.addEventListener(MouseEvent.MOUSE_DOWN, fs15secdownHandler);
function fs15secdownHandler(event:MouseEvent):void
{
circletouch.x = mouseX;
circletouch.y = mouseY;
}
Thanks!
You need to start/stop the movieclip every time you click. Right now, when you click the first time the clip would be put on stage and playing. Then when you click again, all you're doing is modifying the x and y positions of the clip, which moves the clip to the mouse coords...but the clip itself would still be continuing to be in whatever state it is in during the click (playing on it's own at whatever frame).
Within your click handler add in a circletouch.gotoAndPlay(1); to restart the playing at frame 1. Also, you may want to re-add that stop(); back in so that it'll only play once.

gotoAndStop makes it go to the next frame in Flash CS6

I have a problem: I have a movieclip ("gesprekkencivcen") with several frames and layers. I've put this action on a certain button at frame 1:
this.addEventListener(MouseEvent.MOUSE_UP, conv1);
function conv1(evt:MouseEvent):void{
MovieClip(root).gesprekkencivcen.gotoAndStop(23);
}
Now, in stead of going to frame 23 when I click the button it goes to the next frame (which is frame 2). What am I doing wrong??

AS3 move object back to first frame from current position in tween

I have an object with an instance name of arrow that moves across the page on a motion tweet when a button is pressed. When the button is released I want the arrow to move back to the start of the tween frame by frame.
I have set up an if statement when the button is released and its current frame is more than 1 to go back 1 frame.
So far the arrow is ignoring the if and stopping due to the else statement.
btn.addEventListener(MouseEvent.MOUSE_OUT, out);
function out(e:MouseEvent){
if(arrow.currentFrame > 1){
arrow.gotoAndStop(arrow.currentFrame - 1);
}else{
stop();
}
}
You would probably be better off making another tween on the timeline that goes backwards then just playing that. Another option is to use a third party tweening library like tweenlite since in there you can easily setup animations to run forward or in reverse.
Are you sure arrow is the name of the movie clip that you want to run the frames backwards on, or is that the instance of the element that changes over some other movie-clips timeline?