Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Var inside functions

Status
Not open for further replies.

Fion

Vendor
Sep 25, 2003
50
US
Hi all, I have a pretty simple question. I have a global var that I declare in the main level of the movie. I then set it to assorted movieclip paths inside functions. But the problem is, when the function ends, the variable empties. I need a varible that I can pass between functions (this will be a movieclip path of an "open" clip. This is for a dropdown menu).
Basically, I need a varible that contains the path of the currently open clip. Each time a new menu is opened, it closes the old menu, and sets the varible to the movieclip that the use just clicked on.
How can I go about this?
Thanks for your help!

Fion
 
I am using _global before the variable. That what I ment when I said I had a global variable. Should I also use Var? The problem is, when I set the global var equal to somthing inside a function, it does not actaully set the variable globally, it only stays at what I have set it until that particular function ends.
 
Well I'm not, so things could be different in MX2004, because it works fine for me on MX.
Try switching to AS1.0, to see if it then works in MX2004.
If so, then things probably have to done differently with AS2.0, regarding global variables.

Regards. Affiliate Program - Web Hosting - Web Design
 
This did not change in 2004 (or AS 2.0). If you are setting a _global variable (whether in a function or not) it is _global. There must be something else going on... timing maybe?

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top