Advertise here: Contact FM.


How to convert shapes drawn with ActionScript to movie clips?
August 19, 2008 6:02 PM   RSS feed for this thread Subscribe

How do I convert a shape drawn with ActionScript to a movie clip that can have mouse actions in Flash (ActionScript 2)?

Maybe I'm missing something really basic here, but a couple hours of research in all the likely places haven't produced anything. Bascially I'm using some functions for creating isometric drawings and I would like to be able to address the shapes they create as objects with onRollOver and onRelease and so on. Any help would be appreciated.
posted by nímwunnan to computers & internet (4 comments total)
Assuming you're using the AS2 drawing api (ie moveTo, lineTo, curveTo), typically this is handled by using those methods on a new dynamically created movieclip. In this case, I'm creating a shape named "shape01_mc".

createEmptyMovieClip("shape01_mc", 1);
shape01_mc.lineStyle(1, 0xcccccc, 100);
shape01_mc.moveTo(0, 0);
// blah blah blah, finish drawing your shape ...

So after drawing the shape in the new movieclip, you can assign your rollover and release functions to that movieclip.

shape01_mc.onRollOver = function(){
//do something
}
shape01_mc.onRollOut = function(){
//do something
}
shape01_mc.onRelease = function(){
//do something
}
posted by joe vrrr at 7:42 PM on August 19, 2008


Actionscript 3.0 makes this very easy. Just make a new class that extends Sprite, rather than Shape, and then you can attach event listeners all day. I'm not sure how to do it in AS2, but joe vrrr seems like he's on the right track.
posted by Alterscape at 12:28 AM on August 20, 2008


Thanks joe vrrr, but I haven't been able to get that method to work because I'm using the isometric transformation functions to create the shapes and breaking them down into their api methods for each object created would be a huge pain. The two approaches I've thought of 1) are either rewriting the functions to include another variable which allows you to insert the movie clip of your choice in the steps that directly reference api methods or 2) rewriting the functions to extend MovieClip as methods so that they can be called in the way you suggest. Any thoughts on those?
posted by nímwunnan at 4:59 AM on August 20, 2008


Ah, I see. I should have looked more closely at the functions themselves.

I think both approaches would work, though I would try option #2 first. I think that's probably easier to implement and reuse.
posted by joe vrrr at 9:41 AM on August 20, 2008


« Older How do I copy browser historie...   |   How do I find the complete lyr... Newer »
This thread is closed to new comments.