
Figure 3-6. The Button component in the Outline view
2. To
the Button component, add a click attribute with a
value of requestPhotos():
<mx:Button label="Search" click="requestPhotos()"/>
When a user clicks the button, it calls the requestPho
tos() handler, which initiates the HTTPService call.
3. Using the Outline view, locate the TextInput component
in the HBox component and add an id attribute with a
value of searchTerms. The instance name for the TextIn
put component is id, as shown here:
<mx:TextInput id="searchTerms"/>
4. In the mx:Script block, create a private function named
requestPhotos() with a return value of *void. This is the
function where the HTTPService call is initiated.
The relevant code appears in Example 3-7.
Example 3-7. The requestPhotos method
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var photoFeed:ArrayCollection;
private function requestPhotos():void{
}
]]>
</mx:Script>
26 | Chapter 3: Flex 101: Step by Step
Comentários a estes Manuais