Copy link to clipboard
Copied
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)..,
instead of mouse click use mouse down for going to frame 2 and mouse up for going to frame 1
Copy link to clipboard
Copied
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..
Copy link to clipboard
Copied
I've got no audio yet in the frames. Juste images (animation).
Copy link to clipboard
Copied
something like
if (string1.currentframelabel=='first') {
//gotoAndStop whatever the other label is
} else {
//your current goToAndStop logic
}
Copy link to clipboard
Copied
Nope.
The animation of vibration plays only once.. I click again, the string doesnt vibrate... http://ul.to/s7rlld77 (180 ko)
Copy link to clipboard
Copied
Ah ! It seems to work with goToAndPlay !
Just a thing, I have to click twice..
(one click = the string vibrate (frame2))
(one click again = the string does nothing (going to frame 1))
(one click again = the string vibrate (frame2))
Is there anyway to automatically skip the 2nd click (the one that tells the string to go back at frame1), and let do the code like :
- When animation of frame 2 is finished, automatically go back to frame 1
?
Copy link to clipboard
Copied
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 !
Copy link to clipboard
Copied
instead of mouse click use mouse down for going to frame 2 and mouse up for going to frame 1
Copy link to clipboard
Copied
Of course !! Better idea ! THANK YOU VERY MUCH !