Showing posts with label Label ActionScript. Show all posts
Showing posts with label Label ActionScript. Show all posts

Wednesday, August 4, 2010

Flex Framework Label with ActionScript


Flex Framework Label with Actionscript

Aim:

We use label and button UI components. We click on OK button the message “Hello Flex Framework” will be displayed.      

Procedure:

            Step 1:

                        Create Project FlexPro. Using eclipse.

                        From previous post, we can understand how to create project.

            Step 2:

                        Create File LabelScript.mxml

                        Include following coding into the LabelScript.mxml

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

< mx:Application xmlns:mx = 'http://www.adobe.com/2006/mxml' >
< mx:Script >
< ![CDATA[
private function display1(event:Event):void
{
display.text="Hello Flex Framework";
}
]] >
< /mx:Script >
< mx:Panel title="Label Demo Plus ActionScript"
height="500" width="500"
backgroundColor="Blue" >
< mx:Label text="" id="display" color="Red" fontSize="25"/ >
< mx:Button label="OK" click="display1(event);"/ >
< /mx:Panel >
< /mx:Application >














Note:

We use click property in button component, so we click on OK button the display1 function will be called. In display1 function, we assign the Hello Flex Framework.

We include actionscript coding between

< mx:Script >

< /mx:Script >

< mx:Script >
< ![CDATA[
private function display1(event:Event):void
{
display.text="Hello Flex Framework";
}
]] >
< /mx:Script >

Step 3:

Include following coding into the build.xml
….
< exec executable='${compiler}' failonerror='true' >
< line='-output F:\FLEXWORKSPACE\FlexPro\LabelScript.swf' / >
< line='F:\FLEXWORKSPACE\FlexPro\LabelScript.mxml' / >
< /exec >
….












Step 4:

          Run the Application

Click build.xml

Inside build.xml

Right click inside build.xml and select Run As – 1 Ant build

















Step 5:

          Goto the where you stored LabelScript.swf file.

          Open LabelScript.swf in any Browser.

          You get output like below



















You click OK button “ Hello Flex Framework “ message will be displayed like   below