A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: SCALE Movieclip on BROWSER resize

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Location
    Melbourne, Australia
    Posts
    2

    SCALE Movieclip on BROWSER resize

    'Ello chaps

    Looking for someone to help with a bit of AS3 code. I'm trying to do a full browser website but have run into a few problems with the background movieclip.

    What I'd to do is have the background scale according to the size of the browser like on the Samsung Australia website.

    You'll notice that when you resize your browser, the image doesn't 'distort', but keeps the same proportions.

    I'm aware this is possible if you just publish it with the HTML>Percent>100 thing. but it also forces every other MC to scale along with the resize. Is there a way to only have the background MC resize through AS3?

    Thanks in advance for any help!

  2. #2
    Junior Member
    Join Date
    Apr 2010
    Posts
    18
    You will need to access the stage.

    Import the needed classes.

    Actionscript Code:
    import flash.display.StageDisplayState;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;


    Set your registration point for the stage. And set the stage scaleMode.

    Actionscript Code:
    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;

    Now when a user resizes the window objects will not move nor resize.

    To make the background resize position it on the stage, and make sure it has it's registration mark in the top left. Place this Background MovieClip on the stage at x:0, y:0.


    Add a listener for the stage resize event.

    Actionscript Code:
    this.stage.addEventListener ( Event.RESIZE, this.resizeBG);


    Then add your function that resizes the MovieClip, I call it "BG" here

    Actionscript Code:
    private function resizeBG( evt : Event ) : void {
               
        var w : int = this.stage.stageWidth;
        var h : int = this.stage.stageHeight;
               
        this.BG.width = w;
        this.BG.scaleY= this.BG.scaleX;
               
    }

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