Nebula
Nebula

Reputation: 691

AS3 flashing dynamically appending movieclip names to goto functions

I have a virtual on screen keyboard for a touch screen interface. I get the name of the key (Q, W, E, etc) by calling event.currentTarget.name Now each button is a movie clip with a small animation and I need to know which key is pressed so it can call the relevent movieclip.. Below is the code:

function keyPressed(event:MouseEvent):void {

    var butID:String = event.currentTarget.name;
    trace("clicked " + butID);

 //////////////ERROR BELOW///////////

    Q.gotoAndPlay(2); <-------- Q is the name of the movieclip. It has to be something like butID.gotoAndPlay(2); but it doesn't work. I'm not sure of the type of the variable either...Can any one help?

/////////////////////////////
//Below I append the letter to a text box
    if(event.currentTarget.name == "SPACE")
    {
        addText(" ");
    }
    else
    {
        addText(event.currentTarget.name);
    }
}

Thanks in advance, Luben

Upvotes: 0

Views: 303

Answers (1)

George Profenza
George Profenza

Reputation: 51837

Have you tried event.currentTarget.gotoAndPlay(2); ?

Upvotes: 2

Related Questions