A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: movieclip in conditional statement of if

  1. #1
    Senior Member
    Join Date
    Apr 2000
    Location
    Minneapolis
    Posts
    2,127

    movieclip in conditional statement of if

    Hi,
    In the code below how can I use the movieclip in the conditional statement?
    This is simplified, there is lots more going on but the basic issue is shown.
    I want to say if currently dragged mc is dot1_mc do the copyDragTo35 function
    PHP Code:
    var item:MovieClip;

    //add event listeners to all dots
    kite_mc.dot1_mc.addEventListener(MouseEvent.MOUSE_DOWNonItemDragStart);
    kite_mc.dot2_mc.addEventListener(MouseEvent.MOUSE_DOWNonItemDragStart);

    function 
    onItemDragStarte:MouseEvent ):void 
        
    item e.target.parent as MovieClip;
        
    trace(item.name);//traces dot1_mc
        
    trace(item.parent.name);//traces kite_mc.dot1_mc
          
        
    stage.addEventListenerMouseEvent.MOUSE_UPonItemDragStop );
        
    stage.addEventListenerMouseEvent.MOUSE_MOVEonItemDrag );
        
    }

    function 
    onItemDrage:MouseEvent ):void 
        
        if(
    item == dot1_mc){
        
    copyDragTo35(null);
        }

    thanks
    Mark

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Posts
    113
    Try this...

    Code:
    var item:MovieClip;
    
    //add event listeners to all dots
    kite_mc.dot1_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
    kite_mc.dot2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
    
    function onItemDragStart( e:MouseEvent ):void {
        item = e.target.parent as MovieClip;
        if(item.name == "dot1_mc")  {
            copyDragTo35(null);
        }
        trace(item.name);//traces dot1_mc
        trace(item.parent.name);//traces kite_mc.dot1_mc
          
        stage.addEventListener( MouseEvent.MOUSE_UP, onItemDragStop );
        stage.addEventListener( MouseEvent.MOUSE_MOVE, onItemDrag );
        
    }

  3. #3
    Senior Member
    Join Date
    Apr 2000
    Location
    Minneapolis
    Posts
    2,127
    Thanks,
    that works.
    mark

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