A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Navigating to MainTimeline from a MovieClip

Threaded View

  1. #1
    Senior Member da_hammer's Avatar
    Join Date
    Jul 2003
    Location
    Ritchie Street.
    Posts
    294

    Navigating to MainTimeline from a MovieClip

    Hello,

    Am a newbie to AS 3.0, am trying access the MainTimeLine from a movieClip instance added from Library.
    Am able to remove the same instance, but am not able to navigate to MainTim

    Code:
    // Doesn't Work
    wellPlayed(root).gotoAndStop(120);
    
    // This removal works fine.
    parent.removeChild(wellPlayed);
    am sure am doing something silly here is the full code:

    Code:
    public class BallMc extends MovieClip
    	{
    		protected var originalPosition:Point;
    		public function BallMc()
    		{
    			originalPosition = new Point(x, y);
    			buttonMode = true;
    			addEventListener ( MouseEvent.MOUSE_DOWN, down );
    		}
    		
    		protected function down (event:MouseEvent) :void
    		{
    			parent.addChild(this);
    			startDrag ();
    			stage.addEventListener ( MouseEvent.MOUSE_UP, stageUp );
    		}
    		
    		protected function stageUp(event:MouseEvent ):void
    		{
    			stage.removeEventListener( MouseEvent.MOUSE_UP, stageUp );
    			stopDrag();
    			
    			if( dropTarget )
    			{
    				if( dropTarget.parent.name == "basket")
    				{
    					scaleX = scaleY = 0.2;
    					alpha = 0.2;
    					y = stage.stageHeight - height - 10;
    					
    					buttonMode = false;
    					removeEventListener( MouseEvent.MOUSE_DOWN, down );
    					
    					var wellPlayed : WellPlayed = new WellPlayed();
    					parent.addChild(wellPlayed);
    					
    					wellPlayed.x = stage.stageWidth / 2;
    					wellPlayed.y = stage.stageHeight / 2;	
    					
    					wellPlayed.addEventListener(MouseEvent.CLICK, wellClick);
    					
    					function wellClick(event:MouseEvent):void
    					{
    						wellPlayed(root).gotoAndStop(120);
    						parent.removeChild(wellPlayed);
    						wellPlayed.removeEventListener(MouseEvent.CLICK, wellClick);
    						
    					}
    			
    				}else{
    					returnToOriginalPosition();
    				}
    
    			}else{
    				returnToOriginalPosition();
    			}
    		}
    		
    		protected function returnToOriginalPosition():void
    		{
    			x = originalPosition.x;
    			y = originalPosition.y;
    		}
    		
    	}
    Someone point me in the right direction.

    Thanks in advance.
    Amar
    Last edited by da_hammer; 08-25-2014 at 10:33 AM.

Tags for this Thread

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