Copy link to clipboard
Copied
I need help writing the code for a button that will switch the current scene.
-I want the button to be activated by the spacebar
-when the button is activated it will automatically switch the scene to another scene playing simoutaenously
-if the button isnt activated after 5 seconds it will dissapear
Could someone give me an example of what this code will look like. I am a beginner to Actionscript with very limited knowledge of coding, I appreciate all help thank you.
Copy link to clipboard
Copied
it's not clear what you mean by, "..the button to be activated by the spacebar".
clicking the button (with the mouse) could trigger a scene change or pressing the spacebar could trigger a scene change.
Copy link to clipboard
Copied
Sorry let me make myself clearer.
I want to have a video clip playing and at a specific frame I want a button to appear on the screen, only the spacebar can activate this button nothing else.
When this button is activated it will switch the video clip to another one playing simultaneously.
Copy link to clipboard
Copied
what purpose does the button serve? does it need to be clicked?
Copy link to clipboard
Copied
Only the spacebar can activate this button nothing else.
When this button is activated it will switch the video clip to another one playing simultaneously.
Copy link to clipboard
Copied
just use a keyboardevent listener. the button appears to be irrelevant.
this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
function keydownF(e:KeyboardEvent):void{
this.gotoAndPlay("framelabelornumber","scene name");
}
Copy link to clipboard
Copied
Thanks alot this is really helpful I have another question.
What is the process in Flash to having two video clips playing simultaneously, when this button is activated the video clips will switch instantly and continue playing?
Copy link to clipboard
Copied
Sorry I also frogot to mention the button only appears if you want to switch the video clip, if you dont actiavte the button after a few seconds it will dissapear and the original clip will continue playing.
Copy link to clipboard
Copied
use two flvplayback components to play two videos simultaneously.
your button serves no purpose (that you've been able to explain so don't use it).
when the keydownF executes, you can change the source properties for the flvplayback components (to change the videos they play) without needing to change frame.
use a timer to trigger an event that will occur after a certain period of time.
Copy link to clipboard
Copied
The purpose of the visible button is to give the person watching an option to switch between "video 1 and 2"
The button will only appear for a few seconds and if it isnt activated it will dissapear. Only during that time period will you have the option to switch between videos.
How do I insert two flvplayback components in flash? Do they each go on seperate layers or seperate scenes?
Copy link to clipboard
Copied
just place two of them on stage. they can be in the same layer/same frame or different layers.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now