0
votes

I have a .swf file that I'm trying to use in my program. I don't want it to loop, just to stop on the first frame and only change frames when I tell it to. This works when I put the .swf file on the stage and tell that specific instance to stop(). But I need it to be a Movie Clip that's linked to an AS3 file. When I do that, stop() doesn't work anymore and it just keeps looping.

        mybrick = new Brick(0, 0);
        addChild( mybrick );
        mybrick.stop();

It doesn't give me any errors or anything, but it just keeps looping instead of stopping. For some reason when I go to "Convert to Symbol" and "Export for ActionScript" (which is how I made all my other objects follow their code) the stop() function no longer works. What am I doing wrong?

Edit: Ok, here's the main file (I cut out the parts related to other objects because they're not affecting Brick and otherwise this would be pretty long)

package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.display.Stage;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.utils.Timer;
import flash.events.TimerEvent;


public class RetrievoidGame extends MovieClip
{


    public var mybrick:Brick;

    public function RetrievoidGame()
    {


        mybrick = new Brick(0, 0);
        addChild( mybrick );
        mybrick.stop();



        stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);

        var newTimer = new Timer( 1 );
        newTimer.addEventListener( TimerEvent.TIMER, everyFrame );
        newTimer.start();

    }

And here's the Brick.as file: package { import flash.display.MovieClip;

    public class Brick extends MovieClip
    {


        public function Brick(myX, myY) {

            x = myX;
            y = myY;


        }



    }
}
2
Is the class file continuously controlling the asset using gotoAndPlay? If that is the case, calling stop() isn't going to work.Bennett Yeates
I don't have gotoAndPlay in my code. I've tried calling stop() from the parent as you see above, and I've also tried putting stop() in Brick's constructor. I've also tried gotoAndStop(1) and that doesn't work either.user3384588
Does the brick movieclip have code in its timeline? Check that for errors.Bennett Yeates
No, I was told that it was bad to put code in the timeline. All my code is in .as files. It's not giving me any error message, it's simply looping when I tell it to stop()user3384588
Ok if there isn't any code in your timeline (please note that if there is any code anywhere in the timeline that has compiled with errors, your animations could all be on a continuous loop) then you will have to post more code so we can see where it may be coming from. Currently this won't be enough to go off of.Bennett Yeates

2 Answers

0
votes

Put stop(); in the first frame of the MovieClip's timeline. Use gotoAndPlay() from the parent when you want the MovieClip to move.

0
votes

You can't stop Brick, because loop animation for him that you made, in another inner MovieClip? If you have inner MovieClips, you also should stop them. Give them some name on the timeline, like: myAnimation and stop them. myBrick.myAnimation.stop()

If it hard to you, use this code snippet, it will stop your Brick for sure, add these methods to the Class Brick:

override public function stop():void {
    super.stop();
    stopMovies(this);
}

private function stopMovies(movie:MovieClip):void{
    var i: uint, len:uint = movie.numChildren, child:MovieClip;
    for(i; i < len; ++i){
        child = movie.getChildAt(i) as MovieClip;
        if(child != null){
            child.stop();
            stopMovies(child);
        }
    }
}