A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [MX] hittest

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Posts
    394

    [MX] hittest

    Code:
    onClipEvent (enterFrame) {
    	if (Key.isDown(Key.LEFT)) {
    	this._x -=15;
    	}
    	
    	if (Key.isDown(Key.RIGHT)) {
    	this._x +=15;
    	}
    	if (_root.mainchar, hitTest(_root.scene1right)) {
    		nextFrame();
    	} else {
    		
    	}
    }
    i don't get why this doesn't work

    p.s. i have the object mainchar on a different layer

  2. #2
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    its the if statement for the hitTest

    if (_root.mainchar.hitTest(_root.scene1right)){
    nextFrame();
    }
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  3. #3
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    i now have this
    Code:
    onClipEvent (enterFrame) {
    	if (Key.isDown(Key.LEFT)) {
    	this._x -=15;
    	}
    	
    	if (Key.isDown(Key.RIGHT)) {
    	this._x +=15;
    	}
    	if (_root.mainchar.hitTest(_root.scene1right)){
    	nextFrame();
    	}
    }

  4. #4
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    does it still not work?
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  5. #5
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    still doesn't

  6. #6
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    I would do some testing to make sure you are referencing everything properly.
    Make sure all the traces, trace what you expect.
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT)) {
    this._x -=15;
    }

    if (Key.isDown(Key.RIGHT)) {
    this._x +=15;
    }

    trace(_root.mainchar)
    trace(_root.scene1right)
    trace(_root.mainchar.hitTest(_root.scene1right));

    if (_root.mainchar.hitTest(_root.scene1right)){
    nextFrame();
    }
    }

    Also, what object is supposed to go to the nextFrame()?
    The object that has the clipEvent, or something else? Also, use the debugger to make sure everything goes correctly.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  7. #7
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    well I just want the timeline to move to the next frame. But its not on the same layer as the mainchar

  8. #8
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    nope, didn't work. It gave me like a million undefined errors

  9. #9
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    do you want me to post my fla?

  10. #10
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    sorry it wouldn't let me edit my other posts

    http://rapidshare.com/files/117545264/game2.fla.html

  11. #11
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Here's the deal.

    You forgot to give your MovieClips an instance name.

    Give your mainchar and scene1right instance names.
    Also, you can change the hitTest to - this.hitTest(_root.scene1right);
    same thing as before..

    The last thing, your next frame call when the hitTest it true, needs to say _root.nextFrame();
    before you were referencing the timeline of the mainchar, which only had one frame.

    Good luck
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


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