-
Auto resizing loaded SWF
Hey Everyone,
I have checked the BBS for similar situations and there are many. My problem is simple. I have a mask that I'm loading advertisements into. The blank MC is called movie1. The mask is set to 600 x 70 and I want the MC to automatically resize any loaded swf of any size to fit into this 600 x 70 space.
Must I have a preloader for this or can I just dynamically have the MC resize the loaded SWF?
Example, having the MC take a 750 x 90 SWF and resize it to 600 x 70 on the fly. Any help?
You can see my ads at http://w-p.biz/eng/home.htm
Thanks.
Daren
-
Product Designer
The issue is quite simple:
to resize a movieclip you must know it's dimensions, but you can't know them unless the external movie has fully loaded into your loader movieclip right?
so yes, you do need a very simple preloader, just enough to trigger a script as soon as the movie has finished loading.
the other thing you need is a script that resizes your loaded movie...there are various ways to do it (and it gets just slightly more complex if you want to mantain the aspect ratio, but in your case you don't, right?)...a very, very simple way is just to set it's _width and _height properties to the desired values...
so here is what we get (myDriver is a movieclip that we use to control preloading, myLoader is a movieclip we use to load movies into..)
PHP Code:
// to load a movie you use myLoadMovie("path_to_file");
_global.myLoadMovie = function(f) {
// actually calls a load action for your movie
myLoader.loadMovie(f);
// this is to make the driver start working only
// at the next refresh (to avoid bugs)
p = false;
// this is the trigger
myDriver.onEnterFrame = function() {
var t = myLoader.getBytesTotal();
var l = myLoader.getBytesLoaded();
if(t == l && l > 0 && p) {
resizeBanner();
}
p = true;
};
}
// this resizes your movie
function resizeBanner() {
myLoader._width = 600;
myLoader._height = 70;
}
Cheers
Altruism does not exist. Sustainability must be made profitable.
-
Senior Member
Without a preloader you can also just put this ON the movie1 mc...
onClipEvent(load){
this._height=70;
this._width=600;
}
It wil resize any loaded swf
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
|