Flex ѧϰ±Ê¼£Ö®1 flexµÄʼþ(1)
Adobe Flex 3 Help > Flex Programming Elements > Using Events
Adobe Flex 3 Help
Flex Programming Elements / Using Events
Using events
Using events in Flex is a two-step process. First, you write a function or class method, known as an event listener or event handler, that responds to events. The function often accesses the properties of the Event object or some other settings of the application state. The signature of this function usually includes an argument that specifies the event type being passed in.
The following example shows a simple event listener function that reports when a control triggers the event that it is listening for:
<?xml version="1.0"?>
<!-- events/SimpleEventHandler.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp();">
<mx:Script><![CDATA[
import mx.controls.Alert;
private function initApp():void {
b1.addEventListener(MouseEvent.CLICK, myEventHandler);
}
private function myEventHandler(event:Event):void {
Alert.show("An event occurred.");
}
]]></mx:Script>
<mx:Button id="b1" label="Click Me"/>
</mx:Application>
As you can see in this example, you also register that function or class method with a display list object by using the addEventListener() method.
Most Flex controls simplify listener registration by letting you specify the listener inside the MXML tag. For example, instead of using the addEventListener() method to specify a listener function for the Button control's click event, you specify it in the click attribute of the <mx:Button> tag:
<?xml version="1.0"?>
<!-- events/SimplerEventHandler.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.controls.Alert;
private function myEventHandler(event:Event):void {
Alert.s
Ïà¹ØÎĵµ£º
ÒÔϽéÉܼ¸ÖÖ×îΪ³£¼ûºÍʵÓõÄFLEXÓëÏÖÓпª·¢ÓïÑÔͨÐŵķ½·¨£º
1.C#
2.PHP
3.JAVA
1.FlexÓëC#ͨÐÅ(.net¿ª·¢Öг£ÓÃ)
Flex¶Ë´úÂë:
public static function SendMessage(objXML:XML,objResultHandle:Function):void
{
var objHttpService:HTT ......
ActionScript 3.0 ÓïÑÔºÍ×é¼þ²Î¿¼
Foundation ActionoScript3.0 ¶¯»
Learning Flex3
AS3 Cheat Sheets
Flex Frameword Diagram
Rich Internet Applications With Adobe Flex & Java
......
1. ×î¼òµ¥µÄ¾¯¸æ´°¿Ú
ÄãÐèÒªÏȵ¼ÈëAlertÀࣺ import mx.controls.Alert;
È»ºóÔÚÏëÒªµ¯³ö¾¯¸æµÄʱºòʹÓãº
Alert.show(“ÄãÈ·¶¨ÒªÍ˳öϵͳÂð?”,“È·ÈÏ”,Alert.YES|Alert.NO,null,logout)
²ÎÊý˵Ã÷£ºµÚÒ»¸ö²ÎÊýÊÇÒªÏÔʾµÄÎı¾£¬µÚ¶þ¸ö²ÎÊýÊÇ´°¿ÚµÄ±êÌ⣬ÕâÁ½¸ö²ÎÊýÊÇ×î¾³£Óõġ£µÚÈý¸ö²ÎÊýÊǰ´Å¥£ ......
package event
{
import flash.events.Event;
public class CustomEvent extends Event
{
public var evObject:Object;
public function CustomEvent( ......
Flex Project Nature/Add Flex Project Nature Ö´Ðкó³öÏÖÒÔÏ´íÎó£¬
Severity and Description Path Resource Location Creation Time Id
Server SDK: Directory does not contain a Flex SDK.
ÐèÒªÔÚ¹¤³ÌÊôÐÔµÄFlex co ......