RSS
email

Button Events in Flex2.0



Create new Flex project in flex editor..select basic radio and choose next then enter project name and finish..


Wow you are in flex coding part

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button id="button1" label="Click me" x="100" y="100" />
</mx:Application>


this is way for creating button in flex we have given

id name which is used to refer the button later in actionscript or mxml

Label is the text displayed in Button

Then x y values to position button



Handling Events


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import flash.net.URLLoader;
import flash.net.URLRequest;
public function launch(evt:MouseEvent):void{

navigateToURL(new URLRequest("http://sara-intop.blogspot.com"));

}
]]>
</mx:Script>
<mx:Button id="button1" label="Click me" x="100" y="100" click="launch(event)"/>
</mx:Application>



Here we are going to write our button handler using Actionscript using mx:script tag
we are calling launch method in click event.

and navigating to url similar to getURL in flash8

Bookmark and Share

0 comments:

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.