Assign an id to the child component:

<local:child id="mychild"/>

 

With that reference, you can access public members in the child component.
So in parent, you can do:

 

myChild.doSend(aMyArray);  

 

And in child:

 

public function doSend(aSomeArray:Array):void

{

            .

            text.send()

}

 

 

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of [email protected]
Sent: Sunday, July 26, 2009 12:10 PM
To: [email protected]
Subject: [flexcoders] Sending Child's httpservice call from Parent

 

  

Hi, I have an application called "parent.mxml" and a component called
"child.mxml". child.mxml has an httpservice that gets sent via creation
complete w/in the child.mxml. How can I change it so that this httpservice
gets sent from the parent and the parent then passes the array to the child?
I've gone through the parent/child docs at http://livedocs.
<http://livedocs.adobe.com/flex/3/html/help.html?content=modular_7.html>
adobe.com/flex/3/html/help.html?content=modular_7.html
but it isn't sinking in.....thx!

Here's my simplified code for parent:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. <http://www.adobe.com/2006/mxml>
com/2006/mxml" xmlns:local="*" xmlns:comp="components.*" >
<mx:TabNavigator width="100%" height="100%">
<local:child/>
</mx:TabNavigator> 
</mx:Application>

Here's the code for child.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe. <http://www.adobe.com/2006/mxml>
com/2006/mxml" width="100%" height="100%" creationComplete="init();" >
<mx:HTTPService id="text" url="text.php" fault="httpFaultHandler(event)"
result="httpResultHandler(event)"/> 

<mx:Script>
<![CDATA[
import mx.events.ListEvent; 
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent; 
[Bindable] private var textdata;

private function changeHandler(event:ListEvent):void{
}
public function init():void{
text.send(); 
}
private function httpFaultHandler(event:FaultEvent):void{
Alert.show("doesn't work","Error");
}
private function httpResultHandler(event:ResultEvent):void{
textdata = event.result.entries.entry;
}
]]>
</mx:Script>
<mx:DataGrid dataProvider="{textdata}" width="100%" height="100%" >
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="name" color="black"/>
<mx:DataGridColumn dataField="date" headerText="date" color="black"/>
</mx:columns> 
</mx:DataGrid>
</mx:Module>



Reply via email to