Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Dynamically Created Text Field Inside Of Empty Movieclip



Hi there.My goal is to have a button that, when clicked, an empty movieclip is created and a text field is attached to it.I could write it easily if the newly created instance names where hard coded, the problem comes with the syntax to generate them dynamically.Here's the code i have so far:ActionScript Code:button.onRelease = function() { createText(); } var count:Number = 1; createText = function () { _root.createEmptyMovieClip("placeholder"+count,this.getNextHighestDepth()); this["placeholder"+count].createTextField("my_txt"+count, this.getNextHighestDepth(), 100, 100, 100, 100); count++;}After that's done i still need to assign a text value to the text field, which i have no clue on how to do it...In other words I want to accomplish something like:placeholder[count].my_txt[count].text = "my text";I hope it's not confusing... Any help would be greatly appreciated.Thanks in advance!



Adobe > ActionScript 1 and 2
Posted on: 07/09/2008 11:50:25 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

How To Load Image Into Movieclip Inside Movieclip That Is Dynamically Created?
Hello Kirupa Cats!

I am building a menu from an XML file, and I'm cool with cyclying thru the xml data to create menu items.

For every menu item in my XML file, I'm using attachMovie to insert a movie clip called menuitem from my library into a movieclip called menuholder. This works no problem, my menuholder movieclip is poplulated with as many menuitem movieclips from the library as designated by the xml data.

However, inside the library movieclip called menuitem, I have another movieclip on its stage, called mc_menuImage. I want to load an image into that movieclip, and I'm taking the URL for the image from the XML data.

My problem is I can't seem to figure out how to fully identify the movieclip mc_menuImage to load the image. It may have something to do with the fact that the library movieclip is being loaded dynamically, but the movieclip inside the library movieclip exisits pysically on the stage. I don't know...here's the code I'm working with:

THE CODE:

var xmlMenu:String = "menu.xml";
menuholder = createEmptyMovieClip("menuholder", -1);

