A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Can a button play a mc on a different layer?

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Question Can a button play a mc on a different layer?

    Hi

    I don't know if this is possible, but can you have a button on one layer play a mc on another layer?

    I am trying to build a file where when my button is clicked, it will move the x and y axis of a movie clip on the layer below.

    I'm working in CS4 action script 3.0 (no drop down menu option?)

    Any help would be totally totally appreciated!

  2. #2
    Junior Member
    Join Date
    Dec 2009
    Location
    Toronto
    Posts
    6
    Yes, it's possible. You have to give an instance name to your movie (for example - mc) and add a click listener to your button, like this:

    Actionscript Code:
    playButton.addEventListener(MouseEvent.CLICK, startPlay);

    function startPlay(e:MouseEvent):void {
      mc.play();
    }

  3. #3
    Junior Member
    Join Date
    May 2007
    Posts
    24
    I know my code is wrong, but I don't know how to correct it.

    My btn instance name is: art_btn_cfo
    My mc instance name is: work_mc

    When the btn is clicked, I'd like the work_mc to move it's x and y coordinates.

    Here is what I've got:

    play.art_btn_cfo.addEventListener (MouseEvent.CLICK, cfoClick);
    function cfoClick(e:MouseEvent):void
    {
    work_mc.play(moveContent(187,53));
    }

    Can you help out - I'm lost.

    Thanks so much.

  4. #4
    Junior Member
    Join Date
    Dec 2009
    Location
    Toronto
    Posts
    6
    Code:
    art_btn_cfo.addEventListener(MouseEvent.CLICK, cfoClick);
    
    function cfoClick(e:MouseEvent):void {
      work_mc.x = 187;
      work_mc.y = 53;
      work_mc.play();
    }

  5. #5
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Smile

    That's what I needed! Thanks so so much. You just saved me a lot of profanities!

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