SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: AS3 and buttons

  1. #1
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    AS3 and buttons

    Hi,

    Im trying to add a next button on every frame of my timeline. I have setup the first button no problems with:

    Code Actionscript:
    next_button.addEventListener(MouseEvent.CLICK, clickFunctionNext);
     
    function clickFunction(evt:MouseEvent):void {
    gotoAndPlay.nextFrame();
    }

    but then if i want to add another next button on the next frame with the same function i.e. gotoAndPlay.nextframe() i get a duplicate function defenition error.

    There must be some way of setting a repeated button up like this without having to give each one an individual instance name and function?

    Thanks

  2. #2
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need the code, or the button, on every frame.

    For the button, make sure there isn't a keyframe in the time line so that the same instance of the button stretches across multiple frames.

    For the AS, make sure it's on the first frame where the button occurs, and that's all you need. As long as the button stays on the stage, you don't need the code on every frame the button is on.

  3. #3
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ah yes, thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •