Skip to main content
Inspiring
December 12, 2013
Answered

Simple click event

  • December 12, 2013
  • 2 replies
  • 1302 views

I don't know why I can't figure out this problem that is really basics !! (sometimes the brain is tired I guess).

I've got a movieclip with a guitar string. I want the string to move everytime I click on it.

I've created a movie clip with 2 lables. the first = non movement, the second = movement. I've placed in the second one a stop(); action. (in order to stop the loop)

I've put this code :

stringOne.addEventListener(MouseEvent.CLICK, accord1, false, 0, true);

public function accord1(e:MouseEvent):void{

            var stringOne;

            trace("DING");

            stringOne.gotoAndStop("first");

        }

It works but, of course, it only play the string movement at the first click.

Do you know how I could play the string movement EVERYTIME that I click on the string ?

Thank you very much and sorry for this easy question (little ashamed)..,

This topic has been closed for replies.
Correct answer ___x-_V_P_-x___

Nobody know how I could tell the code to automatically go back to label 1 at the end of  the animation of label 2 ?

I've been on it all day and I can't figure it out !


instead of mouse click use mouse down for going to frame 2 and mouse up for going to frame 1

2 replies

Amy Blankenship
Legend
December 12, 2013

something like

if (string1.currentframelabel=='first') {

     //gotoAndStop whatever the other label is

} else {

     //your current goToAndStop logic

}

Inspiring
December 13, 2013

Nope.

The animation of vibration plays only once.. I click again, the string doesnt vibrate... http://ul.to/s7rlld77   (180 ko)

sinious
Legend
December 12, 2013

Are you sure you want gotoAndStop() and not gotoAndPlay()? Are there multiple frames to this?

Aside that are you embedding the audio directly in the frame? If so then if you tell the playhead to go to exactly where it already is, the sound won't be triggered again. You need to leave the frame and return to it to get the sound to play. If you already know you're not on frame 1 (I assume the 'not playing' frame) then you're on the 'playing' frame and if clicked it should move back to the beginning and then return to the 'play' frame. So just:

stringOne.gotoAndStop(1); // get off the embedded audio frame

strongOne.gotoAndStop('first'); // go back to it to trigger the audio

Or you can just control the audio with code..

Inspiring
December 13, 2013

I've got no audio yet in the frames. Juste images (animation).