Jump to scene based on button click

Brian Coughter
Brian Coughter used Ask the Experts™
on
I have a button that I set a variable on:

onClipEvent (mouseDown) {
      var buttonHit:String = "AboutUs";
}

Upon clicking this button (which is a Movie Clip), I am taken to a transitional scene.  At the end of that scene an action is supposed to pick up that variable that was set on the button click and take me to the next scene based on the evaluation of that variable.  However, it's not working.  Is this the best way to go about this?

gotoAndPlay("eval(buttonHit)",1);
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Process Improvement Mgr
Commented:
try to change the scope of your variable to _global

_global.buttonHit:String = "AboutUs";

the movie you're refercing later doesnt know that var button exists, because it was created inside a button, and only exists there. :)

Montoya

Author

Commented:
Got it:

onClipEvent (mouseDown) {
      _global.buttonHit = "AboutUs";
}

Here's my issue now:

the buttonHit var gets assigned no matter where I click.  How to I assign that var only when I click the AboutUs movie clip?
MontoyaProcess Improvement Mgr

Commented:
aboutUs_mc.onRelease=function(){
_global.buttonHit = "AboutUs";
}

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

MontoyaProcess Improvement Mgr

Commented:
In other words, you want to assign the action to the object in question, not to the type of object (clip).
It's the equivalent of saying "if basketball player gets goal, do this", instead of saying.. if "Tim Duncan gets goal, do this".

Author

Commented:
So _mc is an ActionScript suffix used to point to a specific movie clip?  

Author

Commented:
Never mind, I'm retarded.  I got it now...


AboutUs.AboutUs_Button.onRelease = function(){
      _global.buttonHit = "AboutUs";
        gotoAndPlay("GPE", 1);
}

Thanks for all the wizardry!
MontoyaProcess Improvement Mgr

Commented:
my pleasure..  btw, _mc is something you add to the end of your move clip instances if you want actionscript to give you some context sensitive help in the editor. Try it. Just go to the AS panel and type.. me_mc.   once you type the dot, voila!

:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial