• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

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. :(
0
Knightley
Asked:
Knightley
  • 2
1 Solution
 
Saqib KhanSenior DeveloperCommented:
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.
0
 
KnightleyAuthor Commented:
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?
0
 
Saqib KhanSenior DeveloperCommented:
Code Runs , Line by Line, One after another.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now