dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [CS3][AS2] Hello with this 100% flash website code

  1. #1
    Senior Member
    Join Date
    Dec 2007
    Posts
    121

    [CS3][AS2] Hello with this 100% flash website code

    Hi all,

    this has always been haunting me for a while, I mean doing a 100% Flash website, which takes the browser.

    I've been able to make the Background take the browsers width and height at 100% using this code

    Code:
    Stage.align = "TL";
    Stage.scaleMode = "noScale";
    
    setProperty(bg_mc, _width, Stage.width);
    setProperty(bg_mc, _height, Stage.height);
    
    var resizeListener:Object = new Object();
    Stage.addListener(resizeListener);
    
    resizeListener.onResize = function () {
         setProperty(bg_mc, _width, Stage.width);
         setProperty(bg_mc, _height, Stage.height);
    };

    For the Bground its ok, but on a layer above the background layer, I have a movieclip (cover_mc) which contains some graphics for a website. What i want to do is

    When I resize the broswer, also resize the movieclip cover_mc to fit the users screen and to keep it centered.

    I have the Fla Attached as a zip file, can someone please help me wiz it? I going mad with this since i've never made a 100% flash !
    Attached Files Attached Files

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    PHP Code:
    Stage.align "TL";
    Stage.scaleMode "noScale";

    //size bg_mc to match stage size
    bg_mc._width Stage.width;
    bg_mc._height Stage.height;
    //position cover_mc in middle of stage
    cover_mc._x Stage.width/cover_mc._width/2;
    cover_mc._y Stage.height/cover_mc._height/2;

    var 
    resizeListener:Object = new Object();
    Stage.addListener(resizeListener);
    resizeListener.onResize = function() {
        
    //size bg_mc to match stage size
        
    bg_mc._width Stage.width;
        
    bg_mc._height Stage.height;
        
    //position cover_mc in middle of stage
        
    cover_mc._x Stage.width/cover_mc._width/2;
        
    cover_mc._y Stage.height/cover_mc._height/2;
    }; 
    if you want the cover_mc to match the size of the stage..do the same thing you are doing for the bg_mc..

  3. #3
    Senior Member
    Join Date
    Dec 2007
    Posts
    121
    thanks for replying.

    Look at what happened to the contents area, it's not resizing itself to the browser resolution

    http://mu-anime.com/patrimoines/flashindex.html

  4. #4
    Senior Member
    Join Date
    Dec 2007
    Posts
    121
    i still can figure out how to resize the cover_mc when the broswer is resize.

    here is the code im using

    Code:
    stop();
    
    // noScale prevents content in the movie resizing (unless we tell it to!)
    
    Stage.scaleMode = "noScale";
    Stage.showMenu = false;
    // LT 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_mc.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_mc);
    bg_mc._x = bg_mc._y = 0;
    bg_mc.onResize();
    
    //trace(bg_mc._height);
    
    cover._x = Stage.width/2;
    cover._y = Stage.height/2;
    
    
    
    cover.onResize = function(){
    	this._x = Stage.width/2;
    	this._y = Stage.height/2;
    }
    
    Stage.addListener(cover);
    cover.onResize();

  5. #5
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    first of all...your not even, anywhere in your code (unless I missed it) are you even trying to set the cover_mc height and width??!!

    your adding listeners..here and there...and everywhere..


    try something like this:

    PHP Code:
    //start Stage re-size code
    Stage.align "TL";
    Stage.scaleMode "noScale";
    // ---> Create a new listener object
    var stageListener:Object = new Object();
    // ---> Define the resize function...
    stageListener.onResize = function() {
        
    // ---> first, get the new dimensions of the stage....
        
    var stageWidth:Number Math.round(Stage.width);
        var 
    stageHeight:Number Math.round(Stage.height);
        
    //position bg_mc
        
    bg_mc._x = (stageWidth 2) - (bg_mc._width 2);
        
    bg_mc._y = (stageHeight 2) - (bg_mc._height 2)
        
    //scale bgc_mc
        
    bg_mc._width stageWidth;
        
    bg_mc._height stageHeigh;
        
    //position cover_mc
        
    cover_mc._x = (stageWidth 2) - (cover_mc._width 2);
        
    cover_mc._y = (stageHeight 2) - (cover_mc._height 2)
        
    //scale cover_mc
        
    cover_mc._width stageWidth;
        
    cover_mc._height stageHeight;

    };
    // --->  Apply the listener...
    Stage.addListener(stageListener);
    // ---> Run the function...
    stageListener.onResize(); 

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