Jump to content


problems with global


  • You cannot reply to this topic
4 replies to this topic

#1 worldofth4

    Young Padawan

  • Members
  • Pip
  • 17 posts

Posted 29 March 2007 - 01:38 PM

ok i've made this game but i'm stuck cause i need a variable which i can use everywhere cause it affects weither i can go to an area or not.

so i use _global.money = 0;

then when i test it by adding an extra value nothing happens. i try this by sayin if _global.money == 3 then gotoAndPlay frame 2.

i read that you can't change a _global 's value.

so if any of that makes scense can you plz help. thank you :D

#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 29 March 2007 - 02:05 PM

You can change the value of any global var whenever you want - so that isnt the issue. I suggest you try tracing out your global variable in difference places to see what it is. Check your spelling too.

Also, a good idea for global variables is to prefix them with 'g' so that you know its a global var and not a local var. Example: _global.gMoney

#3 worldofth4

    Young Padawan

  • Members
  • Pip
  • 17 posts

Posted 29 March 2007 - 02:14 PM

cool thx also i foudn out another problem it the variables don't seem to work in move clips. and i need to keep the movie clips for movement. soo can anyone help?

#4 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 29 March 2007 - 02:25 PM

Scope back to where the variables are located. If the variables are on the timeline above the movieclip, use this._parent.variableName to access the var. Keep adding _parent's on to go up more levels.

#5 worldofth4

    Young Padawan

  • Members
  • Pip
  • 17 posts

Posted 29 March 2007 - 04:58 PM

kk thx 4 the help. my idea was to creat an inventory system but when i thought about it id didn't really need it, but with all the advice as i have put this on a few forums has been very helpful thx :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users