Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Height and Width of dynamic images

 
Jump to:  
 
yombull
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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);
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

prawo jazdy cieżarówki lokata Jokes wizz air