creating multiple MovieClips programmatically in Flash 3

How do I create multiple movieClips at runtime? I need to take several TextField children of a single movieclip and make them the children of individual movieclips which will then be dragged and dropped.
mliittscAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CyanBlueCommented:
What do you mean by Flash 3???  What version of ActionScript do you use???

CyanBlue
0
mliittscAuthor Commented:
I meant ActionScript 3,
0
CyanBlueCommented:
Here is the simplest version I can think of...  See if you can adapt this to yours...

CyanBlue
var max:int = 5;

for (var i:int = 0 ; i < max ; i++)
{
	var mc:Sprite = new Sprite();
	mc.graphics.beginFill(0x000000, 0.1);
	mc.graphics.drawRect(0, 0, 200, 20);
	mc.graphics.endFill();
	mc.x = 0;
	mc.y = i * 25;
	mc.buttonMode = true;
	mc.mouseChildren = false;
	mc.useHandCursor = true;
	
	var txt:TextField = new TextField();
	txt.text = "Hello" + i;
	txt.selectable = false;
	
	addChild(mc);
	mc.addChild(txt);
	
	mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouse_Down);
	mc.addEventListener(MouseEvent.MOUSE_UP, onMouse_Up);
}

function onMouse_Down(e:MouseEvent):void
{
	e.currentTarget.startDrag();
}

function onMouse_Up(e:MouseEvent):void
{
	e.currentTarget.stopDrag();
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mliittscAuthor Commented:
did not include necessary imports
0
CyanBlueCommented:
That code works as is inside the Flash IDE...  You don't need to do any of those import...

CyanBlue
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.