A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Creating multiple, adjustable, instances of a Movie Clip?

  1. #1
    Join Date
    Aug 2006

    Smile Creating multiple, adjustable, instances of a Movie Clip?

    I've done some basic flash for my college course and i'm moving onto advanced flash and Actionscript. For this, i'm trying to build a "construction game".

    What I have is objects on the right side, and I want to be able to drag out copies of those objects onto the left and have the size and rotation of each object adjustable...

    So say click and drag on a circle, it puts a copy of the circle where I place it on the left. I can then drag that circle around, scale it or rotate it, or if I decide I don't want it at all, drag it onto a recycle bin icon and have it removed.

    I'd like to be able to make as many copies of that circle as allowed (so maybe a limit of 10?), and have each one adjustable when you "select" it...

    Hope this all makes sense. Thanks in advance for any help.

  2. #2
    Senior Member
    Join Date
    Jul 2008
    You'll pretty much have to create the transform tool from Flash. I'm not sure if you're familiar with classes but this is what I would do. This is just for the adjustable part of your problem.

    I would create a super class that every object that can be dragged, scaled, and rotated would subclass, I'll call it BaseObject. BaseObject would have a MovieClip that looks like a rectangle and it would have 8 points on it. Those points are also MovieClips and are placed in the fashion of the transform tool. But for me I'm just gonna do 4 points arranged so that

    1 is at top left - rotation
    1 is at top - scaleY
    1 is at top right - scaleX and scaleY
    1 is at right - scaleX

    There will be a string variable called adjust or something declared in the beginning. Each point will be assigned a mouse down listener. When the listener triggers adjust will be changed depending on what point triggered the listener so the variable would have values like "rotate", "scalex", "scaley", "scalexy". Also when the listener triggers a mouse move and mouse up listener will be added to the stage.

    In the mouse move listener, depending on what the adjust variable is, that's how the object will be transformed. You just need to have 4 different conditional statements.

    In the mouse up listener, when it triggers it will remove the mouse move listener from the stage.

    So this is how I would do this. If you are not familiar with classes and prefer timeline coding the design is essentially the same. I even wrote up some code but I chose not to post it cause it would make my post rather huge. But I'll post it if you really really need to see it.

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center