A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: Subservient Chicken

Hybrid View

  1. #1
    Member
    Join Date
    Mar 2009
    Location
    Brooklyn, NY
    Posts
    77
    Ok, if you're using AS3 this is going to be a bit trickier. Because of how AS3 uses event listeners you can't just pass in a variable. If you have the time then now would be a good chance for you to read up on custom event managers so that you would be able to add parameters to your mouse events.

    However, there is a work around that you can use. It's not the best way (the custom event manager would be the best), but it will work.

    What you want to do is something like this:
    Code:
    button1.addEventListener(MouseEvent.CLICK, playTheMovie);
    button1.addEventListener(MouseEvent.CLICK, playTheMovie);
    button1.addEventListener(MouseEvent.CLICK, playTheMovie);
    
    function playTheMovie(me:MouseEvent):void
    {
       switch(me.target.name)
       {
          case "button1":
             yourFlv_instanceName.contentPath = "sit";
             break;
          case "button2":
             yourFlv_instanceName.contentPath = "stand";
             break;
          case "button3":
             yourFlv_instanceName.contentPath = "hop";
             break;
          case default:
             yourFlv_instanceName.contentPath = "sit";
             break;
       }
       yourFlv_instanceName.play();
    }
    So basically whichever button you click the function "playTheMovie" gets called. It then checks the name of the button (button1, button2, or button3) and assigns the content path accordingly using the switch statement. When that is done it tells the FLV component to play the video.

  2. #2
    Junior Member
    Join Date
    Mar 2009
    Location
    UK
    Posts
    9

    Thumbs up

    I can now see the differences between AS2 and AS3, I'm tempted to jump back on to AS2, but I'd like to give this a go!
    Last edited by Mayato; 04-26-2009 at 05:56 PM.

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Location
    UK
    Posts
    9
    Right, this is doing strange things, God help me!


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