-
Load image using loadMovie - Can you dynamically change the image size?
Hello,
Is it possible to dynamically change the size of an image that is loaded into flash using the loadMovie function?
loadMovie("/images/tripOne/image1.jpg", "image1MC");Regards
Rob
-
Senior Member
Sure is. Just wait for the movie to load, then you can access its properties like any other movieclip, ie.
image1MC._width = 100;
image1MC._height = 400;
The future belongs to those who prepare for it today.
-
you have to be careful with this though. when you create the blank movie clip, the size will be 0, 0 if i am not mistaken. But after it's loaded, it because the dimensions of the picture. So if you wish to resize this using _xscale and _yscale you may have a hard time, because you can't just do it right after loadMovie.
You should read up on listeners, particularly onLoadInit(). onLoadInit, if proper requirements are set up, is called after the picture is loaded.
Anyway, check out the help panel in flash.
-
Re-scaling a .jpg in Flash, although possible, ain't a very good idea in the first place, and isn't recommended!
My 2 cents!
-
may i ask why? is it the performance issues?
-
Double compression and quality loss!
-
Bhanu Shankar
Originally Posted by devnull_2k
Sure is. Just wait for the movie to load, then you can access its properties like any other movieclip, ie.
image1MC._width = 100;
image1MC._height = 400;
I am picking up an image from online and loading it and my code is below
loadMovie("http://xxx.yyy.com/thumb.jpg", cover);
cover._width = 117;
cover._height=156;
The actual size of thumb image is more than I re-sized in my code. 'cover' is an empty movie clip.
It doesn't work at all. The thumb image is not displayed with the new dimension. If I remove AS line 2 (width) and line 3 (height), the thumb image is displayed.
-
.
Hi,
The image needs to be loaded before you can mess around with its dimensions.
so you need to use movieClipLoader()
its quite easy to decipher it.
Actionscript Code:
myLoader = new MovieClipLoader(); myPreload = new Object(); myLoader.addListener(myPreload);
myPreload.onLoadStart = function(Target) { // Do what ever you like; }
myPreload.onLoadProgress = function(Target, lBytes, tBytes) { Percent = Math.round((lBytes / tBytes) * 100) loading.text = Percent + "% Loaded"; }
myPreload.onLoadComplete = function(Target) { loading.text = "Complete"; }
myPreload.onLoadInit = function(Target) { cover._x = 20; cover._y = 20; cover._width = 100; cover._height = 100; }
myLoader.loadClip("http://xxx.yyy.com/thumb.jpg", cover);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|