Skip to main content
Participating Frequently
November 14, 2009
Answered

proportionate the image in flash

  • November 14, 2009
  • 2 replies
  • 635 views

Hello all,

i had a xml wich is dynamically genrate the values, and i use those value to show as a image in flash as2.

now the values are n numbers, if it is beyound the screen i want to resize the whole image in to best fit on my screen.

I have attached the source file, advance thanks for the help

This topic has been closed for replies.
Correct answer Ned Murphy

Hello all two things i need...

one is iam having a xml, with the help of xml values iam doing attachMovie to display movieClip in a screen.

1. i need how display the images inside the movieclip

2. and how to resize that movieclip to fit on any screen without scroll

for to know more about the Objective i have attache the source file 1. fla 2. xml


In the code below I show red code which places the pieces inside another movieclip and then resizes it to half its width.  I know you want it to size to fit in the stage, but I don't know to what dimensions, so hopefully you can determine that math for yourself and adjust the width and height accordingly.  It would essentially involve first determining the height/width ratio after the assembly is complete, then changing the width to the desired width, and then using the height/width ratio to set the revised height for the revised width.  And you could keep the holder_mc invisible until all of this is complete if you prefer.

unit_mc._visible = false;
_root.createEmptyMovieClip("holder_mc", this.getNextHighestDepth()); // create the holding mc
////////////////////////////////////////////////////////
//////////////////////loading xml///////////////////////
////////////////////////////////////////////////////////
var myXml:XML=new XML();
myXml.ignoreWhite = true;
myXml.load("sampleInput.XML");
myXml.onLoad = function(success)
{
if (success)
   {
var poc=myXml.firstChild;
//trace(poc.attributes.id);
var tower=myXml.firstChild.childNodes;
//trace(tower.length);
var noOfTower=tower.length;
for(i=0;i<noOfTower;i++)
     {
var group=myXml.firstChild.firstChild.childNodes;
var noOfGroup=group.length;
//trace (group);
//trace(noOfGroup);
//trace(towerId);
for(j=0;j<noOfGroup;j++)
      {
var groupId = group.attributes.id;        
//trace (groupId);   
Setting();
     }
    

     }
   }
   holder_mc._width = 0.5*holder_mc._width; // resize the holding movieclip
};
///////////////////////////////////////////////////////
///////////////////end of loading xml//////////////////
///////////////////////////////////////////////////////
  Setting=function()
  {   
  var curritem1;
  var depth=i+(j*100);
  curritem1 = holder_mc.attachMovie("menuitem","_mc",depth); // add the xml pieces
  curritem1._x=10+(i*160);
  towerheight=curritem1._height;
  curritem1._y=560-((j*(towerheight-20)));
  };

2 replies

November 14, 2009

Hi,

Add the images in scrollpane or add the scroll bar for the images to avoid the unfit

Saransoft

Ned Murphy
Legend
November 14, 2009

Do you load all of these things into a single movieclip?  If so, then after you have finished loading things, you need to resize the movieclip.

Participating Frequently
November 14, 2009

thanks for your guidance,

please explain me how can we resize the movieclip as best fit in any screen.

Participating Frequently
November 14, 2009

the objective is we should not use scroll in this page......