Convert Loader() to SimpleButton()
EntWebDS Jan 2, 2010 11:23 PMI am loading a series of images from an XML file into Loader() objects, but I am having some issues with what I want to do with those images afterwards.
I need to set the size of the images to thumbnails for a sliding chooser and since the images are various widths, I cannot use a constant. I have to get the Bitmap from the contentLoaderInfo:
//This is found within an array loop and loads for each picture in the XML file (actually, every other pic)
picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadChooserImages);
function loadChooserImages(evt:Event):void
{
// All thumbmails will have a height of 50.
// The height will be proportionally set.
var bm:Bitmap = Bitmap(evt.target.content);
var reductionVal = 50 / bm.height;
bm.width = bm.width * reductionVal;
bm.height = 50;
leftX = bm.width; // leftX is the x value that will be used to place the next image
// intChooserWidth is the width of all the images plus the outer margins
// intSpace is the space between images images
intChooserWidth = leftX + intSpace;
}
The problems are
1)
a) the objects do not trigger the COMPLETE event in the same order as the array because some images are larger than others, so my row of images is not in the same order as the array. How do I get them in the correct order?
b) intChooserWidth, though declared at the module level of frame 1 of the .fla is not seen by the child object code that runs the slider. How does one access a variable that was declared and set in a parent object?
2) I want to place the children as SimpleButtons and assign Event Listeners. I do not know how to recast the Loader() object as a SimpleButton.
I have attached the .fla and xml files but not the graphic files. Any files will do as long as the XML file matches the image names.
Any help would be appreciated.
-
images.fla.zip 11.2 K
-
pics_mod.xml 1.6 K



