Flash HELP!
- Started
- Last post
- 11 Responses
- springbok
Hi Guys,
I have been working on this flash gallery all night now and cant seem to figure out how to get the external images to display in the flash with different widths. Currently the image width is specified in the xml and hard coded. I just want to flash to recognize the image widths and position the x position accordingly.
Can anyone help?Many many thanks in advance
the files are here;
- kingsteven0
Don't have time to look at the code but have you tried loading them in to a container clip and doing something like:
//position the image so that the center of the clip is at 0,0
container.image._x = -image._width/2;
container.image._y = -image._height/2;//then position the container mc:
container._x = Stage.width/2; //image will be centered horizontally
container._y = Stage.height/2; //image will be centered vertically
- kingsteven0
oeps should be:
container.image._x = -container.image._width/2;
container.image._x = -container.image._width/2;
- fyoucher10
Also, make sure the image is loaded before applying any code to it. You might be calling code on something that doesn't exist yet.
- yes, probably this. oof i'm so glad i don't have to think about this shit any more.kingsteven
- springbok0
The images are positioned like this;
for (i=0; i<_root.myImagesTotal; i++) {
imageURL = _root.myImages[i].attributes.url...
image_mc = _root.myImages_mc.createEmptyMov... _root.myImages_mc.getNextHighest...
image_mc._x = _root.image_width*i;myMCL.loadClip(imageURL,image_mc...
}
- fyoucher10
Looks like the prob I mentioned above.
Looks like ur using AS2.
Look up the MovieClipLoader Class and it's events in the help section, specifically onLoadComplete.
- kingsteven0
looks like fyoucher1 is right... look up onLoadInit in the MovieClipLoader documentation.
- or onLoadClomplete they'll both do the same thing in this case.kingsteven
- Jinx!fyoucher1
- springbok0
Cool will do
Thanks
- springbok0
still no luck with this guys any more suggestions?
- funkage0
Try the MovieClipLoader Class.
Assuming you're loading your image into a MovieClip by the name of 'image_mc':var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();mclListener.onLoadInit = function(target:MovieClip) {
trace(target._width);
trace(target._height);
// You should get both values, and do whatever you want to do to the image here.
}mcl.addListener(mclListener);
mcl.loadClip("01.jpg", image_mc);
- PonyBoy0
funkage has it...
... gotta wait for the full image to load which will fire 'onLoadInit'... else - if the image isn't 'there'... you can't capture it's width / height. :)
- monNom0
width and height will only be available 1 frame after the load complete event fires.
get around this by setting a loop to check for width until it returns something.eg:
if(myClip.width){
clearInterval(myInterval);
}