Skip to main content
Balthazar1234
Participant
December 18, 2015
Question

Button that can change a variable?

  • December 18, 2015
  • 1 reply
  • 292 views

Hello

I'm currently doing my year 13 ICT coursework and was trying to find an easier solution for my button/ navigation system.

My product has several scenes; a home page, 4 subsection pages and a quiz page.

currently when I press a button (to go from the home to a subsection for example) it jumps to the page like needed however I need to add in transitions, I could add in new scenes that would contain the separate transition but personally I think that would take too long creating a scene for every transition needed for the product so I was wondering, is it possible to combine a variable with a button?

My idea was that on the home page there are 4 main variables, 1 for each button.

Then when a button is pressed it will continue to play the scene while changing the variable by +1          (so in this case, button A will change var A to +1 and continue to play)

Then when the transition has ended there would be some script of "if statements" saying:        if variable A = 1 then continue to subsection A

also I would then need to subsection page to reset the variables back to 0, ready to use again

I hope this question make sense, if it does not please let me know

thanks

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 18, 2015

sure.

you can have 'outro' scene that would display the fade-out or some other transiition out from your main scene and use the variable set by your button to determine which scene to display after the outro:

eg:

var nextscene_var:String;

scene1_btn.addEventListener(MouseEvent.CLICK,scene1F);

function scene1F(e:MouseEvent):void{

nextscene='scene1';

gotoAndPlay(1,'outro');

}

scene2_btn.addEventListener(MouseEvent.CLICK,scene2F);

function scene2F(e:MouseEvent):void{

nextscene='scene2';

gotoAndPlay(1,'outro');

}

//etc

// on the last frame of your outro scene:

gotoAndPlay(1,nextscene);

Balthazar1234
Participant
January 14, 2016

Hello

Sorry for such the late reply but I've been very busy with other subjects work.

I have tried to use this script and it has worked wonderfully

many thanks

Tom

kglad
Community Expert
Community Expert
January 14, 2016

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)