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
相关文档:
由于avm版本的问题,flex3无法直接调用flash做的swf文件,弄了一天,最后终于想到了一个办法,将LocalConnect和flex调用as3两种方式攒在了一起,算是暂时把这个问题解决了!
存起来,留着以后修改
第一步:用flash做一个as2的文件
我在里面添加了一个按钮
在第一帧写下面的代码
mybtn.onRelease=function()
{
......
作为一个不入流的flex开发人员总结一下不入流的感悟。
我一定要记住,as中的变量的作用范围只有两种,function和class,所以要想用闭包就需要一个createFunction的东西才行,不要妄想在for循环中用闭包了。看了一下as3的参考,发现它的前世和lua还真像,as3的继承其实还是prototype来做的,就是lua的元表了, ......
一.通过js访问Flex组件
1.准备工作。先建立Flex工程 :fademo,并放置一个文本框:txtName。做完后代码应该类似于这个样子:
view plaincopy to clipboardprint?
·········10······· ......
flex整合spring也有很多的例子,其实有很多例子很复杂。我在这就给大家介绍个最简单的,很实用。
说明下:flex完全可以代替struts,下面的例子能证明。有人会问了,和其他框架怎么样整合。spring都能整合了,其他框架你要不会整合我也都无语了。
不多说了,看代码就知道简单不!
flex--sdk 3.2以上
jdk 1.5 以上
spring ......
两个不同的flex自定义控件怎么相互控制?
比如当在一个只有add方法的控件框mxml里,当提交成功的时候,怎么更新另外一个有datagird控件框的mxml?
就可以用如下方法:在主应用程序里面,对子控件datagird进行操作;
1、parentApplication.refreshAdmin(); //在add子控件
2、public ......