A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Script Wrong? Help Please...hitTest

  1. #1

    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"...

  2. #2
    Member
    Join Date
    Aug 2006
    Posts
    56
    My guess would be that it's not reading 'targe-1' correctly... probably interpreting it as targe minus one. Not sure, though.

  3. #3
    Okay, thanks..

  4. #4
    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?

  5. #5
    Member
    Join Date
    Aug 2006
    Posts
    56
    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.

  6. #6
    That didnt work, errors..

  7. #7
    Member
    Join Date
    Aug 2006
    Posts
    56
    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;


  8. #8
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    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

  9. #9
    Thanks Dude!

  10. #10
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center