Question

Let's say I have a resource file which exports mc1 with 4 frames in it. I would like to create a new MovieClip and insert frames like this:

mc2:flash.display.MovieClip = new flash.display.MovieClip()

mc1.gotoAndStop(2);
mc2.gotoAndStop(1);
mc2.currentFrame = mc1.currenctFrame
mc1.gotoAndStop(1);
mc2.gotoAndStop(2);
mc2.currentFrame = mc1.currenctFrame
mc1.gotoAndStop(2);
mc2.gotoAndStop(3);
mc2.currentFrame = mc1.currenctFrame
mc1.gotoAndStop(4);
mc2.gotoAndStop(4);
mc2.currentFrame = mc1.currenctFrame

[edit] More details

I am not using Flash IDE. I am using:

  • Inkscape (for SVG generation)
  • swfmill (to create asset files)
  • Haxe (to create animations)

I am not at this point trying to build games or anything interactive. I have managed to create a simple animation where a background sprite is spinning (and that's it). I used TimerEvents to achieve this. But instead I would really like to be able to construct a MovieClip and attach individual frames on it and then play it on loop.

Alternatively I can create a MovieClip and just draw on it frame by frame programmatically. (and then of course play in loop)

Basically I would like to use ActionScript to generate content instead of swfmill's XML (not the simple dialect, simple is fine). Since I am a beginner I don't know what other information I can give you. So please tell me if I can supply any other details?

Was it helpful?

Solution

Without the Flash IDE, there is little point in using gotoAndStop() etc.

As you can't add your different assets on different frames, you should add them all as layers using addChild(assetToAdd) and set all but one to visible = false. Then add a simple function like this:

function showFrame(num:int):void
{
    for (var i:int = 0; i < numChildren; i++)
    {
       if (i == num)
       {
          getChildAt(i).visible = true;
       }
       else
       {
          getChildAt(i).visible = false;
       }
    }
}

OTHER TIPS

I'm not aware of a convenient way to do what you're trying to do. Your example won't work because currentFrame is a read-only property, also all it returns is an integer representing the frame number, not the data making up the actual frame.

My suggestion, if you need to dynamically rearrange the frames, would be to wrap that particular MovieClip in a custom class that translates the gotoAndPlay(x) to whatever number you would want.

However, this might not be very useful depending on what you're trying to achieve, but if you clarify your question a bit I'm sure we can come up with a proper suggestion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top