Help with FP with animations and movieclip


(fedyfausto) #1

Hello to all :smiley: i have some question for FP, if i have a SWF animation and i wanna play it before launch the level and delete it from memory after finish the animation and continue with game how can i do that?

Other question (more important) if in flash professional i draw some graphic (like box or buttons) in vectorial, how can i use that in my FP PRoject?


(Jacob Albano) #2

Sometimes what I do is create a class called FPGame, which is just a class that extends the Flashpunk Engine class. I can add it to the stage whenever I want to, which allows me to use Flashpunk without making it the document class.

No clue about your second question; I never use Flash Pro so I have no experience with it.


(Zachary Lewis) #3

You can import symbols compiled into an .swf or .swc with FlashDevelop and use them however you’d like with FlashPunk.

To do this, create a Flash Professional movie and create your object. Make sure it exists in your library, and build it.

Assuming the built movie is named myFlashProfessionalMovie.swf and your object is named myMovieClip, you can create instances of your class with the following:

[Embed(source='../myFlashProfessionalMovie.swf', symbol='myMovieClip')]
public class myMovieClip;

...

var clipInstance:MovieClip = new myMovieClip();

(fedyfausto) #4

ooo thx a lot now i dan see my draw :smiley: but how can i use that in an Entity Graphic?


(Zachary Lewis) #5

The easiest way is to draw it onto a new BitmapData, then create a new Graphic using the rendered data.

See Adobe’s reference for BitmapData.draw() for usage. :thumbsup:


(Justin Wolf) #6

In the entity’s render function, you can run:

FP.buffer.draw(myMovieclip, myMatrix);

This is not the most efficient way of rendering MovieClips, however. You could also try blitting the MovieClip. Cache the entire MovieClip and any frames of it into an array of BitmapData then animate through them in the update loop using copyPixels(), which you can read about here: [http://www.adobe.com/devnet/flash/articles/blitting_mc.edu.html][1]. Much more efficient than BitmapData’s draw but a bit more confusing.

Or just use Zach’s suggestion. Likely works faster than drawing directly to FlashPunk’s buffer. [1]: http://www.adobe.com/devnet/flash/articles/blitting_mc.edu.html


(fedyfausto) #7

the problem is… how can i use the VECTOR data of my movieclip (is a single frame with a draw made in FP8), wherever, and if i have a swf (or movie clip into swf) with an animation (for example the intro), how can i add it in a FP stage, play and stop/delet after animation? (or skip with button)


(Justin Wolf) #8
private var myMovieClip:MovieClip = new MovieClip();
FP.stage.addChild(myMovieClip);

Is that what you’re looking for? Of course you’ll have to reference your movieclip somehow within your code, likely through linking a SWC to your project.


(Zachary Lewis) #9

This is correct. You’ve still got all the functionality of Flash available, so you’d probably want to set up an event listener on the newly added move clip to listen for a complete event, then dispose of your splash move and the initialize the FlashPunk engine.