Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Results 1 to 2 of 2

Thread: Help Proportional scaling MovieClips relative to stage

  1. #1
    Junior Member Settled In terraform is on a distinguished road
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Help Proportional scaling MovieClips relative to stage

    amazing Flash templates
    Hello
    I need some assistance on how to proportionally scale multiple movieClips relative to the stage size.

    I understand movieclip placement relative to the stage, and I have been using a code to scale MovieClips as a fullscreen background (also proportionally)

    But

    I can not figure out for the life of me how to scale other movieclips in relation
    to the stage size.

    for example I have a background_mc that proportionally scales with the stage
    to fill without distortion.

    HOW do I then place another MC say center aligned (I know how to do that) that will scale with the background without distortion?

    Ideally I would like to place several MC's on my stage all scaling in proportion with the stage yet independently.

    I have not been able to find any documentation on this.
    lots of tutorials on backgrounds and color fills and the like but nothing
    on proportional scaling of independent mc's

    this is the code I use for my background_mc (can it be modified or should it be thrown out the window to achieve independent scaling?)

    Code:
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    
    
    //function to handle background image resize.
    function setBackground() {
    	var reg2 = stage.stageWidth / 2;
    	var reg1 = stage.stageHeight / 2;
    	bg_mc.x = reg2;
    	bg_mc.y = reg1;
    	bg_mc.width = stage.stageWidth;
    	bg_mc.height = stage.stageHeight;
    	bg_mc.scaleX <= bg_mc.scaleY ? (bg_mc.scaleX = bg_mc.scaleY) : (bg_mc.scaleY = bg_mc.scaleX);
    	
    }
    setBackground();
    
    function resizeHandler(event:Event):void {
    	setBackground();
    thanks

  2. #2
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,449
    Rep Power
    8

    Re: Help Proportional scaling MovieClips relative to stage

    Hi,
    try this one:
    Code:
    private function scaleProportional():void 
    {
    	var newHeight=my_mc.height/my_mc.width;
    	var newWidth=my_mc.width/my_mc.height;
    
    	if((stage.stageHeight/stage.stageWidth)<newHeight)
    	{
    		my_mc.width=stage.stageWidth;
    		my_mc.height=newHeight*my_mc.width;
    	} 
    	else
    	{
    		my_mc.height=stage.stageHeight;
    		my_mc.width=newWidth*my_mc.height;
    	}
    }

+ Reply to Thread

Similar Threads

  1. Tweening Movieclips
    By xPINKMERCEDESx in forum advanced Actionscript 3.0
    Replies: 1
    Last Post: 6 Days Ago, 22:40
  2. movieClips Ricorsivi
    By rivo900 in forum Actionscript 3.0 base
    Replies: 2
    Last Post: 31-01-10, 22:36
  3. Pre-loading MP4 + fixed scaling - HELPZORZ!
    By Zombie in forum Actionscript 3.0 newbies
    Replies: 6
    Last Post: 29-09-09, 20:59
  4. Adressing MovieClips
    By hard_overclocker in forum Flash English
    Replies: 3
    Last Post: 07-10-07, 07:09
  5. Replies: 0
    Last Post: 23-09-07, 13:05

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Optimization by vBSEO