A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Buttons Inside Movie Clips

  1. #1
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    Buttons Inside Movie Clips

    Good day All,

    I'm currently creating a website in FLASH CS3 using ACTIONSCRIPT 3.0.

    On my main timeline I have several buttons which direct you to different frames using the following code:

    function onGD_WB_butClick(evt:MouseEvent):void {
    gotoAndPlay("Web Solutions");
    }
    GD_WB_but.addEventListener(MouseEvent.CLICK, onGD_WB_butClick);

    with GD_WB being my button.

    I have one button on the main timeline that sends you to a frame which plays a MOVIE CLIP and inside that movie clip I have a buttons. What I need help on is making the buttons inside the movie clip once clicked on will send you to a frame on the Main timeline. I have the frames all labelled.

    can anyone help me out by providing me with Actionscript 3.0 script or refer me to a tutorial?

    I would appreciate any help or advise you could provide me.

    Thanks in advance,
    Alan

  2. #2
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    As an advice: stop using buttons... use only movie clips
    and regarding your problem, try using (root as MovieClip).gotoAndPlay("yourFrame");
    By casting root you'll be able to access the root of your movie.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  3. #3
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    Buttons Inside Movie Clips

    What would the code look like if I want to use the the method you suggested.
    (root as MovieClip).gotoAnyPlay("yourframe");

    I haven't really used the root command before so I'm a little unfamilar with it. Any chance you could help me out?

    As for your suggestion to no longer use buttons, you're saying the best thing is to always use movieclips as your buttons, am I understanding that correctly?

    Thanks,
    Alan

  4. #4
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Yeps, that's exactly what I said. Always use movie clips, never use buttons. Buttons are way too limited and in certain situations they fail miserably. A movie clip on the other hand can be considered a separate scene... it has 16000 available keyframes, it allows nesting, complex control, complex rollover and roll out animations and so on. For your own good, don't ever again use buttons.

    Regarding the problem, since I don't know where you have your function and so on, I'll modify the piece of code you posted, hopefully you'll understand it and achieve what you are trying to do:

    PHP Code:
    function onGD_WB_butClick(evt:MouseEvent):void {
        
    // this will tell your movie to search for a frame label on the root
        // of your animation ; once it found "web solutions" it plays from there
        
    (root as MovieClip).gotoAndPlay("Web Solutions");

    // end of onGD_WB_butClick

    GD_WB_but.addEventListener(MouseEvent.CLICKonGD_WB_butClick); 



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  5. #5
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    Buttons Inside Movie Clips

    I want to thank you for taken the time to help me out with my problem, the code and the solution you provide work 100%. You're awesome.

    Thanks again for all your help it is greatly appreciated.
    Alan

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