var xmlMenuData:XML = new XML();
xmlMenuData.ignoreWhite = true;
xmlMenuData.load( xmlMenu );
xmlMenuData.onLoad = function(loaded) {
if (loaded) {
var mImage:Array = new Array();
var mRootNode = this.firstChild.childNodes;
totalMenuItems = mRootNode.length;

// fill array
for (var i = 0; i<totalMenuItems; i++) {
mImage.push(mRootNode[i].attributes.menuImage);
}
}

//make the menu
for (var i = 0; i<totalMenuItems; i++) {
var menuitem = menuholder.attachMovie("menuitem", "menu"+i, i);
menuitem.id = i;

/* now here I thought I could just do this: */
menuitem.mc_menuImage.loadMovie(mImage[i]);
/* but that doesn't work... */

};


When I trace menuitem I get this: _level0.menuholder.menu0, _level0.menuholder.menu1, etc, so I figured the syntax menuitem.mc_menuImage would identify the movieclip inside menuitem, but to no avail. Maybe it has something to do with levels, I'm not sure...

So I don't know, any suggestions? Thanks so much!!!

Duplicate A MovieClip Containing Dynamically Created Field
is there a way to duplicate a movie clip with everything that it contains?

I created a MC dynamicallly and I created dynamically a text in it:

createEmptyMovieClip("clip1", 3);
clip1.createTextField("TF", 0, 0, 0, 10, 10);
clip1.TF.borderColor = 0xFFFFFF;
clip1.TF.border = 1;
duplicateMovieClip(clip1, "clip2", 4);
clip2._y = 10;

The textField doesn't exist in the clip2. why?

It does works when you just create shapes in it

createEmptyMovieClip("clip1", 0);
clip1.lineStyle(1, 0x4E0053, 100);
clip1.lineTo(10, 10);
duplicateMovieClip(clip1, "clip2", 1);
clip2._y = 10;

How Would I Create A Variable Inside A Dynamically Created Movieclip?
? i created the movie clip all good and everything... but i need to create 2 variables in each one. anyone?

Centering Content Inside A Dynamically Created Movieclip
Like the title says, I'm having trouble to center any dynamic content (movieclips, textfields...) inside a dynamically created movieclip, which has a default point of interested in the top left corner.
Do you have any solutions?

Thanks

PS: Just as an example, I have a dynamically created text field inside a dynamically created movieclip....and when I try to scale that movieclip I need to scale it from its center

Access To Dynamically Created Text Field
How can I code a onRollover for a textfield that has been generated with createTextField function. Can anyone help? TIA

Problems With Dynamically Created Text Field
Hi

I’m dynamically creating a text field using “createTextField” as part of a larger method that runs through a line of text & animates it by setting each letter to uppercase every 100th of a second.

The problem that I have is that the dynamic filed I’m creating for some reason creates a second line of identical text which it tags onto the first so say the text to be displayed was just “Eat a grape” I’m getting
“Eat a grapeEat a grape”

A link to an online version of the site is HERE & the complete code is set out below:


Code:
TextField.prototype.caseAni= function(msg){
var tf=this;
tf.uppperIndex=0;
tf.msg=msg;
var id=setInterval(moveUppercaseLetter,100);
function moveUppercaseLetter(){
var part1=tf.msg.slice(0,tf.upperIndex);
var part2=tf.msg.charAt(tf.upperIndex);
var part2=part2.toUpperCase();
var part3=tf.msg.slice(tf.upperIndex+1,tf.msg.length);
tf.msg=part1+part2+part3;

tf.text=tf.msg;

tf.msg=tf.msg.toLowerCase();

tf.upperIndex++;

if(tf.upperIndex> (tf.msg.length-1)){
tf.upperIndex=0;
}
}
}
this.createTextField("msgOutput_txt",1,0,0,300,30);
msgOutput_txt.setNewTextFormat(new TextFormat("_typewriter",16));
msgOutput_txt.caseAni("This is just a simple test");


Sorry to cross post on this but the posting I made in the more advanced forum has died without a reply.

Resizing Dynamically Created Text Field
I've only got 360 pixels in width to work with. My dynamically entered text may be longer than that and I want to resize it, in essence "squishing" it to fit the area. I've tried putting the created text field in a movie clip and resizing it to no avail. Here is the code I am using.

headfmt = new TextFormat();
headfmt.color = 0xFFFFFF;
headfmt.font = "Arial Black";
headfmt.bold = true;
headfmt.size = 14;
headline.createTextField("headtext", 10, 0, 0, 30, 24);
headline.headtext.type = "dynamic";
headline.headtext.autoSize = "left";
headline.headtext.text = "HEADLINE ONE GOES HERE WITH EIGHT TO TEN WORDS IN IT";
headline.headtext.setTextFormat(headfmt);

"HEADLINE ONE GOES HERE WITH EIGHT TO TEN WORDS IN IT" is much longer than 360 pixels (approx. 540 px). How can I squish it down to fit the 360 px. area at runtime? Is there a way to convert text to shapes at runtime?

Problems With Dynamically Created Text Field
Morning all,



I’m dynamically creating a text field using “createTextField” as part of a larger method that runs through a line of text & animates it by setting each letter to uppercase every 100th of a second.



The problem that I have is that the dynamic filed I’m creating for some reason creates a second line of identical text which it tags onto the first so say the text to be displayed was just “Eat a grape” I’m getting

“Eat a grapeEat a grape”



A link to an online version of the site is HERE & the complete code is set out below:




Code:
TextField.prototype.caseAni= function(msg){

var tf=this;

tf.uppperIndex=0;

tf.msg=msg;

var id=setInterval(moveUppercaseLetter,100);

function moveUppercaseLetter(){

var part1=tf.msg.slice(0,tf.upperIndex);

var part2=tf.msg.charAt(tf.upperIndex);

var part2=part2.toUpperCase();

var part3=tf.msg.slice(tf.upperIndex+1,tf.msg.length);

tf.msg=part1+part2+part3;



tf.text=tf.msg;



tf.msg=tf.msg.toLowerCase();



tf.upperIndex++;



if(tf.upperIndex> (tf.msg.length-1)){

tf.upperIndex=0;

}

}

}

this.createTextField("msgOutput_txt",1,0,0,300,30);

msgOutput_txt.setNewTextFormat(new TextFormat("_typewriter",16));

msgOutput_txt.caseAni("This is just a simple test");

Hscroll A Dynamically Created Text Field
I'm trying to dynamically create an empty text field with as at 560px wide, fill it with a bunch of text (one line) and continuously scroll it from left to right using hscroll and setInterval.

I've read all kinds of specs about createTextField and hscroll but I can't get it to work. I ouputted the mytext.hscroll value and it's always at 0;

Maybe there is a better way than I have been trying or maybe I'm too fried out from looking at it... Any help would be huge - thanks.


Code:

_root.createTextField("mytext",10,150,281,560,10);
mytext.multiline = false;
mytext.wordWrap = true;
mytext.border = false;
mytext.htmlText = true;
mytext.html = true;
mytext.background = false;

myformat = new TextFormat();
myformat.color = 0x00A0C6;
myformat.font = "Sevenet 7";
myformat.size = 8;

uString = "Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. Here is a bunch of text. ";

mytext.text = uString.toUpperCase();

mytext.setTextFormat(myformat);

//functions

function startMove() {
setInterval( moveText, 500 );
}

function moveText() {
mytext.hscroll += 1;
}

startMove();

Problems With Dynamically Created Text Field
Hi

I’m dynamically creating a text field using “createTextField” as part of a larger method that runs through a line of text & animates it by setting each letter to uppercase every 100th of a second.

The problem that I have is that the dynamic filed I’m creating for some reason creates a second line of identical text which it tags onto the first so say the text to be displayed was just “Eat a grape” I’m getting
“Eat a grapeEat a grape”

A link to an online version of the site is HERE & the complete code is set out below:


ActionScript Code:
TextField.prototype.caseAni= function(msg){
    var tf=this;
    tf.uppperIndex=0;
    tf.msg=msg;
    var id=setInterval(moveUppercaseLetter,100);
function moveUppercaseLetter(){
    var part1=tf.msg.slice(0,tf.upperIndex);
    var part2=tf.msg.charAt(tf.upperIndex);
    var part2=part2.toUpperCase();
    var part3=tf.msg.slice(tf.upperIndex+1,tf.msg.length);
    tf.msg=part1+part2+part3;
   
    tf.text=tf.msg;
   
    tf.msg=tf.msg.toLowerCase();
   
    tf.upperIndex++;
   
    if(tf.upperIndex> (tf.msg.length-1)){
    tf.upperIndex=0;
}
}
}
this.createTextField("msgOutput_txt",1,0,0,300,30);
msgOutput_txt.setNewTextFormat(new TextFormat("_typewriter",16));
msgOutput_txt.caseAni("This is just a simple test");

Dynamically Created Text Field Doesn't Appear When Imported
Greetings,

I have 2 issues regarding dynamically created text fields. What I'm trying to do is to create a text field inside a swf file, then import that swf into another file. The main problem is, the text field is created and displayed perfectly when i execute the first swf, but when i try to import the whole thing into another file, the text is not displayed.

I have to point out that, when I add "stage" before the addChildAt command, the text appears, but I don't want the coordinates of the text box depending on it's location on the stage.

The second problem is, I want the scroll buttons to appear if the text is longer than the text box, however they appear no matter what. I trace the values and they are correct, so I can't really understand why they keep appearing.

Thank you very much for your help.







Attach Code

var external_txt:TextField = new TextField();
var externalReq:URLRequest = new URLRequest("03ekranlar.txt");
var externalLoad:URLLoader = new URLLoader();

externalLoad.load(externalReq);

externalLoad.addEventListener(Event.COMPLETE, textReady);

external_txt.x = 303;
external_txt.y = 14;
external_txt.border = true;
external_txt.height = 365.5;
external_txt.width = 200;
external_txt.wordWrap = true;

var myFormat:TextFormat = new TextFormat();
myFormat.font = "Verdana";
myFormat.size = 10;
myFormat.leading = 2;

addChildAt(external_txt, numChildren);
external_txt.setTextFormat(myFormat);

function textReady(event:Event):void
{
external_txt.text = event.target.data;
external_txt.setTextFormat(myFormat);

// this bit works even if the criteria is not satisfied

if(external_txt.textHeight > external_txt.height);
{
var up_btn:up = new up();
addChild(up_btn);
up_btn.x = 515.8;
up_btn.y = 15.8;
up_btn.addEventListener(MouseEvent.ROLL_OVER, scrollUp);

var down_btn:down = new down();
addChild(down_btn);
down_btn.x = 515.8;
down_btn.y = 379.1;
down_btn.addEventListener(MouseEvent.CLICK, scrollDown);

function scrollUp(event:MouseEvent):void
{
external_txt.scrollV --;
}

function scrollDown(event:MouseEvent):void
{
external_txt.scrollV ++;
}
}
}

Getting A “Dynamically Created” Text Field To Change _alpha At Run Time
Here’s the problem.

I have a script that dynamically creates a text field at run time & I would like to get it’s _alpha to decrease on say a standard keyframe script.

From searching the forums the only way I have seen that comes close to achieving this is to use the “Embed Font” option which as far as I know can only be achieved at authoring time & not done dynamically.

Anyone any ideas please?

I have seen mention to a tut that may solve the problem in one of the posts but can find no reference to it when searching

[F8] Dynamically Created Input Text Field With Embedded Font
I'm creating a high score table for my game and I'm trying to mimic those arcade style high score tables with the scores on the right and the three letter names on the left. Everything works fine except for the line where you input your three letter acronym. If I try and get it to use the embedded font it wont work. If I comment out those lines it does work. If I don't comment them out you can't type into the text field, the I beam cursor shows but you can't type. I know the font is embedded properly because all of the dynamic text boxes are using it just fine.

In addition to this I was wondering if it was possible to replace the standard vertical bar text cursor with a horizontal bar kind of like would you would see at a dos prompt.

Here's my code:

code:
mc_HS.createTextField("name"+i,_root.mc_HS.getNext HighestDepth(), 153, 50+count, 50, 20);
mc_HS["name"+i].type = "input";
mc_HS["name"+i].maxChars = 3;
//mc_HS["name"+i].setTextFormat(lvltxtformat);
//mc_HS["name"+i].embedFonts = true;


It works with those two lines commented but doesn't if I uncomment them.

Resize Text In Dynamically Created Text Field
Anyone, everyone!!

using the Menu_tabs.fla template (New From Template->Menus->Menu_tabs) that comes with Flash MX to create a Menu- I want to resize the text in the subnavigation so that it is smaller than the main text, can't seem to get it to work.

The problem is that it is creating a new textfield from an existing textfield instance, and it is sharing the attributes of the original.
I've located the subnav textfield script- it looks like this...
// set the width and height of the text fields and button.
fieldObj = curSub.fieldText;
fieldObj._width = 1000;
fieldObj.autoSize = true;
fieldObj.textHeight = 200; (!!!!I've added this!!!)

// here we set the option text, colors to be used on rollover, etc.
curSub.onColor = data.menu.sub_onColor;
curSub.offColor = data.menu.sub_offColor;
curSub.optionText = text;
curSub.fieldTextVar = "<FONT color=""+data.menu.sub_offColor+"" >"+text+"</FONT>";

I've added the "fieldObj.textHeight = 200;" line (200 just to see if it makes a difference)

Why isn't this working???

Dynamically Created Radio Buttons And Text Inside Input Boxes
I have been working on some code that will create input boxes dynamically set up to look like table. The code looks like this:


Code:
//attach header movieclip for NA
naHolder_mc.attachMovie("naHeader", "naHeads",getNextHighestDepth(), {_x:95, _y:8.4});
//code to create multi array through for loop
var row:Number = 15;
var col:Number = 15;
var depth:Number = 0;
var rowArr:Array = new Array(row);
var i:Number;
var j:Number;
for (i=0; i<row; i++) {
rowArr[i] = new Array(col);
for (j=0; j<col; j++) {
rowArr[i][j] = "["+i+"]["+j+"]";
}
//trace(rowArr[i]);
}
//code to iterate through multi array elements
var outerArrayLength:Number = rowArr.length;
for (i=0; i<outerArrayLength; i++) {
var innerArrayLength:Number = rowArr[i].length;
for (j=0; j<innerArrayLength; j++) {
var tableFormat:TextFormat = new TextFormat();
tableFormat.font = "Arial";
tableFormat.bold = true;
tableFormat.size = 11;
tableFormat.align = "center";
_root.createTextField("NAr"+i+"_c"+j, depth,95+(33.5*j), 30+(i*20.7), 28.1, 16.2);
var _box:TextField = _root["NAr"+i+"_c"+j];
_box.type = "input";
_box.selectable = true;
_box.restrict = "DdEeNnXx";
_box.border = true;
_box.multiline = false;
_box.maxChars = 1;
_box.textColor = 0xff0000;
_box.setNewTextFormat(tableFormat);
depth++;
trace(_box);
//trace(rowArr.length);
}
For a couple of days now I have been trying to create radio buttons along with the input boxes that will sit on the left side of the text boxes 3 on each row that have the labels D, E, and N. So far I have come up with nothing. I also need to have the row headers placed in the first column of the input boxes saying NA 1, NA2, NA 3, inside the input box. Does anyone have an idea on how to do this or where I should start?

I have been able to create radio buttons by using the import mx.control.radiobutton code and then createClassObjects class but don't know what type of loop to use to align the 3 radio button on the yaxis of each of the rows.

Duplicate A Movieclip That Has A Text Field Inside
hey there

i have a movie clip with a text field in it (as a child in it)

when i duplicate the movie clip using a loop I output the loop variable in the text (1,2,3.........)

but half way duplicating i need 2 rotate my movieclip 90 degrees & here goes the problem :

my text field 4 some reason stops appearing

when i removed the line that rotates the movieclip it worked in alla duplicates.

what can i do ???

PS: a thought came 2 me right now: maybe i should mk the duplicates 1st then rotate the ones i wanna rotate.

I'll try it & C what happens

thx 4 ur help & 4 my thought
bye

Dynamically Center Text Field In A Movieclip
I have a project where I need to populate 60 button movieclips with text. I created the movieclip buttons with 2 layers -- a background and a pre-sized dynamic text box with fonts embedded.

Unfortunately, this makes the text align to the top of the background when the movieclip button is assigned a text value 1 line long. 2 lines work ago and are aligned reasonable well over the background.

What is the best method for creating a dynamic text-based movieclip button where the dynamic text is automatically vertically/horizontally aligned inside the movieclip button?

For reference, I'm putting the text values into each movieclip button as follows:


Code:
for (i=0; i<criticName.length; i++) {
this["bfShouldClip_"+i].shouldTextNew.text = bfShould[i].firstChild.nodeValue;
}
The text values for the buttons, by the way, are powered by XML data.

I tried placing a dynamic text box inside the movieclip button (over the background) and not sizing it to fit. Then I did the following variation on the code:


Code:
for (i=0; i<criticName.length; i++) {
this["bfShouldClip_"+i].shouldTextNew.text = bfShould[i].firstChild.nodeValue;
this["bfShouldClip_"+i].shouldTextNew.autoSize = "true";
this["bfShouldClip_"+i].shouldTextNew._y = (this["bfShouldClip_"+i]._height - this["bfShouldClip_"+i].shouldTextNew._height)/2;
this["bfShouldClip_"+i].shouldTextNew._x = (this["bfShouldClip_"+i]._width - this["bfShouldClip_"+i].shouldTextNew._width)/2;
}
Sorry for the wildness of the code. In any event, this didn't work. I wasn't sure if putting the dynamic text field inside its own movieclip inside the button movieclip would help. I'm not even sure if I'm on the right track here.

Any help is greatly appreciated. Otherwise, I'll have to leave these movieclip buttons with top aligned text.

IronChefMorimoto

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

Calling Dynamic Text Field On Main Timeline From Inside Movieclip
Hi, this is probably really easy, but I can't seem to figure out how to do it.

I made a little login screen in a separate movieclip on my homepage. When the login is correct, frame 8 of the main timeline is called, and I would like it to say "welcome (name here)." Unfortunately, I don't know how to call the dynamic text field on Frame 8 (instance name "greetings", variable saved as "welcome") from inside the movieclip on Frame 2.

Here's the code from the login button in the movieclip:

on (release, keyPress "<Enter>") {
if (user eq "name" and password eq "password") {
_root.gotoAndStop(8);
//trying to access dynamic text field on frame 8 of main timeline, but nothing works!
_root.greetings.welcome = "Welcome, "+ user;
_root.welcome = "Welcome, " + user;
welcome = "Welcome, " + user;

I just don't know! By the way, this is in Flash MX

How To Hide My Current Movieclip And Display 2nd Dynamically Created Movieclip?
I have a movieclip in which there is an image create this movieclip dynamically by reading the oath of the image from file and play an effect. its working fine, now i want to hide this MC after its effect is ended and then dynamically want to create the other MC and similarly so on. how to do that. my code is as below:

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

lv.load("data.txt");
var my_lv:LoadVars = new LoadVars();
my_lv.load("data.txt");
my_lv.onLoad = function(success)
{
if (success)
{
if(this.pic1!=undefined)
{
var ImgMc:MovieClip = createEmptyMovieClip("ImgMc", getNextHighestDepth());
_root.mcLoader.loadClip(this.pic1,_root.ImgMc);
//Some effect on ImgMc

//how to hide the ImgMc whe nits effect is played and then load another image in a movieclip and so on
}
}
}

Help - Placing A Dynamically Created Clip Inside Another...
Hey all,

I have a situation and can't figure out how it's solved. The short of it is that I have a dynamically created mc that needs to ultimately be placed INSIDE another dynamically created mc. So I will need to somehow 'attach/place' firstClip_mc into secondClip_mc.

I'm doing this for undo tracking purposes. For example, the user can paint into the dynamically created clip called firstClip_mc and then that 'painting' will then be placed inside secondClip_mc which is also created on the fly. That way I can 'undo' the entire painted clip...attachMovie only works from the library. It's like I need that type of functionality for these two clips...

Any ideas? And thank you in advance!

Brian

How Can I Set Actions To Buttons Inside Dynamically Created Movieclips?
Hello thank you for coming! I am trying to put Actions in a button that is inside a Blank Movieclip. This Blank movie clip gets duplicated dynamically. Although it does not seem to work!

Inside the Blank MC I put a button. I clicked on this button an set it to do an action but it doesn't work!

Can someone help please! Any type of help will be greatly appreciated.

How To Run Some Actionscript Inside A Dynamically Created Movie Clip?
Hey Flashkit,

First off forgive me if someone has posted a message on this subject already because I haven't found it, yet.

I would like to create some dynamically created movie clips in a main movie that absorb, receive, or have embedded in them (I do not know the word to use) some actionscript that can be called over and over while the newly created movie clips play through their own timelines.

Is this possible? How can I put some actionscript inside a dynamically created movie clip? I’m interested in using the code on the first frame, perhaps on enter frame or actually anywhere in the move clip.

Thanks,
- Jimmy

Create Link Inside Dynamically Created Texfield
Hello world, I have the below dynamically created textfield:


PHP Code:



_root.createEmptyMovieClip('label', 1002);
     _root.label.createTextField("insidelabel",1003,-30,-30,200,100);
     _root.label.insidelabel.background = true;
     _root.label.insidelabel.selectable = true;
     _root.label.insidelabel.multiline=true;
     _root.label.insidelabel.wordWrap=true;
     _root.label.insidelabel.font="Tahoma";
     _root.label.insidelabel._x=581;
     _root.label.insidelabel._y=120;
     
     _root.label.insidelabel.text = "Juliet Howard's Illustration website, constructed in HTML and Flash. Date of creation: February 2006. Online on www.julietillustration.co.uk"; 




Is it possible to make "www.julietillustration.co.uk" clickable as an html link or is this feature just reserved for textfields created through the text tool?.

As always, any help much appreciated.

Txusm

Assigning Movieclip To Dynamically Created Movieclip
In part of my actionscript i'm using:

thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());

to create a seperate movieclips for ewach image in my xml file.

How would I then attach another movieclip to each of the newly created ones?

ie thumbnail_mc.t0, thumbnail_mc.t1, thumbnail_mc.t2...

is there a way to do it automaticall7y or do i have to assign it to each one individually?



"thumbnail_mc.t"+k.attachMovie obviously doesn't work

Assigning Movieclip To Dynamically Created Movieclip
In part of my actionscript i'm using:

thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());

to create a seperate movieclips for ewach image in my xml file.

How would I then attach another movieclip to each of the newly created ones?

ie thumbnail_mc.t0, thumbnail_mc.t1, thumbnail_mc.t2...

is there a way to do it automaticall7y or do i have to assign it to each one individually?



"thumbnail_mc.t"+k.attachMovie obviously doesn't work

[MX] Referencing A Dynamically Created MovieClip...
Hi,

I'm trying to load jpegs named Image1.jpg, Image2.jpg, etc, into dynamically created MovieClips using the following.

PHP Code:



TotImgs=number(myVars.TotImgs);
this.createEmptyMovieClip("ImageHolder"+TotImgs, 999);
loadMovie("Image"+TotImgs+".jpg", ["ImageHolder"+TotImgs]);




This, of course only loads one image, image3, but I just wanted to get the code correct before I start adding loops.

It ain't working but hopefully from the description of what I'm trying to achieve, somebody may be able to point me into the right direction.

The TotImgs variable loads fine, just no image loads in to the empty Movieclip.

Ta.

Masking A Dynamically Created Movieclip
hi all,

i'm creating an image scrollbar and for some reason i can't get my mask to properly mask the "container" movie clip which holds the dynamically created image holder clips. i only want to display a few images at a time and i'm using setMask to perform the masking but for some reason i can't get it to work. below is the actionscript code and i've attached a zip of the FLA and the images if you want to take a look.

any help would be greatly appreciated! thanks!


Code:
var x_o:Number = 0;
var y_o:Number = 0;
var x_pad:Number = 4;

this.createEmptyMovieClip("container_mc", this.getNextHighestDepth(), {_x:x_o, _y:y_o});
currDepth = this.container_mc.getDepth();
trace("container_mc depth is " + currDepth);


for(i=0; i < 16; i++) {
//this.container_mc.attachMovie("rollover", "rollover" + i, currDepth + 1);
this.container_mc.attachMovie("rollover", "rollover" + i, this.container_mc.getNextHighestDepth());
clipWidth = this.container_mc["rollover" + i]._width;
if(i==0) {
this.container_mc["rollover" + i]._x = x_o;
this.container_mc["rollover" + i]._y = y_o;
clip_x = this.container_mc["rollover" + i]._x;
current_x = clip_x;
currDepth = this.container_mc["rollover" + i].getDepth();
trace(currDepth);
} else {
this.container_mc["rollover" + i]._x = current_x + this.container_mc["rollover" + i]._width + x_pad;
current_x = this.container_mc["rollover" + i]._x;
this.container_mc["rollover" + i]._y = y_o;
currDepth = this.container_mc["rollover" + i].getDepth();
trace(currDepth);
}
this.container_mc["rollover" + i].onRollOver = function() {
trace("Rolling over image " + this._name);
trace("Parent is " + this._parent._name);
}
this.container_mc["rollover" + i].onRollOut = function() {
}
}

// images
for(i=0; i < 16; i++) {
this.container_mc.attachMovie("holder", "holder" + i, this.container_mc.getNextHighestDepth());
if(i==0) {
this.container_mc["holder" + i]._x = x_o + 1;
this.container_mc["holder" + i]._y = y_o + 1;
clip_x = this.container_mc["holder" + i]._x;
current_x = clip_x;
this.container_mc["holder" + i].loadMovie("images/img" + i + ".jpg");
this.container_mc["holder" + i]._xscale = 13.45;
this.container_mc["holder" + i]._yscale = 13.45;
currDepth = this.container_mc["holder" + i].getDepth();
trace(currDepth);
} else {
this.container_mc["holder" + i]._x = current_x + this.container_mc["holder" + i]._width + x_pad + 2;
current_x = this.container_mc["holder" + i]._x;
this.container_mc["holder" + i]._y = y_o + 1;
this.container_mc["holder" + i].loadMovie("images/img" + i + ".jpg");
this.container_mc["holder" + i]._xscale = 13.45;
this.container_mc["holder" + i]._yscale = 13.45;
currDepth = this.container_mc["holder" + i].getDepth();
trace(currDepth);
}
}

totClipWidth = (i*clipWidth) + ((i - 1)*x_pad);
trace(totClipWidth);


trace(this.container_mc._x);
trace(this.container_mc._y);

scroller_x = 50;
scroller_y = 200;

this.container_mc._x = scroller_x;
this.container_mc._y = scroller_y;
//this.container_mc._height = 371;
//this.container_mc._width = totClipWidth;

// mask
this.attachMovie("mask", "mask_mc", this.getNextHighestDepth());
this.mask_mc._x = scroller_x;
this.mask_mc._y = scroller_y;
this.mask_mc._width = totClipWidth;
this.mask_mc._height = clipWidth;

this.container_mc.setMask("mask_mc");

How To Control A Dynamically Created Movieclip?
Hi everybody am new to AS3. Please help!

Problem:
I have a movieclip in my flash library and i dynamically attached to the stage. Inside this movieclip i have another 3 movieclips.
I can able to access the properties like x,y,scaleX ....Everything works fine.
But on Mouse move i would like to control the movieclip.
ie. depends upon the angle i would like to display different movieclip in this dynamically created one. Please help
function buildTile():void {
addChild(player);
player.x=50;
player.y=100;
player.name="player";
player.scaleX =.70;
player.scaleY =.70;
stage.addEventListener(MouseEvent.MOUSE_MOVE,OnMou seMove);
}

OnLoad For Dynamically Created MovieClip
Good time, dear developers!
Help me, please!
How can i set onLoad and other methods for dynamically created MovieClips?

Here is trouble i have:

if in MovieClip (named "LibMovieName", for example) write this code

this.onLoad = function() {trace("OnLoad");}

then this will work only if i'll place instance of "LibMovieName" on work area by hands.

And how can it work in run-time? So, i need to create MovieClip in run-time and this clip must have working onLoad() method.
Code, listed below isn't work:

Scene = _root.MainMovie;
Scene.attachMovie("LibMovieName","daMovie",100);
...
Scene.daMovie.onLoad = function() {trace("DaMovie.OnLoad");};


String "OnLoad"(check it above) also not present in trace-log window...

So, Help me Please!!!

Dynamically Created Movieclip And OnRollOver
Hi,

I'm dynamically creating a row of movieclips, load images in them but I can't seem to be able to react on any event related to the clip.

Here's what I did:

var Thumb = [];
var CurrxPos:Number = 0;

var MainHolder:MovieClip = this.createEmptyMovieClip("mcMainHolder",this.getN extHighestDepth());

var ThumbHolder:MovieClip = MainHolder.createEmptyMovieClip("mcThumbHolder", MainHolder.getNextHighestDepth());

for (i=1;i<5;i++) {
Thumb[i] = ThumbHolder.createEmptyMovieClip("mcThumb"+i, ThumbHolder.getNextHighestDepth());
Thumb[i]._x = CurrxPos;
CurrxPos += 50;
}

MainHolder._x = 100;
ThumbHolder._x = 100;
ThumbHolder._y = 100;

for(i=1;i<5;i++) {
Thumb[i].loadMovie("images/thumb_"+i+".jpg");
}

stop();

//This part is not working
this.mcMainHolder.mcThumbHolder.mcThumb1.onRollOve r = function() {
trace("Mouse over Thumb1!");
}

Thanks a lot!

Removing Dynamically Created MovieClip
Hi,
I am creating a chat Application , where in I am getting a List of Users and there Details through an XML String. Iam dynamic Movie Clip for Each user on the List and it works fine. but Now I want to remove these movie Clips on the click of clearButton (_root.clearButton.onRelease towards the end of the code). I have trie all options.. but not working please suggest.


this.stop();
var flag:Boolean = false;
var userArray:Array = new Array();
var nickArray:Array = new Array();
var imageArray:Array = new Array();
var xPost:Number = 0;
var yPost:Number = 0;
//var topList_mc:MovieClip = _root.attachMovie("topMovie", "topList_mc", _root.getNextHighestDepth());
this.createEmptyMovieClip("listClip_mc", this.getNextHighestDepth());
topList_mc._x = 650;
topList_mc._y = 70;
var listClipLoader:MovieClipLoader = new MovieClipLoader();
var textClipLoader:MovieClipLoader = new MovieClipLoader();
var userProfile_mc:MovieClip = new MovieClip();
var imageLoader:MovieClipLoader = new MovieClipLoader();
myListener = new Object();
myListener.onLoadComplete = function(targetMC) {
targetMC.onRollOver = function() {
setProfile(targetMC);
};
};
listClipLoader.addListener(myListener);
//textClipLoader.addListener(myListener);
function setProfile(targetMC) {
var mcValue:String = targetMC._parent._name;
if (!flag) {
userProfile_mc = _root.attachMovie("userProfile", "userProfile_mc", _root.getNextHighestDepth());
}
for (var i = 0; i<=nickArray.length; i++) {
if (mcValue == nickArray[i]) {
imageLoader.addListener(this);
flag = true;
userProfile_mc._x = topList_mc._width;
userProfile_mc._y = _ymouse;
var imagePath:String = imageArray[i];
var userName:String = userArray[i];
var nickName:String = nickArray[i];
userProfile_mc.userTxt.text = userName;
userProfile_mc.nickTxt.text = nickName;
imageLoader.loadClip(imagePath, userProfile_mc.ldImage);
}
}
}
//associate listerer with MCL object
var loadXMLString:String = "<board><user><UserName>ăƒ©ă‚žăƒŁăƒ„</UserName><Status>1</Status><NickName>Raj</NickName><UserImagePath>rajat_1143780945342.jpg</UserImagePath></user><user><UserName>Manish</UserName><Status>0</Status><NickName>man</NickName><UserImagePath>manish_1144333276431.jpg</UserImagePath></user><user><UserName>かおる</UserName><Status>1</Status><NickName>Kao</NickName><UserImagePath>kaoru_1138619360716.jpg</UserImagePath></user></board>";
var headlineXML:XML = new XML(loadXMLString);
headlineXML.ignoreWhite = true;
_root.onLoad = function() {
var HeadlineXMLNode = headlineXML.firstChild;
if (HeadlineXMLNode.nodeName.toUpperCase() == "BOARD") {
user = HeadlineXMLNode.firstChild;
while (user != null) {
if (user.nodeName.toUpperCase() == "USER") {
element = user.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "USERNAME") {
uName = element.firstChild.nodeValue;
userArray.push(uName);
}
if (element.nodeName.toUpperCase() == "NICKNAME") {
nName = element.firstChild.nodeValue;
nickArray.push(nName);
}
if (element.nodeName.toUpperCase() == "USERIMAGEPATH") {
iPath = element.firstChild.nodeValue;
imageArray.push(iPath);
}
element = element.nextSibling;
}
}
user = user.nextSibling;
}
}
createUserList();
};
function createUserList() {
for (var j = 0; j<=userArray.length; j++) {
var imagePath:String = imageArray[j];
var userName:String = userArray[j];
var nickName:String = nickArray[j];
if (imagePath == undefined) {
} else {
//var topList_mc:MovieClip = _root.attachMovie("topMovie", "topList_mc", _root.getNextHighestDepth());
topList_mc = _root.attachMovie("liClip", nickName, this.getNextHighestDepth());
xPost = topList_mc._x;
yPost = yPost+topList_mc._x+25;
topList_mc.txtNickName.htmlText = nickName;
topList_mc._x = xPost;
topList_mc._y = yPost;
listClipLoader.loadClip("thumb_"+imagePath, topList_mc.ldImage);
}
}
}

// This is Not working
_root.clearButton.onRelease = function() {
removeMovieClip(_root.nickArray[0]);
};

Please Suggest..

Thanx

Manish

Adding Elasticity To Dynamically Created MovieClip
hi,

I have a problem at the minute where i have the following code


Code:
for (i=1; i<9; i++) {
_root.createEmptyMovieClip("button"+i, 100+i);
_root["button"+i].lineStyle(1, 0x000000, 100);
_root["button"+i].beginFill(0x0066CC, 100);
_root["button"+i].moveTo(-95, -20);
_root["button"+i].lineTo(95, -20);
_root["button"+i].lineTo(95, 20);
_root["button"+i].lineTo(-95, 20);
_root["button"+i].endFill(-95, -20);
_root["button"+i]._x = i*95;
_root["button"+i]._y = 365;
}

// Give button actions
button1.onRelease = function() {
loadVariables("text1.txt", "_root");
};
button2.onRelease = function() {
loadVariables("text2.txt", "_root");
};

//.....actions for buttons 3,4,5,6,7 & 8

..which create my menu system fine. However i wish to add a nice little elasticity function to the menu system which i have found.
The code for the elasticity stuff is:


Code:
onClipEvent (load) {
this.elasticScale = function(tar, accel, convert) {
xScale = xScale * accel + (tar - this._xscale) * convert;
yScale = yScale * accel + (tar - this._yscale) * convert;
this._xscale += xScale;
this._yscale += yScale;
}
}
onClipEvent(enterFrame){
if(this.hitTest(_root._xmouse,_root._ymouse,true)){
this.elasticScale(125,0.7,0.4)
}else if (!this.hitTest(_root._xmouse,_root._ymouse,true)){
this.elasticScale(100,0.7,0.4)
}
}


However because clip events are only permitted for movie clip instances this is not going to work.
How can I recode the OnClipEvent portion of the code in a way that it applies to the menu system I have just created.

Any ideas would be welcome

Playing A Dynamically Created Movieclip Instance(name)?
Hello,
Im new to actionscript, so forgive me if this is a dumb question, but Im trying to do something like this, i have 10 instances named myClip1, myClip2, etc....
code:
for(i=0; i<10; i++)
{
instanceName = "MyClip"+i;
instanceName.play();
}


is this not possible?

OnRelease Event Of Dynamically Created Movieclip
I'm fairly-ish new to actionscript although i've been programming in other languages for a gd 8 years now, so its only really the syntax and the little quirks of the language i'm finding harder.

Basically i've loaded 8 jpegs from an xml file and am trying to make them open a corrasponding url (also in the xml file) when clicked. This is what i've got so far (a slightly more focused version anyway):

code:
var mainNode = this.friendList_xml.firstChild;
resourceCount = mainNode.childNodes.length;
var resource;
for (var i = 0; i < resourceCount; i++) {
resource = mainNode.childNodes[i];

link = resource.attributes.link;
image = resource.attributes.image;

createEmptyMovieClip("image_mc"+i, this.getNextHighestDepth());
_root.friends_mc["image_mc"+i]._x=(109*(i-x));
_root.friends_mc["image_mc"+i]._y=y+15;
//simply the positioning of the mc's
loadMovie(image,_root.friends_mc["image_mc"+i]);

_root.friends_mc["image_mc"+i].onRelease=function(){
getURL(link, _blank);
}

}


They display perfectly, at exactly the positions i want, however then i move the mouse over there is no clicky hand like you'd expect, and when i click on them nothing happens. I've also tried putting the onRelease function on the root level and still nothing worked.

I'm prob just going about this the wrong way or something, but if anyone could point me in the right direction i'd be very grateful.

thanks,
-chris

Unable To Duplicate Dynamically Created MovieClip
Hi buddies,

Am not able to duplicate dynamically created movie clip. I am retreiving images Path from an XML and load each image in a MovieClip.
I have to display those image MC later when needed.
The pbm i have is am not able to duplicate dat attached movie clips. Can anybody luk at the attachments and tell me y?
See the attachement which is having XML file and ImgLoader.fla.

Note: If i duplicate any other MC it is working but not with the dynamic one.
Any suggestion wud be greatly welcome.....

Unable To Duplicate Dynamically Created MovieClip
Hi buddies,

Am not able to duplicate dynamically created movie clip. I am retreiving images Path from an XML and load each image in a MovieClip.
I have to display those image MC later when needed.
The pbm i have is am not able to duplicate dat attached movie clips. Can anybody luk at the attachments and tell me y?
See the attachement which is having XML file and ImgLoader.fla.

Note: If i duplicate any other MC it is working but not with the dynamic one.
Any suggestion wud be greatly welcome.....

Exporting A Dynamically Created Movieclip As Video
Hi,

I am not really sure where to start looking to do this - or even whether Flash is capable of doing it? I need to let users create a custom movie clip, say with their name and photo on it, and then export that movieclip as a video file preferably as a .mp4/.3gp/similar.

Is this possible with Flash? I can only find reference to pulling video into the stage, not publishing it out. I also wondered whether Flash Server(?) would be needed to dynamically publish the content?

Anyway, is this even possible, or should I be looking at other technologies?

Appreciate any help or info!

Thanks

Unable To Duplicate Dynamically Created MovieClip
Hi buddies,

Am not able to duplicate dynamically created movie clip. I am retreiving images Path from an XML and load each image in a MovieClip.
I have to display those image MC later when needed.
The pbm i have is am not able to duplicate dat attached movie clips. Can anybody luk at the attachments and tell me y?
See the attachement which is having XML file and ImgLoader.fla.

Note: If i duplicate any other MC it is working but not with the dynamic one.
Any suggestion wud be greatly welcome.....

Printing A Dynamically-created, Masked Movieclip On The Fly...is This Even Possible?
hey all -

I need some help printing some product specs from within Flash, but I'm not even sure that what I'm trying to do is feasible or even possible. Any advice would be greatly appreciated. Please follow these steps to view the content I need to print:

1. go to http://www.wholelattelove.com/esp_index.cfm. Click "Launch Espressomatic".

2. Add at least 2 machines to your list by clicking on them in the right-hand window.

3. Click on the "compare" tab in the middle of the screen near the left of the menu. This will generate the product comparison tables.

This product comparison data is being pulled from the backend and assembled on the fly, then masked dynamically once the base clip is generated. Only 8 rows are visible at any given time due to the mask, but the clip can be scrolled up and down to view all the rows. For data auditing purposes, I need to print out the whole review data clip. Right now I am using the following code to print:


Code:
print_btn.onRelease = function()
{
var my_pj = new PrintJob();
var myResult = my_pj.start();
if(myResult){
myResult = my_pj.addPage (this._parent.data_mc.hold, null,{printAsBitmap:false}, 1);
my_pj.send();
}
delete my_pj;

}
This code works fine but it only prints the 8 rows which are currently visible. I need to print the entire clip, unmasked. I am having trouble figuring out how to do this. Some options I'm considering are:
1. (This would be excellent): Figure out how to remove the mask and print the whole clip when someone clicks the button, but leave the displayed content alone. This needs to print without affecting the functionality that's already there.
2. when print_btn is clicked, duplicate the data movieclip, print it, then delete it
3. build the printjob as I build the table in the first place.

Anybody have any ideas?

-Rhino

Nesting Dynamically Created Movieclip At Runtime?
Is it possible to nest a movieclip into another dynamically created movieclip at runtime? The commented line of code works, but I am trying to nest a movieclip after it is created into another.







Attach Code

this.createEmptyMovieClip("House_mc", 1);
//this.House_mc.createEmptyMovieClip("Dog_mc", 2);
this.createEmptyMovieClip("Dog_mc", 2);
trace(this.House_mc.Dog_mc);

How To Select Movieclip Border Dynamically Created
I created rectangle movieclip at runtime , now i want to select only particulr portion of that movieclip.if i select border ,that only be selected,
can anyone say answer for this question, pls

ScrollPane Set Content To Dynamically Created MovieClip
How?

How do I set scrollpane content using code to a dynamic movieclip I have created.

Trying To Create OnLoad Function For Dynamically Created Movieclip
Hi,
I wanted to use setinterval to randomly attach a static movie clip to the stage and place it at a random y position to the left of the visible area. I then want that movie clip to move itself across the visible area at a random speed after assigning itself a random width.

So the code I've got is:

Code:
//function to randomly generate white flashes across screen
function white_flashes() {
new_level = "MCwhiteflash" + String(depth++);
this.attachMovie("white_flash",new_level,depth);
this[new_level]._x = -(this[new_level._width]);
this[new_level]._y = (Math.random()*194)+106;
//---works fine up to here
this[new_level].onLoad = function() {
this._width = (Math.random()*50) + 10;
flashspeed = (Math.random()*190)+10;
}
this[new_level].onEnterFrame = function() {
this._x += this.flashspeed;
}
//---these event triggers aren't working
}
setInterval(this, "white_flashes", 1000);


So my question is how do you get the events of loading the MC and enterFame to actually trigger the functions?

Thanks
Robin

[Flash 8 Actionscript] _x Property Of Dynamically Created Movieclip
Hi everyone.

I'm having trouble with how Flash sets the _x property of a dynamically created movieclip.

If I create a rectangle on the stage using the Drawing API:

//for the purposes of this example, assign a value to i
var i:Number = 0;

//assign var squareName
var squareName:String = "square" + i;

//create an empty movieclip named [squareName] at depth 1
this.createEmptyMovieClip([squareName], 1);

//draw a 100 x 100 pixel rectangle originating at coordinates (100, 100)
this[squareName].beginFill("0xFFFFFF", 100);
this[squareName].moveTo(100, 100);
this[squareName].lineTo(200, 100);
this[squareName].lineTo(200, 200);
this[squareName].lineTo(100, 200);
this[squareName].lineTo(100, 100);
this[squareName].endFill(); // stop the fill

//trace the _x property of this[squareName]
trace("this[squareName]._x: " + this[squareName]._x); //RETURNS 0: shouldn't this be 100?

The _x property of the dynamically created movieclip is relative to itself (ie. 0...the upper left corner of the movieclip). I know I can get the global _x value of the movieclip by creating a bounds object and calling targetBounds.xMin using something like this:

//trace the global x coordinate for the movieclip
var targetBounds:Object = this[squareName].getBounds(_root);
trace ("targetBounds.xMin: " + targetBounds.xMin);

But how do I create a movieclip so that it's _x property will be relative to the Stage in the first place, and not itself? It's important, because if I then want to move the movieclip using something like this:

this[squareName]._x = 200;
trace("this[squareName]._x: " + this[squareName]._x); //RETURNS 200: shouldn't this be 300?

Then the square moves 200 to the right within itself. This is clearly not what I want to do. I want to set the value of _x to the coordinate 200 (not 300, as this does). I have tried doing the same using the setProperty function:

setProperty(this[squareName], _x, 200);

But with the same result. This example code is highly simplified from the working file, but shows the problem.

I'm not new to Flash by any stretch of the imagination, but I have never come up against this problem before. For context, I'm actually getting my feet wet with the Tween class, and am having trouble animating dynamically created movieclips due to this confusion with coordinates. When I tween a dynamically created clip from one set of coordinates to another, they are offset by the movieclip's _x and _y properties starting at 0, 0, rather than their actual position on stage.

ANY help is greatly appreciated, as I've been fighting with this for hours.

Cheers! JR.





























Edited: 02/28/2007 at 01:25:43 PM by Johnny Rodgers

Quick One: Target To Combobox In Dynamically Created Movieclip?
I have a movie clip "input_mc" from the Library and attach it to the main timeline using this.attachMovie(). It contains comboboxes, and from the main timeline I want to control the comboboxes, like addItem(). How do I do this?

From the main timeline:
this.input_mc.comboboxInstanceName.addItem("foo") - doesn't work
input_mc.comboboxInstanceName.addItem("foo") - doesn't work
_root.input_mc.comboboxInstanceName.addItem("foo") - doesn't work

I'm puzzled....there must be something really easy that I'm missing....

Thanks!!!

[Flash 8 Actionscript] _x Property Of Dynamically Created Movieclip
Hi everyone. Long time listener, first time caller here.

I'm having trouble with how Flash sets the _x property of a dynamically created movieclip.

If I create a rectangle on the stage using the Drawing API:


Code:
//for the purposes of this example, assign a value to i
var i:Number = 0;

//assign var squareName
var squareName:String = "square" + i;

//create an empty movieclip named [squareName] at depth 1
this.createEmptyMovieClip([squareName], 1);

//draw a 100 x 100 pixel rectangle originating at coordinates (100, 100)
this[squareName].beginFill("0xFFFFFF", 100);
this[squareName].moveTo(100, 100);
this[squareName].lineTo(200, 100);
this[squareName].lineTo(200, 200);
this[squareName].lineTo(100, 200);
this[squareName].lineTo(100, 100);
this[squareName].endFill(); // stop the fill

//trace the _x property of this[squareName]
trace("this[squareName]._x: " + this[squareName]._x); //RETURNS 0: shouldn't this be 100?
The _x property of the dynamically created movieclip is relative to itself (ie. 0...the upper left corner of the movieclip). I know I can get the global _x value of the movieclip by creating a bounds object and calling targetBounds.xMin using something like this:


Code:
//trace the global x coordinate for the movieclip
var targetBounds:Object = this[squareName].getBounds(_root);
trace ("targetBounds.xMin: " + targetBounds.xMin);
But how do I create a movieclip so that it's _x property will be relative to the Stage in the first place, and not itself? It's important, because if I then want to move the movieclip using something like this:


Code:
this[squareName]._x = 200;
trace("this[squareName]._x: " + this[squareName]._x); //RETURNS 200: shouldn't this be 300?
Then the square moves 200 to the right within itself. This is clearly not what I want to do. I want to set the value of _x to the coordinate 200 (not 300, as this does). I have tried doing the same using the setProperty function:


Code:
setProperty(this[squareName], _x, 200);
But with the same result. This example code is highly simplified from the working file, but shows the problem. It's also attached as an .fla.

I'm not new to Flash by any stretch of the imagination, but I have never come up against this problem before. For context, I'm actually getting my feet wet with the Tween class, and am having trouble animating dynamically created movieclips due to this confusion with coordinates. When I tween a dynamically created clip from one set of coordinates to another, they are offset by the movieclip's _x and _y properties starting at 0, 0, rather than their actual position on stage.

ANY help is greatly appreciated, as I've been fighting with this for hours.

Cheers! JR.

Copyright © 2005-08 www.BigResource.com, All rights reserved