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
相关文档:
package event
{
import flash.events.Event;
public class CustomEvent extends Event
{
public var evObject:Object;
public function CustomEvent( ......
Flex Builder 快捷键
Adobe在开发Flex最有利的工具就是Flex Builder,快速键对一般开发者来说都非常有用,很多快速键与组合键是会与其他软体或系统都有雷同之处,譬如 Ctrl + C 就是复制,Ctrl + V 就是贴上。若你有注意到就会不难发现,其实Flex Builder有很多与Eclipse编辑工具也是有许多相似之处。 多加善以利用吧!
C ......
php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charse ......
因为flex builder 工具是基于eclipse 上的,所以一些开发plug in 在flex builder 也是可以用的.
php:
Help-->Software Updates-->Find and Install-->Search for new feature to install-->new Reomote site
URL: http://update.phpeclipse.net/update/st ......