Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Button that can change a variable?

New Here ,
Dec 18, 2015 Dec 18, 2015

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

TOPICS
ActionScript
264
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2015 Dec 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2016 Jan 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2016 Jan 14, 2016
LATEST

you're welcome.

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines