Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
load movie scaling with fixed ratio

load movie scaling with fixed ratio

2004-03-13       - By FODOR

 Back
Reply:     1     2     3  

Hi,

Since you are loading a swf in a mc that mc doesn't have any "size" . It is
that mc that will have to be resized to fit your desired screen area. So,
you first have to define your screen area and position, like for example:
<code>
screen_width=320;
screen_height=240;
//top-left corner:
screen_x=0;
screen_y=0;
//preload function ****************************************************
function preload_myMc(){//preload function that will resize the mc when
loaded and having retreived its size
   var loaded_bytes=container.getBytesLoaded();
   var total_bytes=container.getBytesTotal();
   if(loaded_bytes==total_bytes && total_bytes > 25 && container._width !=
undefined){
       clearInterval(preload_ID);
       delete preload_ID;
       //resize the mc to fit the desired screen area
       var
scale_ratio=Math.floor(Math.min(container._width/screen_width,container._hei
ght/screen_height)*100);//set the smaller possible ratio
       container._xscale=scale_ratio;
       container._yscale=scale_ratio;
       //center the container
       container._x=screen_x+((screen_width-container._width)/2);
       container._y=screen_y+((screen_height-container._height)/2);
   }else{
       //do something while waiting
   }
}
//**************************
container.loadmovie("my.swf");
preload_ID=setInterval(preload_myMc,50);
</code>
Hope this helps.

(13/03/04 2:59) Earl Arbuckle wrote:

>
> Please don't scream at me - I know this has been discussed - I looked in
> the archives and found information on scaling but nothing that helps me
> keep my loaded movie from 'skewing'.
>
> Simply, I want to do a container.loadmovie("my.swf") and have my.swf
> expand to cover the same area of 'container' but keeping the same ratio
> so the loaded movie isn't skewed (stretched along the horizontal or
> vertical axis).
>
> Pointers to tutorials or other information would be greatly appreciated!
>
> Thanks
> Earl Arbuckle
>
>
>
> =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
> Supported by Fig Leaf Software
> =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
> Be sure to check the archives and the wiki:
> http://chattyfig.figleaf.com/
> =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
> http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106821
> =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
> To unsubscribe send a blank e-mail to:
> Normal Mode: flashcoders-unsubscribe@(protected)
> Digest Mode: flashcoders-digest-unsubscrive@(protected)
>

-- ---- ---- ---- ---- ---- ---- ---- ----
Pascal FODOR

-- ---- ---- ---- ---- ---- ---- ---- ----
fodor@(protected) // flash@(protected)

******************************************
Visit: http://fodor.liane.net

Flash AV Players can be seen at:
http://fodor.liane.net/flash_AV_players/
******************************************














=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106828
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)