-
Script Wrong? Help Please...hitTest
Code:
onClipEvent(enterFrame){
if(this.hitTest(_root.targe-1)){
score += 10;
}
}
Whats wrong with this?
I want it to add 10 to Var "score" when it hits "targe-1"...
-
My guess would be that it's not reading 'targe-1' correctly... probably interpreting it as targe minus one. Not sure, though.
-
-
onClipEvent(enterFrame){
if(this.hitTest(_root.targe1)){
_root.score += 1;
}
}
This is my script now, but it adds up 1+1+1+1+1=11111, insteed of 1+1+1+1+1=5 as i need...
Whats wrong?
-
You probably have to define _root.score as a Number; it seems to be interpreting it as a string.
Try
code: Number(_root.score) += 1;
instead.
-
That didnt work, errors..
-
Ah, I see. I tried it out and I got the same error; apparently Number() can't be on the left side of an equation... it works if you type it this way, however.
code: _root.score = Number(_root.score) + 1;
-
Hey Timmy!!!
at the beginning of your code put:
var scrore:Number = 0
that way when you use the score varirable Flash will know that its a number instead of a string
-
-
Hey Timmy!!!
No problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|