A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: multiple hittests

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    293

    multiple hittests

    hi all,

    not used flash for a while and my scripting is a little off...

    what i am trying to do is this - i have multiple mc instances that move randomly around the stage - there is a movie clip on the stage named "area" that when an instance passes over it - it triggers a hittest and sends the instance to frame to - and back to frame 1 when not over "area"

    i am trying to add "area2" to the instance go to frame 3 but can't get it to work...

    this is the script inside each instance:
    PHP Code:
    this.onEnterFrame=function(){
    if(
    this.hitTest(_root.area)){
    gotoAndStop(2);
    } else {
        
    gotoAndStop(1);
    //actions go here
    }} 
    but i can't add the right script to recognise both "area" and "area2" - i can make one or the other work - but not both

    any ideas to help put me out of my misery?

    fingers crossed
    ;-)random_hit.fla.zip

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Maybe
    PHP Code:
    if(this.hitTest(_root.area)){
    gotoAndStop(2);
    } else if(
    this.hitTest(_root.area2)){
    gotoAndStop(3);
    } else {
        
    gotoAndStop(1);
    //actions go here

    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    Quote Originally Posted by realMakc View Post
    Maybe
    PHP Code:
    if(this.hitTest(_root.area)){
    gotoAndStop(2);
    } else if(
    this.hitTest(_root.area2)){
    gotoAndStop(3);
    } else {
        
    gotoAndStop(1);
    //actions go here

    BINGO!!!!
    i tried various similar concoctions!!! but that my friend is right on the money...
    thanks for the help - much appreciated ;-)

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