I need to get the resized Width and Height of children in a resized parent. I have an image that is 1080 x 612. I put that in a MovieClip called "stackoverflowLOGO". That is the child width/height I need and it is inside a class called stackOne.
My Stage is set to 500 # 700 First I resize stackOne and check the width and height and they come out with the correct values. This can be seen in image #1. Here is the code to get these values
stackOne = new stackoverflowClass();
stackOne.width = screenX;
stackOne.scaleY = stackOne.scaleX;
addChild(stackOne);
// Width was 1080 and is now 500
stackOne.imageWidth.text = "" + stackOne.width + "";
// Height was 1920 and is now 283.35
stackOne.imageHeight.text = "" + stackOne.height + "";
However when I check the height of an MovieClip inside of the parent that is scaled. The values do not change. I REALLY need to know how to get the actual size of the children inside of scaled MovieClips.
Here is the code that checks the width/height of the child inside of a scaled Movieclip. This is the part of the code that does not work.
stackTwo = new stackoverflowClass();
stackTwo.width = screenX;
stackTwo.scaleY = stackTwo.scaleX;
addChild(stackTwo);
// Was 1080 and still is 1080 even tho the size has been scaled.
stackTwo.imageWidth.text = "" + stackTwo.stackoverflowLOGO.width + "";
// Was 1920 and still is 1920 even tho the size has been scaled.
stackTwo.imageHeight.text = "" + stackTwo.stackoverflowLOGO.height + "";
Here is a screenshot:
I am also including the full code below. Here is a zip file of the fla and the two classes used.
Here is the full code in the MainStack Class:
package
{
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.system.Capabilities;
import stackoverflowClass;
public class MainStack extends MovieClip
{
public var screenX:int;
public var screenY:int;
public var stackOne:stackoverflowClass;
public var stackTwo:stackoverflowClass;
public function MainStack()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
screenX = stage.fullScreenWidth;
screenY = stage.fullScreenHeight;
firstStack();
secondStack();
}
public function firstStack()
{
stackOne = new stackoverflowClass();
stackOne.width = screenX;
stackOne.scaleY = stackOne.scaleX;
addChild(stackOne);
stackOne.imageWidth.text = "" + stackOne.width + "";
stackOne.imageHeight.text = "" + stackOne.height + "";
}
public function secondStack()
{
stackTwo = new stackoverflowClass();
stackTwo.width = screenX;
stackTwo.scaleY = stackTwo.scaleX;
addChild(stackTwo);
stackTwo.imageWidth.text = "" + stackTwo.stackoverflowLOGO.width + "";
stackTwo.imageHeight.text = "" + stackTwo.stackoverflowLOGO.height + "";
stackTwo.y = stackOne.height;
}
}
}