PDA

View Full Version : Accessing dynamic text from inside an addChild object



joemurray
August 27th, 2008, 09:44 AM
Can't figure this out for the life of me. Its probably something simple, but I can't find any solutions online. Can anyone help a brother out here? All I'm trying to do is assign text to a dynamic text box that is inside a movieclip (loaded from the library using addChild()

Heres my code (obviously wrong) :

for(var i:uint=0; i<myXML.*.length(); i++) {
var myMC:MovieClip = new content_mc();
myMC.y = i*170;
myMC.title_txt.text = "Blah";
this.content.addChild(myMC);
}

Anil_kumar
August 27th, 2008, 11:09 AM
try this code

///////////////////////////////////////////////////////////////

var listLoader:URLLoader = new URLLoader( new URLRequest("filelist.xml") );
var btnLoader:Loader = new Loader();
listLoader.addEventListener(Event.COMPLETE, gotList);
var xmlData:XML;
function gotList(evt:Event):void {
xmlData = XML(listLoader.data);
var i:int = 1;
for each (var item:XML in xmlData..btn) {
//trace(item.name.toString());
var myMC:MovieClip = new content_mc();
//myMC.y = i*170;
myMC.y = i*myMC.height;
myMC.title_txt.text =item.name.toString();
this.content.addChild(myMC);
i++;
}
listLoader.removeEventListener(Event.COMPLETE, gotList);

}
///////////////////////////////////////////////////////////////

Anil
anilkumarnd@gmail.com

joemurray
August 27th, 2008, 11:40 AM
Thanks for the help. Unfortunately it still wont work for me. We have our flash files set up exactly the same. Not sure what the problem is. Here is the new code I'm using. I can trace all items in the XML and have them show up in the output panel, but when i assign one to "title_txt" dynamic text box within content_mc, I get nothing at all there. Really frustrating. Any idea why Im having this problem?

var i:int = 0;

for each (var item:XML in myXML.*) {
//trace(item.name.toString());
var myMC:MovieClip = new content_mc();
//myMC.y = i*170;
myMC.y = i*150;
trace(item.time);
myMC.title_txt.text = item.title.toString();
this.content.addChild(myMC);
i++;
}

Anil_kumar
August 27th, 2008, 11:45 AM
download the source file "EmbeddedText.zip " from previous post
it works

or

send me ur source file @ anilkumarnd@gmail.com

joemurray
August 27th, 2008, 12:20 PM
I just sent you the .fla file. Thanks for any help you can give.

joemurray
August 27th, 2008, 02:17 PM
Anyone else have any advice in the meantime? I would think that this would be a simple process. Just trying to get text to show up in a dynamic textbox. I'm good with as2, but pretty much a newb when it comes to as3. I know the data is there because when I trace one of the xml nodes, it shows up. But when i try to assign it to the dynamic text box inside the movie clip that I'm loading from the library (myMC.title_txt.text = "Blah"), nothing shows up.

joemurray
August 27th, 2008, 04:14 PM
Nevermind. Fixed it. I had a mask over the scrollable content area, and for some strange reason, the mask was hiding the text so it was there all along. Any idea why this happens? Seems kind of weird that it would do that.

damienmcd
August 14th, 2009, 11:54 AM
I have been having the same problem and I know it is because I have a Mask over the layer. The area where the Dynamic Text is supposed to be visible is added to the Mask layer and therefore should be visible.

What I have, in essence, is a Movie Clip with some text in it placed around the edge of a circle. This circle containing the text is all contained in a movie clip on one layer. There is a layer above that is set ask a Mask layer with the area where I want the text to be visible set in the Mask.

Anybody got any ideas on how to get the Dynamic Text to show below the mask layer?

johnsonw
September 16th, 2009, 06:28 PM
Hey guys,

I had a similar problem in which I have a dynamic text box within a movieclip. This movieclip is then added to the child of another movieclip that contains a mask. It dawned on me that the mask was causing the issue because the characters in a dynamic movie clip are not rendered. To solve this problem:

1. Select the text box that is not displaying text.
2. Click on the "Character Embedding" button within the properties pane.
3. Select Uppercase, Lowercase, and Numerals (Use Control to select multiple items)
4. Click the "OK" button
5. Re-publish

This should embed the characters so that they will display under the mask. Let me know if this doesn't fix the problem. It worked for my issue.

Will