A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: hit test inside IF condition

  1. #1
    Member
    Join Date
    Jun 2009
    Posts
    69

    Unhappy hit test inside IF condition

    ive tried with this script (as2)

    on (press) {
    if (triggermc._visible == true) {
    if (d1.hitTest(_root.d2.hit)) {
    d1._visible = false;
    }
    }
    }
    to combine on button function with if condition and hit test but it isnt working.
    It should activate "d1.hitTest(_root.d2.hit)" only when "triggermc._visible == true", and result of that interaction should be "d1._visible = false;"
    Is the problem in fact that i have two if conditions in a bunch or something else, is it possible at all to combine two if function in this way.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Please provide FLA file
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Member
    Join Date
    Jun 2009
    Posts
    69
    hers the file
    https://rapidshare.com/files/1154379669/Untitled-1.fla

    as you will see all that complication was because i want to make d2,d3,d4....and so on disappear when you hold pressed mouse button and hit them with clip which represent cursor (move over them) , and make it work only when trigger mc is visible ( which will tell if you are pressing mouse button or not) please help.

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Remove all code from frames and buttons, and use this one code on your Frame:

    Actionscript Code:
    Mouse.hide()
    startDrag(d1,true);
    triggermc._visible=false;

    down = false;

    onMouseDown = function(){
        down = true;
        _root.triggermc._visible = true;
    }

    onMouseMove = function(){
        if(down == true){
            for(i=2;i<6;i++){
                if(_root["d"+i].hitTest(_root.d1._x, _root.d1._y, true)){
                    _root["d"+i]._visible = false;
                } else {
                    _root["d"+i]._visible = true;
                }
            }
        }
    }

    onMouseUp = function(){
        down = false;
        _root.triggermc._visible = false;
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Member
    Join Date
    Jun 2009
    Posts
    69
    perfect
    thank you again!

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    no problem, glad it helped
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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