[RESOLVED] MovieClip Reference nightmare
Hi,
I've been working on a project the last few days in AS2 and decided I'd try and re-write it in AS3 as I'm yet to venture in to the AS3 world.
I've done most of the conversion, but I'm stuck on what should be an easy problem.
I'm loading images from an xml.
The images get put into movieclips.
mcholder.image_mc.nmc0
mcholder.image_mc.nmc1
mcholder.image_mc.nmc2
mcholder.image_mc.nmc3 .......
I have a function that resizes the images when the stage is resized.
This then runs another function to update an array of the image widths.
The problem I have is trying to update the new widths into an Array. I just can't seen to reference my MC's to get the widths!
Actionscript Code:
function checkImages () {
for (var i:int = 0; i < imageHolders.length; i++){
var prevX = ["mcholder.image_mc"+imageHolders[i][1]]; //name
var MC = prevX; //This out puts mcholder.image_mc0 .....
//var MC = prexX.width; // This outputs undefined
trace (MC + " Old Width"); //
}
}
imageHolders is an array. imageHolders[i][0] contains the current width.
imageHolders [i][1] container the nmc.name
I stumped as to why I can get the properties of these items.
The only thing I can think of is that I have 'nmc.name' during the mc creation.
Actionscript Code:
function onComplete(event:Event):void {
var mc = event.target.content;
mc.smoothing = true;
mc.alpha = 0;
var nmc:MovieClip = new MovieClip();
nmc.pos = count;
nmc.name = "nmc" + count;
var nmcname = nmc.name;
var porp = mc.width / mc.height;
mc.width = stage.stageHeight * porp;
mc.height = stage.stageHeight;
nmc.addChild(mc);
Any ideas?