易截截图软件、单文件、免安装、纯绿色、仅160KB

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 与现有开发语言的通信全面解析


以下介绍几种最为常见和实用的FLEX与现有开发语言通信的方法:
1.C#
2.PHP
3.JAVA
1.Flex与C#通信(.net开发中常用)
Flex端代码:
   public static function SendMessage(objXML:XML,objResultHandle:Function):void
   {
        var objHttpService:HTT ......

flex中父窗口与子窗口的通信

假设父窗口是p,子窗口是c,子窗口进行操作后返回父窗口
父窗口:
var flag:Boolean = false;
var c:pop = pop(PopUpManager.createPopUp(this,pop,false)); // 新建子窗体对象
c.callFunction = this.fresh; // 子窗体中可以调用的父窗体函数(这里是子窗体关闭时,用来刷新父窗体的内容
function fresh():void
  ......

Flex窗口访问父窗口demo

1.如果使用MVC框架,相信这并不是一个问题。而如果没有使用的话,可以用类似的方法设置一个单例,子窗口和父窗口通过这个单例来交互消息,如果需要解耦,请发送自定义事件。总之,只要按照MVC思路来做就可以了。
2.类似JS,在子窗口的构造函数里增加一个参数,将父窗口传参进去。MXML没有构造函数,用一个属性来保存父窗口 ......

flex 和php 通信

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号