all groups > flash actionscript > september 2004 >
You're in the

flash actionscript

group:

Load and position image


Load and position image imsammyd
9/30/2004 11:54:14 PM
flash actionscript:
I am trying to dynamically load some images into a flash movie at runtime using
mc.loadclip(). I won?t know the size of the image because the images will be
chosen by the user. It doesn?t seem like I can position or scale the image to
fit?? If I do a mc._width or mc._height after the image loads it just returns
0. Is there any way to get info about the loaded content or possibly another
method to try?
Re: Load and position image _jrh_
10/1/2004 12:15:44 AM
Re: Load and position image imsammyd
10/1/2004 1:17:30 AM
Re: Load and position image _jrh_
10/1/2004 1:54:31 AM
Are you loading it via loadMovie() ? If so, are you loading it into a level or
an existing mc? If it's an existing mc, once you begin the load you can check
the load progress. I believe you can do the same with a level. I've never heard
of loadclip(). What version do you have?
Re: Load and position image imsammyd2 NO[at]SPAM yahoo.com
10/1/2004 5:22:25 PM
[quoted text, click to view]

I'm sorry for the confusion. I tried a couple things one being
MovieClip.loadMovie and the other being MovieClipLoader.loadclip(). I
am using 2004. I try to load the image into a movie clip which is
already on the stage. when I use the MovieClipLoader there is a
onLoadComplete listner, so I know when the clip is fully loaded and
the mc still has no height or width. The image does load however.
Below is the code I use:

var my_mcl:MovieClipLoader = new MovieClipLoader();
var my_listener:Object = new Object();
my_listener.onLoadError = function (mc) {
info_txt.text = "Error. An image did not load.";
};
my_listener.onLoadProgress = function (mc, loadedBytes, totalBytes) {
info_txt.text = Math.floor(loadedBytes/totalBytes * 100) + "%";
};
my_listener.onLoadComplete = function(mc){
info_txt.text = "";
trace(_root.mc._width);
trace(_root.mc._height);
}
my_mcl.addListener(my_listener);
Re: Load and position image imsammyd2 NO[at]SPAM yahoo.com
10/3/2004 6:36:55 PM
[quoted text, click to view]

I got a little further on this and was hoping that someone can help.
The above code was all in frame 1. That was all there was one frame
and one movieclip. so I added a new keyframe in frame 2 and moved the
trace statements for height and width there. so now it goes to frame
one, loads the image, goes to frame 2 and as usual displays 0, 0 for
height and width. Next it goes back to frame one and I guess it
re-executes the code above, but this time it displays the correct
height and width for the loaded content in frame 2. Does it have to
AddThis Social Bookmark Button