Hi!
I am loading text from an XML file into dynamically created MCs. How do I target those MCs so that I can change where they are, their alpha, etc.? For example, I want them to have zero alpha until the image from the XML node they’re in is loaded, then make them visible.
XML:
<portfolio>
<piece>
<image>portfolio/01.jpg</image>
<description>one</description>
</piece>
</portfolio>
AS:
function xmlLoaded(e:Event):void {
var loadedxml:XML = new XML(e.target.data);
for (var i:uint=0; i<loadedxml.piece.length(); i++) {
var pieceholder:MovieClip = new MovieClip();
portfolio.addChild(pieceholder); // "portfolio" is a named MC on the stage
pieceholder.buttonMode = true;
var pieceloader = new Loader();
var pictURLReq:URLRequest = new URLRequest(loadedxml.piece.image.text()*);
pieceholder.addChild(pieceloader);
pieceloader.load(pictURLReq);
pieceloader.contentLoaderInfo.addEventListener(Event.COMPLETE, pieceloaderComplete);
// text
thedescription = loadedxml.piece.description.text()*;
words = "Title: " + thedescription;
var thetext:TextField = new TextField();
var myFont:Font = new Arial();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;
myFormat.size = 11;
myFormat.color = 0x003366;
myFormat.leading = 1;
thetext.width = 200;
thetext.height = 200;
thetext.multiline = true;
thetext.defaultTextFormat = myFormat;
thetext.embedFonts = true;
thetext.antiAliasType = AntiAliasType.ADVANCED;
thetext.sharpness = 100;
thetext.thickness = 500;
thetext.x = 0;
thetext.y = 205;
pieceholder.addChild(thetext);
thetext.htmlText = words;
thetext.alpha = .0;
}
}
function pieceloaderComplete(e:Event):void {
thetext.alpha = 1; // this doesn't work
}
The text is loaded properly and the alpha is set to zero, but when I try and target it in the function pieceloaderComplete I get an error:
ReferenceError: Error #1065: Variable thetext is not defined.
at mottomo_fla::MainTimeline/pieceloaderComplete()
Help! How do I properly target the MC?
Thanks,
trick