Flex×Ô¶¨Òå×é¼þÓë×Ô¶¨Òåʼþ
1¡¢×Ô¶¨Òå×é¼þ
2¡¢×Ô¶¨Òåʼþ
3¡¢½áºÏʹÓÃ
Ò»¡¢×Ô¶¨Òå×é¼þ£¨Ê¹ÓõÄÊÇFlex×é¼þ£¬ActionScript×é¼þÏà¶ÔÂé·³µã£¬¿ÉÊÓ»¯²îµã£©
¸Ã×é¼þÓÉÒ»¸öTextAreaºÍÁ½¸öButton×é³É£¬Èçͼ£º
´úÂ룺
MyComponent.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="180" height="94" creationComplete="initComponent()">
<mx:Metadata>
/**
* 1. ±àÒëÆÚ¼äÖ´ÐÐ
* 2. ×Ô¶¨Òå×é¼þÒ»°ã¿ÉÒÔͨ¹ýdispatchEventίÅÉparentÀ´´¦Àíij¸öʼþ£¬Õâ¾ÍÐèÒªÔÚparentÖÐÉèÖÃÒ»¸öaddEventListerÀ´¼àÌýʼþ¡£
* ¾ÍÏñButtonµÄEvent.CLICKʼþ£¬³ýÁË¿ÉÒÔͨ¹ýaddEventLister(Event.CLICK, clickHandle)À´¼àÌý´¦ÀíÍ⣬ÔÚFlex×é¼þÖл¹¿ÉÒÔ
* Ö±½Ó mx:Button click="clickHandle(event)" / ¡£Ôõô¶¨Òå×Ô¶¨Òå×é¼þÒ²¿ÉÒÔ´ïµ½Èç´ËЧ¹ûÄØ£¿
* 2.1) ÄÚ²¿ÉùÃ÷£º[Event(name="commit",type ="laxino.MyEvent")]£¬typeÊÇָʼþµÄÀàÐÍ£¨Èç1µÄÀàÐÍÊÇint,'aaa'µÄÀàÐÍÊÇString£©,nameÊÇÖ¸
* EventÖеĹ¹Ô캯ÊýÖÐtype¡£
* 2.2) ÍⲿʹÓãºcommit="commitHandle(myEvent)"ÊÇָΪ¸Ã×é¼þ×¢²áÁËÒ»¸ö¼àÌýÆ÷£¬¼àÌýÃû×Ö½ÐcommitµÄʼþ£¬²¢Í¨¹ýcommitHandle´¦Àí¡£Ê¼þµÄ´¥·¢ºÍ
* ίÅɱØÐëÔÚ×é¼þÄÚʵÏÖ¡£
*
*/
/**
*
* Using the Event metadata tag
* You use the [Event] metadata tag to define events dispatched by a component so that the Flex compiler can recognize
* them as MXML tag attributes in an MXML file. You add the [Event] metadata tag in one of the following locations:
* ActionScript components Above the class definition, but within the package definition, so that the events are bound
* to the class and not a particular member of the class.
* MXML components In the mx:Metadata tag of an MXML file.
*
*/
[Event(name="commit",type ="laxino.MyEvent")]
[Event(name="preview",type ="laxino.MyEvent")]
</mx:Metadata>
<mx:Script>
<!--[CDATA[
private function initComponent():void
{
}
private function preview(event:Event):void
{
this.dispatchEvent(new MyEvent(MyEven
Ïà¹ØÎĵµ£º
flashºÍflexÕë¶Ô²»Í¬µÄÄ¿µÄ£¬ÌṩÁË3ÖÖ²»Í¬µÄ×ø±êϵ¡£
È«¾ÖµÄ¾ÍÊÇ(stage¼¶±ðµÄ)
±¾µØ×ø±êϵ£¨×é¼þ¼¶±ðµÄ£©
ÄÚÈÝ×ø±êϵ£¨Ïà¶ÔÓÚ±¾µØ×ø±êϵ˵µÄ ......
±¾ÏµÁÐÎÄÕÂÖ÷Òª½éÉÜÁ˹ØÓÚFlexÓë.NET½áºÏ¿ª·¢ÖеÄһЩ»¥²Ù×÷ÐÔ£¬°üÀ¨ÍøÂçͨÐÅ¡¢Êý¾Ý¼ÓÔØ¡¢Êý¾Ý´«Êä¡¢Îļþ´«Êä¡¢ÒÔ¼°Ó¦ÓÃÓÚFlexÓë.NETÐ×÷¿ª·¢µÄͨÐÅÍø¹Ø¿ªÔ´ÏîÄ¿FluorineFxµÄÏà¹Ø֪ʶµã¡£
¿ªÔ´ÏîÄ¿FluorineFx¾ÍÊÇרÃÅÕë¶Ô.NETƽ̨ÓëFlexͨÐÅÌṩµÄAMFÐÒéͨÐÅÍø¹Ø£¬ÎÒÃÇ¿ÉÒÔͨ¹ ......
±¾ÀýÖн«ÊµÏÖµ±Ó¦ÓÃÔËÐÐʱ²»½øÐÐÈκβÙ×÷¾ÍÏȵ¯³ö´°¿Ú£¬µã»÷¹Ø±Õ/µã»÷´°¿ÚÈÎһλÖà ʱ½«¹Ø±Õ´°¿Ú
1£©´´½¨Component—DefaultWin.mxml £¨Ä¿Â¼½á¹¹src/components/DefaultWin.mxml£©
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
  ......
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("a.txt");
private function initComplete():void
{
  ......