PDA

View Full Version : Action Script wont obey the stop command



Heroes for sale
January 27th, 2010, 07:31 PM
Hellow.. I am an absolute beginner and downloaded this file from a great member here. I tried to use the stop(); command but it keeps going in a loop.


Any help?

I've attached the file here

Krilnon
January 27th, 2010, 08:33 PM
If you insert this code at the bottom of the extant code in that file's main timeline, then it'll stop after 3 seconds:
setTimeout(killall, 3000);

function killall():void {
var i:int = numChildren;
while(i--){
getChildAt(i).removeEventListener(Event.ENTER_FRAM E, efekt);
}
}

If that's not what you're after… say so. The reason that you can't use stop is that it's a scripted animation and not one that's driven by the timeline which stop (MovieClip#stop) controls.

Heroes for sale
January 27th, 2010, 08:42 PM
Uha, I almost understand what you said. If its scripted then simple commands dont stop it. I get it.

The code you just put there would stop it after 3 seconds, if I modify the 3000 (assuming it translates to 3 seconds) would it work?

I want to use the vibration in another animation I made and because I cant control it, it continues to play in different scenes and is confusing. Are there other ways of controling? thats my question I guess..


But thanks so much for your help, I have a project due in 9 hours and your help is very appreciated.

Heroes for sale
January 27th, 2010, 08:47 PM
Another question, sorry to bother you guys but I honestly dont know who else to ask. I've been searching google all day today.

I have two buttons in my fla file, they lead to different parts of the animation, different frames. I used this code to direct the clicks to specific frames:

stop();

button.addEventListener(MouseEvent.CLICK, release);
//the name of the function has to match what you're calling from the event listener
function release(evt:MouseEvent):void {
gotoAndPlay(312);
}


The first one works no problems, but the second one returns an error. Something about definition of a function. Is there any other way to do what I want to do?