A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: setChildIndex kills frame animation

Threaded View

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929

    setChildIndex kills frame animation

    I've got a movie with some buttons in the middle of the screen. I've got a tween on the buttons to make them grow/shrink on rollOver/rollOut, when a button is clicked, I've got a frame animation that moves the buttons to the top of the screen and shrinks them. This all works fine.

    When the buttons grow, they need to appear on top of all the other buttons. Since there's no more swapDepths, I'm using setChildIndex to move the rolled over button to the top. Now, when I click one of the buttons (after rolling over it), any of the buttons I've rolled over aren't affected by the frame animation.

    Here's the code, and I attached an fla file...any ideas??

    Code:
    import fl.transitions.*;
    import fl.transitions.easing.*;
    
    
    for (var i:int=1; i<=2; i++) {
    	this["btn"+i].addEventListener(MouseEvent.ROLL_OUT, mouseListener,false,0,true);
    	this["btn"+i].addEventListener(MouseEvent.ROLL_OVER, mouseListener,false,0,true);
    	this["btn"+i].addEventListener(MouseEvent.CLICK, mouseListener,false,0,true);
    	this["btn"+i].useHandCursor=true;
    	this["btn"+i].buttonMode=true;
    }
    
    var tw:Tween;
    
    function mouseListener( event:MouseEvent ):void {
    	switch ( event.type ) {
    		case MouseEvent.ROLL_OVER :
    			tw = new Tween(event.target,"scaleX",Strong.easeOut,event.target.scaleX,1.5,.50,true);
    			tw = new Tween(event.target,"scaleY",Strong.easeOut,event.target.scaleY,1.5,.50,true);
    			var mc:MovieClip;
    			mc = event.target.parent as MovieClip;
    			mc.setChildIndex(mc.getChildByName((event.target as MovieClip).name), (mc.numChildren - 1));
    			break;
    
    		case MouseEvent.ROLL_OUT :
    			tw = new Tween(event.target,"scaleX",Strong.easeOut,event.target.scaleX,1.0,.50,true);
    			tw = new Tween(event.target,"scaleY",Strong.easeOut,event.target.scaleY,1.0,.50,true);
    			break;
    
    		case MouseEvent.CLICK :
    			gotoAndPlay("slideUp");
    			break;
    	}
    }
    stop();
    Attached Files Attached Files
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

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