• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

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.
0
mliittsc
Asked:
mliittsc
  • 3
  • 2
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now