Ely:
Thanks alot. Worked fine and I learned something about
closures.
Dave
--- In [EMAIL PROTECTED]ups.com,
"Ely Greenfield" <[EMAIL PROTECTED].>
wrote:
>
>
>
>
> You've got three options:
>
> 1) shove the id off
into a member field, and grab it when the RO
> returns. This is the least
well designed response, since it can
break
> in use cases where you've
got multiple requests out and you don't
just
> want last-out-wins.
Might be OK for your use case though.
>
> 2) send the id up to the
RO, and have it include it in the
response. A
> little wasteful, since
the RO doesn't care about the id, but in
general
> this 'cookie'
pattern is a way to maintain state across RO calls.
>
> 3) use
closures. you could do something like this:
>
>
> private
function chartClickHandler(e:MouseEvent):void
> {
> var
id:String = UIComponent(e.currentTarget).id;
> var roCB:Function
= function(e:ResultEvent):void
> {
> nameList = event.result as
ArrayCollection;
> currentState = "showNames";
> gridPanel.title =
id;
>
myRemoteObject.getNomeForNames.removeEventListener
("result",roCB);
>
}
>
myRemoteObject.getNomeForNames.addEventListener("result",roCB);
>
myRemoteObject.getNomeForNames(id);
> }
>
>
<PieChart id="..." click="chartClickHandler(event);" ...
/>
>
> Ely.
>
>
>
________________________________
>
> From: [EMAIL PROTECTED]ups.com
[mailto:[EMAIL PROTECTED]ups.com]
On
> Behalf Of dffmyco
> Sent: Tuesday, September 05, 2006 8:28
AM
> To: [EMAIL PROTECTED]ups.com
>
Subject: [flexcoders] Which chart was clicked
>
>
>
>
I have 3 pie charts which when clicked run the same remoteObject
>
method. Is there a way within the method that I can determine
which
>
pie chart was clicked. I want to pass the id of the clicked chart
as
> a variable in the result function of the remoteObject method.
>
> Thanks, Dave
>
> <mx:PieChart id="Citrus"
>
click="myRemoteObject.getNomeforNames('Citrus')"
showDataTips="true"
>
dataProvider="{citrusData}"/>
>
>
<mx:RemoteObject
> id="myRemoteObject"
>
destination="ColdFusion"
> showBusyCursor="true"
>
source="fungaldatabases.fungaldatabasesstats.stats"
>
fault="Alert.show(event.fault.faultString, 'Error');">
>
<mx:method name="getNomeforNames"
result="showNames(event)">
>
> </mx:method>
>
</mx:RemoteObject>
>
> public function
showNames(event:ResultEvent):void{
> nameList=event.result
as ArrayCollection
> currentState = "showNames";
> gridPanel.title
= 'whould like to use the id of the chart
> selected'
>
}
>