Set the size of visual components using action script in Flex4


 

Set the size of visual components using action script in Flex4

In this tutorial you can see how to set Size for a visual component in action script code in Flex 4

In this tutorial you can see how to set Size for a visual component in action script code in Flex 4

Set the size of Visual Components using Action Script in Flex4:

In this tutorial you can see how to set Size for a visual component in action script code in Flex 4.

Example:

 

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init();">

<fx:Script>

<![CDATA[

public function init():void{

myButton.width = 120;

myButton.height = 30;

mysButton.percentHeight = 20;

mysButton.percentWidth = 90;

}

]]>

</fx:Script>

<s:Panel width="240" height="100" title="Set Size for Button in AS Example">

<mx:HBox>

<s:Button id="mysButton" label="Spark Button"/>

<mx:Button id="myButton" label="MX Button"/>

</mx:HBox>

</s:Panel>

</s:Application>

In this example we have create two button controls and set id property for these button components. After that we have create a method with name init() and set the property width and height for <mx:Button/> control and set percentWidth and percentHeight for <s:Button/> control on the bases of these id properties. After that call this method on the creationComplete property.

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Ads