Link to home
Start Free TrialLog in
Avatar of Knightley
Knightley

asked on

about how flash works

hi, guys:

i am working on a pretty huge flash program, abd are having some problem with functions.
e.g.
function trace_projectile(x){
_root.a=0;
_root.a+=x;
... ... ... //many lines
trace(_root.a);
}

say if i use it several times, could it be, that there maybe some conflict in _root.a.
i mean, that the time i trace _root.a, the same function somewhere else just
set it back to 0 or so.

are functions in flash used one after another, or could they be used parallel???
if the later, i am afraid i must change the function using different variables. :(
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

Because _root.a is defined within the function. Everything Function repeat's itself it sets your _root.a value back to 0.
You need to define the Initial Value of _root.a outside of your function like this.
_root.a=0;
function trace_projectile(x){
_root.a+=x;
... ... ... //many lines
trace(_root.a);
}
This way function will Grab Variable "a" Value once, outside of your function.
Avatar of Knightley
Knightley

ASKER

i do want to the a set back to 0 every time i call the function.
i mean if i use the function twice,

do they run one after another or parallel?
ASKER CERTIFIED SOLUTION
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial