LetsFlex

button click handler with alert window using AS3

by jlagunas on Jul.22, 2008, under Actionscript

The following example shows you how to listen for a button click and show an alert window using actionscript 3.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp(event);" viewSourceURL="srcview/index.html">

	<mx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.controls.Alert;

			private function initApp(event:FlexEvent):void
			{
				myButton.addEventListener(MouseEvent.CLICK, clickHandler);
			}

			private function clickHandler(event:MouseEvent):void
			{
				var alert:Alert = Alert.show("you clicked me!");
			}
		]]>
	</mx:Script>

	<mx:Button id="myButton" label="click me" horizontalCenter="0" verticalCenter="0"/>
</mx:Application>
:,
No comments for this entry yet...

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...