A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Creating a clickable object, how do I do it?

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    3

    Creating a clickable object, how do I do it?

    I am doing a kids story book and I have a couple questions, How do I make a object such as a a tree I drew, that when you click on it, a animation happens such as leaves move etc.

    How would I do this?


    thanks Rob

  2. #2
    Teacosy is coming ranoka's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    123
    Hey,
    This is a simple implementation:

    Code:
    containerClip.addEventListener(MouseEvent.CLICK, playAnimation, false, 0, true);
    containerClip.buttonMode = true;
    
    function playAnimation(event:MouseEvent):void
    {
    	var clickedClip = event.target;
    	
    	clickedClip.play();
    }
    Put that code on the main timeline.

    basically, you need a MovieClip on the main timeline called containerClip.
    Inside that you put your MovieClip with the animation inside it.
    On the first frame of that animation you need a stop(); so it doesn't play by itself.

    The good thing about doing it this way is you don't have to add an event listener to each MovieClip.

    Hope that's a useful start.

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