A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Auto resizing loaded SWF

  1. #1
    Junior Member
    Join Date
    Apr 2000
    Posts
    1

    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

  2. #2
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    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)
        
    false;
        
    // this is the trigger
        
    myDriver.onEnterFrame = function() {
            var 
    myLoader.getBytesTotal();
            var 
    myLoader.getBytesLoaded();
            if(
    == && && p) {
                
    resizeBanner();
            }
            
    true;
        };
    }
    // this resizes your movie
    function resizeBanner() {
        
    myLoader._width 600;
        
    myLoader._height 70;

    Cheers
    Altruism does not exist. Sustainability must be made profitable.

  3. #3
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    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

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center