Alright, I have a difficult problem "for me" , I'm a beginner in Adobe Flash CS6.
The Problem
I can't make the button works for all frame. I was unable to click once I jump to another frame or scene.
The Explaination
I'll explain more detail what I'm trying to do with the button.
I Have have a button which is named "Back to Menu" that placed in "Play" Scene, the button supposed to get the user back to the menu.
"Main Menu" Scene (1 Frame)
"Play" Scene (10 Frame)
The code is placed on frame 1, in the "Play" Scene and the code used is :
backtomenu.addEventListener(MouseEvent.CLICK, backmenuClick);
function backmenuClick(ev:MouseEvent):void
{
gotoandPlay ("Main Menu");
}
So, at the Main Menu there is 9 button, each button from the "Main Menu" Scene will bring to the different frame at the "Play" Scene. The backtomenu button works fine when I click the button that take me to the frame 1 in "Play Scene", but whenever I click the button that direct me from "Main Menu" Scene to frame 2 , 3 or 4 in "Play" Scene, the backtomenu button won't work.
Is there any other way to make the code readable to all frame? or make a universal button? Because I know the code wasn't read when I was at the 2nd Frame in the "Play" Scene. do I have to make a different code for each frame? if that so, that's insane.
You can put your "Back to Menu" button on a new layer with 1 keyframe & 9 frames to cover the whole "Play" scene.
Your "backtomenu.addEventListener" code needs to be placed in the keyframe of the new layer.
Related
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??
I am making a flash file, I am using Adobe Flash CS6 to make it and so using ActionScript 3.0 for coding, I have a kind of "a link" called "About", it should move the flash to a frame that has the "About" content which number is 290 here in my case.
Here is my code for clicking on the "About" button:
import flash.events.MouseEvent;
var frameNumber:int;
var counter:int;
function onClick3(event:MouseEvent):void
{
if (counter%2 == 0)
{
frameNumber = currentFrame;
gotoAndStop(290);
}
else
{
gotoAndStop(frameNumber);
}
counter++;
}
aboutButton.addEventListener(MouseEvent.CLICK, onClick3);
This should display the "About" frame on even clicks (starting from zero) and go back to the frame that "About" was clicked from on odd clicks, like this:
Click on "About" --> Show About.
Another Click on "About" --> Hide About and go back to the calling frame.
Another click on "About" --> Show About.
And so on..
It works well for moving between a frame and the "About" frame (290), but the problem is that I have a "Next" and "Previous" buttons too, but when I come back from the "About" page, the whole flash freezes and nothing work except the "About" button, so what is the problem here ? What can solve this ?
And if there exist, is there a way to display my "About" section as a pop-up message in flash ?
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.
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.
Im doing a program in AS3 and, i'm trying to do the following:
Lets say I have a button, which have onClick event, and when the event is triggered, the popup window will appear.
And in this popup window there is going to be an animation (countdown) of 2020 (this is just an example).
Is there a way to do this without javascript. Because i'm not doing this for website, its going to be a animation.
Hope i was clear.
Thanks
In Flash,create a movie clip, give it an instance name of "countdown_mc", put the countdown animation inside it.This will be your "alert" type window.
Now, in the movieclip containing "countdown_mc", add a new layer and on the same frame bring up the action editor(F9) and write the following: countdown_mc.visible=false;
When you push the button it should make countdown_mc.visible=true and maybe do an optional growing animation;
Also on this frame add a listener for countdown_mc so that when the user clicks on the window it disappears(countdown_mc.visible=false);
For animations add download tweenmax from http://www.greensock.com/tweenmax/, extract the archive in the folder that contains your fla and add the following to your code:
import com.greensock.*;
TweenMax.from(countdown_mc,0.5,{scaleX:0,scaleY:0});