|  | Height and Width of dynamic images |  | |
| | | yombull |  |
| Posted: Fri Aug 29, 2008 3:50 pm Post subject: Height and Width of dynamic images |  |
| |  | |
Hi,
I have this code that I have been working on that loads images from an xml file. I need to be able to get the imported images height and width to be able to do what I want but can't seem to figure out how. I think I need to use the onLoadInit but can't get it to work. Can anyone help me on how I would trace the height and width of the imported images in the following code:
frame 1
stop(); // XML variable var picturesXML:XML= new XML; // Ignore white spaces picturesXML.ignoreWhite = true // Loads the .xml file picturesXML.load("image_slider/logos.xml") // When the load finish starts the movie picturesXML.onLoad = function(ok){ if (ok){ var childItems:Array = picturesXML.firstChild.childNodes; numberOfPictures = childItems.length; gotoAndPlay(2) } }
frame 2
stop(); // Number of items itemNum = numberOfPictures; // Stage Dimentions stageWidth = 199; stageHeight = 200; // Button's widht height = 107; // Separation between the buttons separation = 0 // Distance between the buttoms space = height + separation; // Total widht of the buttons line limit = itemNum * space; // Speed speed = 8
for(i=0; i<itemNum; i++) { _root.attachMovie("mc_button","mc_button"+i,10+i); ref = _root["mc_button"+i]; // Horizontal Positi?n (_y) ref._x = (stageWidth - 175) / 2; // Vertical Positi?n (_x) + separation (20px) ref._y = ( space * i ) + separation; // Loads the picture description ref.marc.unloadMovie(); // Load the picture(.jpg) ref.marc.loadMovie(picturesXML.firstChild.childNodes[i].childNodes[1].firstChil d.nodeValue); // The link where will go when press ref.link=picturesXML.firstChild.childNodes[i].childNodes[2].firstChild.nodeValu e; } onEnterFrame = function() { movement = int(((_ymouse - (stageHeight/2))/-(stageHeight/2)) * speed); } |
| |
| | | kglad |  |
| Posted: Fri Aug 29, 2008 5:22 pm Post subject: Re: Height and Width of dynamic images |  |
you need to wait until loading is complete and the target initialized before accessing those properties.
you can either using preloader code with the loadMovie() method or use the onLoadInit() of the moviecliploader class. |
| |
| | | yombull |  |
| Posted: Sat Aug 30, 2008 12:18 am Post subject: Re: Height and Width of dynamic images |  |
Thank you, after I do the preloader, if I wanted to trace the height of the dynamic image, would I use this code:
trace(ref.marc.image._height); |
| |
| | | kglad |  |
| Posted: Sat Aug 30, 2008 4:05 am Post subject: Re: Height and Width of dynamic images |  |
no, you reference the target movieclip:
trace(ref.marc._height); |
| |
|
|