Log In  
  Getting Started  
compared with
Current by Randy Nielsen
on Apr 29, 2009 10:28.

(show comment)
 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 2 changes. View first change.

 {section}
 {column:width=80%}
  
 h2. Handling events
 *Subtopics:*
 * [Event demo | http://learn.adobe.com/wiki/display/Flex/Event+Demo]
 * [Event listeners | http://learn.adobe.com/wiki/display/Flex/Event+Listeners]
 * [Event propagation | http://learn.adobe.com/wiki/display/Flex/Event+Propagation]
 * [Simple UI event | http://learn.adobe.com/wiki/display/Flex/Simple+UI+Event]
  
 h2. What you need to know
 With Flex events, you use handler functions to respond to both asynchronous network and user generated events.
  
 h2. What you need to know
  
 * PHP KEY CONCEPT: Asynchronous events might be a new concept for many PHP developers. We highly recommend reviewing this section. In PHP, there really aren't any events. Event is basically the user requesting a web page. If you're familiar with Javascript though, event handling is similar.
  
 * ASP Event handling is similar to the way events are handled via the callback function and code-behind concepts.
  
 h3. Use Event Listeners (also called Event Handlers) to respond to events
  
 Events are generated in three ways: User actions (e.g. mouse click), Network (e.g. data received), and the Flex Application itself (for example, page loaded event).
 When an event is dispatched, you may want your Flex application to respond. This is done via an event listener or handler function that is called when certain events are fired.
 There are three phases to the Flex event flow mechanism: capturing, targeting, and bubbling.
 {column}
 {column}
 {adbe-prev:http://learn.adobe.com/wiki/display/Flex/Validation+and+Formatting}
 {adbe-next:http://learn.adobe.com/wiki/display/Flex/Event+Demo}
 {rate:title=User rating|theme=dynamic|key=focal|display=default}
 {adbe-pod}
  
 h6. Learn more
  
 * Quick-start: {adbe-popup:http://www.adobe.com/devnet/flex/quickstart/handling_events/}Handling events{adbe-popup}
 * LiveDocs: {adbe-popup:http://livedocs.adobe.com/flex/3/html/16_Event_handling_1.html}Basics of event handling{adbe-popup}
 * LiveDocs: {adbe-popup:http://livedocs.adobe.com/flex/3/html/events_01.html}Using events in Flex{adbe-popup}
 * Reference: {adbe-popup:http://livedocs.adobe.com/flex/3/langref/flash/events/Event.html}flash.events.Event class{adbe-popup}
 * {adbe-popup:http://ajaxandbeyond.blogspot.com/2007/09/flex-events-introduction.html}Flex Events: Introduction{adbe-popup}
 * {adbe-popup:http://www.ananth.info/files/54923-48191/FlexEventDataManagement10April2007.ppt}flex event Management (powerpoint){adbe-popup}
 {adbe-pod}
 {column}
 {column}
 {column}
 {section}
 {section}
 {section}
  
 h2. SAMPLE CODE OVERVIEW: Handling an application event (asynchronous network event)
  
 The following application:
 * Uses an HTTPService control that retrieves a twitter RSS feed.
 * Responds to the asynchronous event using a handler function.
 * Makes the remote call in response to a user generated click event.
  
 The finished application will look like this:
 {code}
 <?xml version="1.0" encoding="utf-8"?>
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  width="500" height="500">
  <mx:HTTPService
  id="twitterService"
  url="http://twitter.com/statuses/public_timeline.xml"
  resultFormat="e4x"
  result="twitterServiceResultHandler(event);"
  />
  <mx:Script>
  <![CDATA[
  import mx.rpc.events.ResultEvent;
  private function twitterServiceResultHandler(event:ResultEvent):void
  {
  resultTxt.text = event.result.toString();
  }
  ]]>
  </mx:Script>
  <mx:Button id="myButton" label="Send HTTP Request"
  click="twitterService.send()"/>
  <mx:TextArea id="resultTxt" width="100%" height="100%"/>
 </mx:Application>
 {code}
  
 Note that this code requires that Twitter provide a crossdomain.xml file (also called a crossdomain policy file) that enable access from your application. For more information on crossdomain policy files, see {adbe-popup:http://livedocs.adobe.com/flex/3/html/05B_Security_03.html#122782}Programming ActionScript 3.0{adbe-popup} and the {adbe-popup:http://livedocs.adobe.com/flex/3/html/security2_04.html#139879}Flex deployment checklist.{adbe-popup}
  
 {adbe-prev:http://learn.adobe.com/wiki/display/Flex/Validation+and+Formatting}
 {adbe-next:http://learn.adobe.com/wiki/display/Flex/Event+Demo}
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators