Images resetting upon entering frame 1 (flash/actionscript 3) - actionscript-3

In frame one I have buttons that send the player to different frames. There is a button that sends to a 'how to play' frame and then from that frame a back button to the main menu. The problem is that I have clouds floating in the background that I animated with actionscript. Going to the 'how to play' page is fine, but when I hit back, the clouds freeze and new ones are created. I had everything on frame 1, but thought maybe since it was going back to the first frame it was resetting everything, so now I have the back button sending the player to a new keyframe on frame 2 but the problem still occurs.

Any code you have on frame 1 will be run again when you return to frame 1.
I'm assuming you have code there that creates the clouds.
Solution: Create the clouds on frame 1 and continue to frame 2. Create the buttons on frame 2. When you hit 'back', return to frame 2 rather than frame 1.

Related

Frame by Frame animation AS3

This is for AS3 FlashDevelop, Basically I'm super new to this. The most I've done in AS3 coding is display multiple images on a single frame and parallax images.
However I want to know how to display embedded Bitmap (.png pictures) as frames one after another,
like frame 1 = embedded image 1 frame 2 = embedded image 2 (frame 1 is gone but 2 shows) frame 3 = embedded image 3 (and so on.)
and they would continuously play as an animation and stop at the first frame until I press play again
I believe I would use nextFrame, stop and gotoframe but don't know where and what I need to code, I heard of bitmapdata but I'm stuck on how to use it in purpose of animating frame by frame.
EDIT: No I'm not animating sprites, rather it's more like cartoon process where you'll go frame by frame of the image files, as one appear the previous one disappears.
You could iterate through each frame and add the images after you load them.
If you do addChild() it should add it to the current frame you're on. Load the next image with a Loader, place it down with addChild, nextFrame(), and repeat until you have all the images. Then when they're all loaded (from what I guess would be some list you'd have in an array or an xml) take the user to frame 1. You might want to do this inside of a movieclip while having that and a cover graphic on your main stage so the user doesn't see all of the images while they're being loaded and placed.
[More about adding display objects to frames]

AS3 Timer Class causing odd behaviors, black screen, not starting, etc - Full code available

So I'm trying to use the timer class in a Flash CC AS3 script.
When the SWF loads, it plays this looping video. When the user clicks the video, it goes to the next frame where there are 4 buttons which play movies, and a timer.
The timer is there so that if the user doesn't click after a few minutes (in this case a couple seconds) the SWF returns to frame 1 and plays the looping video, once again, until the user clicks.
After adding this to my COMPLETE and MOUSE_EVENT event listeners...
this(root).attractTimer.start();
when I click on the video, it removes it from stage and I'm again presented with the 4 buttons.
It's at that moment I need it to start the timer once again. If the timer runs out, it needs to gotoAndPlay(1).
I'm banging my head on the desk with this right now.
Looks like I got it working.
The buttons that fire off the video, I was using...
this(root).attractTimer.star();
I didn't need to use 'this'
instead I used
attractTimer.start();

Actionscript 3 - lock the code from restarting while it loops

I am making a boardgames in flash, with a background with moving objects.
It goes on repeat, so they dont stop on the last frame, which in this case is 60 frames. Only problem is, the actionscript code which has its own layer, and exists on frame 1, resets every time it starts over again, logically enough. But then I loose all the data I´ve gained over the time of 60 frames.
Is there a way I can make the actionscript code unbound from the objects loop?
Cheers
On the last frame of your animation, add a bit of AS3 code to force skipping frame 1:
gotoAndPlay ( 2 );
When the playhead reaches the last frame, this line will execute and your animation will restart at frame #2, skipping the code on frame #1.

is there anyway that i can move to some frame in actionscript based on a random number from a dice?

here's the thing, i am actually new to actionscript and currently developing a a game in flash. the game is snakes and ladders. i have problems with regards to how to move the player avatar to the boxes of the game board. here's what i did. i made 100 frames, and with each frame is where the position of the avatar. (for example, frame 2 shows that the avatar is in box 2, etc).only thing is how do i make the frame move depending on a random number given by the dice.?
for example if i was originally in frame 2, and the dice gave a random number of 5, how do i get to frame 7? like playing the frames 3 - 6 and stopping at frame 7?
To move to a specified frame, invoke gotoAndStop() with a frame number as parameter. Of course, it can be calculated, and you can refer to movieclip's current frame via currentFrame property.
The manual

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

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.