Resizes the component to the requested size. If the scaleContent property is set to true, the UILoader is not resized.
import fl.containers.UILoader;
var myUILoader:UILoader = new UILoader();
myUILoader.source = "http://www.helpexamples.com/flash/images/image2.jpg";
myUILoader.addEventListener(Event.COMPLETE, completeHandler);
addChild(myUILoader);
function completeHandler(event:Event):void {
var uiLdr:UILoader = event.currentTarget as UILoader;
var image:DisplayObject = uiLdr.content as DisplayObject;
trace("UILoader:", uiLdr.width, uiLdr.height); // 100 100
trace("UILoader.content:", image.width, image.height); // 400 267
uiLdr.setSize(image.width, image.height);
uiLdr.move((stage.stageWidth - image.width) / 2, (stage.stageHeight - image.height) / 2);
}
Adobe Flex is a software development kit released by Adobe Systems for the development and deployment of cross-platform rich Internet applications based on the Adobe Flash platform. Flex applications can be written using Adobe Flex Builder or by using the freely available Flex compiler from Adobe.
Showing posts with label resize. Show all posts
Showing posts with label resize. Show all posts
Saturday, September 10, 2011
Monday, June 6, 2011
scaleContent property is true, but the UILoader is not resized ?
Resizes the component to the requested size. If the scaleContent property is set to true, the UILoader is not resized.
import fl.containers.UILoader;
var myUILoader:UILoader = new UILoader();
myUILoader.source = "http://www.helpexamples.com/flash/images/image2.jpg";
myUILoader.addEventListener(Event.COMPLETE, completeHandler);
addChild(myUILoader);
function completeHandler(event:Event):void {
var uiLdr:UILoader = event.currentTarget as UILoader;
var image:DisplayObject = uiLdr.content as DisplayObject;
trace("UILoader:", uiLdr.width, uiLdr.height); // 100 100
trace("UILoader.content:", image.width, image.height); // 400 267
uiLdr.setSize(image.width, image.height);
uiLdr.move((stage.stageWidth - image.width) / 2, (stage.stageHeight - image.height) / 2);
}
import fl.containers.UILoader;
var myUILoader:UILoader = new UILoader();
myUILoader.source = "http://www.helpexamples.com/flash/images/image2.jpg";
myUILoader.addEventListener(Event.COMPLETE, completeHandler);
addChild(myUILoader);
function completeHandler(event:Event):void {
var uiLdr:UILoader = event.currentTarget as UILoader;
var image:DisplayObject = uiLdr.content as DisplayObject;
trace("UILoader:", uiLdr.width, uiLdr.height); // 100 100
trace("UILoader.content:", image.width, image.height); // 400 267
uiLdr.setSize(image.width, image.height);
uiLdr.move((stage.stageWidth - image.width) / 2, (stage.stageHeight - image.height) / 2);
}
Sunday, December 7, 2008
Automatically resize Text/TextArea based on content (autoSize) in Flex
Automatically resize Text/TextArea based on content (autoSize) in Flex
by Nicolas Noben
UPDATE: turns out that doesn’t always work. the autoSize property is not reliable at all…
This, should do!
var ta_height:uint = 25;
field.validateNow();
for(var i:int=0; i < field .mx_internal::getTextField().numLines; i++) {
ta_height += field.mx_internal::getTextField().getLineMetrics(i).height;
}
derivedHeight = ta_height;
Thanks Vaan.
Original post:
Adobe’s dodgy textHeight sure doesn’t do the trick. I end up getting a textfield of 2000px height while it clearly looks like 300 tops.
This, however, works.
the code
private function resizeMe(field:TextArea) :void
{
field.validateNow();
field.mx_internal::getTextField().autoSize = TextFieldAutoSize.LEFT;
field.height = field.mx_internal::getTextField().height;
}
Just use that on your TextArea or Text component:
creationComplete="resizeMe(this.myTextAreaInstance)"
Subscribe to:
Posts (Atom)
Freelance
Find more freelance jobs