Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Old 07-29-2005, 03:28 PM   #1
gradey
Registered User
 
Join Date: Jul 2005
Posts: 1
Default Loading Dynamic Images, Preserving Aspect Ratio

Hello
Please help...

Firstly, I need to dynamically load many images of different sizes in sequence - (I can do that part). But I also want the aspect ratio of my images to remain intact. This is the part that I have been having such trouble with. From what I've picked up, it seems that Flash does not recognise that new images are being loaded and does not treat each one as a new object and therefore does not change the scaleMode, but I'm not sure.

This is my code that loads the images. I have taken out all the ScaleMode stuff because none of it works.

ActionScript Code:
stop(); var the_loader:MovieClipLoader = new MovieClipLoader(); var the_listener:Object = new Object(); the_listener.onLoadInit = function(mc) {     trace("loaded");              mc._x = 0;     mc._y = 0;     mc._width = 780;     }; the_loader.addListener(the_listener); myAdd = "0"; function wait() {     // a function called 'wait'     the_loader.loadClip("image"+(Number(myAdd++)+1)+".jpg", 1); } myTimer = setInterval(wait, Number(2*1000)); // calls the function after 2 seconds

Could anyone help me or send me in the right direction. I have tried hard to find the answer, but I can't.

Thank you.

Gradey.
gradey is offline   Reply With Quote
Old 07-29-2005, 08:55 PM   #2
Navarone
Don
 
Navarone's Avatar
 
Join Date: Feb 2003
Location: Akron, Ohio USA
Posts: 1,897
Default

ok, here is what I did for a similar situation. My setup included loading images of various sizes and creating thumbnails of each. My thumb_nail size was 65 pixels wide x 65 pixel tall, but the movieclip I was loading it into was 75x75. There are three problems that present itself that have to be solved. First is knowing the image sizes before any actions take place and then 2nd,what to do about images where the width is greater than the height and 3rd, those images where the height is greater than the width. This is the formula I came up with.
ActionScript Code:
//////////////////////////////////////////////////////////////// var MAX_WIDTH:Number = 65; var MAX_HEIGHT:Number = 65; var mclListener:Object = new Object(); mclListener.onLoadInit = function(mc:MovieClip) {     // set variables to keep the original image dimensions     var xw = mc._width;     var xh = mc._height;     //trace(xw);     //trace(xh);     // where image width is greater than image height     if (mc._width>mc._height) {         mc._width = MAX_WIDTH;         mc._height = (mc._height*MAX_WIDTH)/xw;         // center image         mc._y = (75-mc._height)/2;     }     //where image height is greater than image width     if (mc._height>mc._width) {         mc._height = MAX_HEIGHT;         mc._width = (mc._width*MAX_HEIGHT)/xh;         mc._x = (75-mc._width)/2;     }     //trace(mc._width);     //trace(mc._height);     //trace("done"); }; //////////////////////////////////////////////////////////////////
__________________
Damn the torpedoes! Full speed ahead.
Navarone is offline   Reply With Quote
Old 08-23-2005, 04:48 AM   #3
xxlm
Meuh? MMeuh!
 
xxlm's Avatar
 
Join Date: Sep 2001
Location: Auckland - New Zealand
Posts: 3,049
Send a message via ICQ to xxlm Send a message via AIM to xxlm Send a message via MSN to xxlm Send a message via Yahoo to xxlm
Default

Pls give the name of the people who codes belongs to (even if code is belonging to noone )

:P

C ya mate
__________________
I'm a froggy, so excuse me for my poor english
Blog - Dev By MX
For any jobs go on my blog on the contact page...
xxlm is offline   Reply With Quote
Old 08-23-2005, 07:06 AM   #4
yougart
Registered User
 
Join Date: Aug 2005
Posts: 6
Default

If I use this code to load the image
ActionScript Code:
_root["mc"+i].loadMovie(this["bild"+i]);
can someone pls help me edit this so I can set my heigh to 120 and weight to 90.

//N
yougart is offline   Reply With Quote
Old 08-23-2005, 08:14 AM   #5
james@ba
Registered User
 
Join Date: Aug 2005
Posts: 9
Default

try
ActionScript Code:
with(_root["mc"+i]){ _width = 100;//or desired value _height = 100;//or desired value }

Last edited by james@ba; 08-23-2005 at 11:15 AM..
james@ba is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.
You Rated this Thread: