A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: background scaling problem here. advice, plz?

  1. #1
    user in A minor
    Join Date
    Jan 2005
    Location
    finland
    Posts
    121

    background scaling problem here. advice, plz?

    hi.

    i'd really appreciate if someone would care to give this a thought and help me out! i found advice in a thread here of how to make a scalable background, that is a background mc (bg) that always scales to fill all screens and content mc (content) that doesn't scale and stays always centered when resizing screen, holding the main movies.

    my trouble is that the movie that should stay centered does not always do so when i resize the screen. to begin with it's ok, but when i alter screen size the content mc often gets stuck on top of the screen, and the only way i can get it back is to refresh the whole page.

    i can't solve the problem myself. i add the code i'm using here. how should i alter it? or is there any smarter way to achieve the desired effect? a simple uniform bg will not be enough for my chosen page design... i'm using flash 8, mozilla and ie for testing.

    thanks for shredding light into my darkness

    Code:
    // noScale prevents content in the movie resizing (unless we tell it to!)
    Stage.scaleMode = "noScale";
    
    // TL means all positions measured from the top left hand corner
    Stage.align = "TL";
    
    // a function to be called when the movie resizes
    // this will resize the background clip to fill the stage
    bg.onResize = function() {
        this._width = Stage.width;
        this._height = Stage.height;
    };
    // get the bg clip to listen for events (onResize) 
    // broadcast by the stage object
    Stage.addListener(bg);
    
    bg._x = bg._y = 0;
    bg.onResize();
    
    // this function will position the content clip in the centre
    // when the movie resizes
    content.onResize = function() {
        this._x = (Stage.width - this._width) / 2;
        this._y = (Stage.height - this._height) / 2;
    };
    Stage.addListener(content);
    content.onResize();

  2. #2
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Try posting this in Flash Actionscript Help Forum... More helpful see.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  3. #3
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey mrk13,

    It works fine for me , simply make your background movieclip and give it an instance name of 'bg' (without the qoutes)

    Run it and see what happens

  4. #4
    user in A minor
    Join Date
    Jan 2005
    Location
    finland
    Posts
    121
    hi, osteel: i've done just that. my problem is that still, in my testing browsers, the thing works fine at first, but if i for some reason want to resize screen while viewing, the content movie gets glued to the top of screen. that's not very cool, is it... everything does look ok to begin with, though, so that's why i'm puzzled.

    tonxgn: point taken: i'll post this in actionscript forum next, so that's where you'll find this thread's part two.

    thanks for advice to u both
    Last edited by mrk13; 12-21-2005 at 03:08 PM. Reason: spelling mistharghkes

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