How do I give a function to only the second frame of a movie-clip? (AS3)

I want to create a function that only allows the second frame of a movie clip to allow navigation of SWF. The "2button" is the original movie-clip while the "unlock2" is a different movie-clip on the second frame of "2button"

I tried:

//test
    public function open(){
        2button.unlock2.addEventListener(MouseEvent.CLICK,clickjump2);
        function clickjump2(event:MouseEvent) {
            gotoAndStop("play2");
        }
    }

Any suggestions or improvements to this would be greatly appreciated :D!

Answers


try this:

function open():void
{
    2button.unlock2.addEventListener(MouseEvent.CLICK,clickjump2);
}

function clickjump2(event:MouseEvent):void
{
    //check if 2button is at frame 2
    if (2button.currentframe==2)
    {
        gotoAndStop("play2");
    }
}

ps: as Versper pointed out, dont start names with numbers


Need Your Help

Building a more realistic random word generator?

php random word generator markov

I'm seen many examples of using Markov chains for generating random words based on source data, but they often seem a bit overly mechanical and abstract to me. I'm trying to develop a better one.

What is the purpose of _IOR_BAD and _IOW_BAD?

linux-device-driver kernel-module ioctl

The kernel header file with the definitions for defining ioctl functions, /usr/include/asm-generic/ioctl.h, has the usual and commonly applied macros _IO, _IOR, _IOW, and _IOWR. Right beside those,