USERNAME:
PASSWORD:
Save Info!
Logging in…
This topic is 1 page long.
[ Profile | Posts | Contact ]
Posted at: 10/13/09 10:14 PM
Sign-Up: 05/31/07
Posts: 64
So basically, my code detects a button press, takes one away from 400 (max hp var), and decreases hp bar size. Since actions for it say HP = 400 on load frame, it resets. How can I modify script in second frame so it carries over HP value to next frame?
This post was made using Linux.
Posted at: 10/13/09 10:26 PM
Sign-Up: 03/17/07
Posts: 52
At 10/13/09 10:14 PM, RustySpoons95 wrote: So basically, my code detects a button press, takes one away from 400 (max hp var), and decreases hp bar size. Since actions for it say HP = 400 on load frame, it resets. How can I modify script in second frame so it carries over HP value to next frame?
Use _global variables.
e.g.
_global.hp=100;
Posted at: 10/13/09 11:49 PM
Sign-Up: 10/05/08
Posts: 1,608
i usually just do
if(HP == undefined){ var hp:Number = 400 }
AS2||AS3||Motox Thanks to hdxmike for the sig :]
Posted at: 10/14/09 06:47 AM
Sign-Up: 09/11/09
Posts: 1,840
At 10/13/09 11:49 PM, Yambanshee wrote: i usually just do if(HP == undefined){ var hp:Number = 400 }
Wouldnt that have the same effect as resseting ? _global variables or work in one frame
OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !
Posted at: 10/14/09 07:40 AM
At 10/14/09 06:47 AM, hdxmike wrote: At 10/13/09 11:49 PM, Yambanshee wrote: i usually just do if(HP == undefined){ var hp:Number = 400 }Wouldnt that have the same effect as resseting ? _global variables or work in one frame
oops, forgot the caps on the second variable. Once its defined as a variable, it will never again be undefined
Posted at: 10/14/09 08:00 AM
At 10/14/09 07:40 AM, Yambanshee wrote: At 10/14/09 06:47 AM, hdxmike wrote: At 10/13/09 11:49 PM, Yambanshee wrote: i usually just do if(HP == undefined){ var hp:Number = 400 }Wouldnt that have the same effect as resseting ? _global variables or work in one frameoops, forgot the caps on the second variable. Once its defined as a variable, it will never again be undefined
i suggest keeping one layer for the constant code or in AS3 just set it as a constant variable const myVar:int = 12345
Posted at: 10/14/09 08:12 AM
Sign-Up: 06/25/04
Posts: 4,926
At 10/14/09 08:00 AM, hdxmike wrote: or in AS3 just set it as a constant variable const myVar:int = 12345
Oh wow. That totally works. If you NEVER want to change a HP value throughout the game.
Current build for ThreedeeTiles : Monkey Previous: Lamprey, Mountain Goat (Dead Fork)
All times are Eastern Standard Time (GMT -5) | Current Time: 01:59 PM
<< Back