views:

1273

answers:

3

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?

A: 

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.

grapefrukt
I have added more details.
muhuk
+2  A: 

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;
       }
    }
}
Iain
Thanks! Can I add the same asset with different transformations (different frames of course)?
muhuk
yes - make sure you understand the difference between an asset in your "library" and an instance on the stage though
Iain
A: 

Hello-

I created a movie clip called splash_mc that I only want to be viewed on the "splash page". However, when I link my splash_mc to the main timeline, or any other movie clip, it (of course) spreads it across all my frames. Basically, I just want the animation to appear under the designated label "splash" so that when I click the links going to my other pages in my main navigation the animation disappears. I tried using 'this.removeChild' by placing my animation in with my navigation movieClip and it worked. But only when i first use the nav in on my splash page; when I try clicking the links from my internal pages I get an error, since the eventListener was still running the function but of course there's no longer a the splash_mc to get rid of.

What can I do? I saw here where I could just load my splash_mc to one frame, so when my links are clicked, theoretically, the playhead moves off that frame and my animation is no longer viewable. Is this a better option?

Thank you.

Start your own question.
Mk12