Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
Jaguar280 #1
using string variable to define object
Hey guys,
im having trouble getting this code to work. I would really appreciate any
help you can provide as its the only thing holding me back from finishing my
project :-). what im doing is creating a map where when you click on a state,
it brings up all the locations we have within that state. the locations for
each state are within an xml file.
the file has the following structure. it is just a list of locations within
different states. i used the each state's two letter code for the structure.
[Q]
<venuelist>
<mi>
<name></name>
<address></address>
<city></city>
</mi>
<mi>
<name></name>
<address></address>
<city></city>
</mi>
<ma>
<name></name>
<address></address>
<city></city>
</ma>
</venuelist>[/Q]
here is the result handler. right now it is set so that it always grabs the
locations from michigan
[Q] public function resultHandler(event:ResultEvent):void {
var arrvar:Object = event.result.venuelist.mi;
arrcol = arrvar as ArrayCollection;
dg.dataProvider = arrcol;
}[/Q]
in my flex, i have a http service calling the xml file and assigning the
entire xml collection to a variable. and then having it assigned as the
dataprovider for my datagrid. when you click on a state, it creates a pop up
with the data grid. i also have an alert that shows the two letter state code
you click on
[Q] public function createPopUp(event:USAMapEvent):void {
var stateSelected:String = event.code;
Alert.show(stateSelected, 'Alert Box', mx.controls.Alert.OK);
PopUpManager.addPopUp(panel, this, true);
PopUpManager.centerPopUp(panel);
}[/Q]
what i need to do is set the dataprovider for the datagrid to something like
dg.dataProvider = arrcoll + stateSelected so that it will go to "
"venuelist.stateSelected". what is the proper way to do this. any help is
appreciated!
Jaguar280 Guest
-
#40137 [Opn]: in-function-call variable-define bug
ID: 40137 User updated by: kolypto at mail dot ru Reported By: kolypto at mail dot ru Status: Open Bug Type: ... -
drop down menu to define a variable
I'm using php to allow users to upload pictures onto their site. This works fine but I want to define a variable by using a drop down list. the... -
define variable problem
I am attaching values to a array from XML. When I trace the variable the output gives me the values, no problem so far. the values are always... -
How to define a member variable?
PHP barfs (on line 3) when I define a member variable like this: class Foo() { $num; function DoSomething() { $num = 2 + 3; -
template parameters : define a new variable?
If you want to avoid having a "Whole-Bunch-of-Long-Multiple-If-Statements" so that you can have pretty good idea of what your page looks like,... -
VarioPegged #2
Re: using string variable to define object
Use resultFormat="e4x" in your HTTPService. Declare a property to hold the
result...
private var xml:XML;
Then your result handler might look something like this...
private function resultHandler(event:ResultEvent):void {
xml = event.result as XML;
}
Your data provider for the datagrid will be an XMLList, so declare that as a
bindable property...
[Bindable]
private var dp:XMLList;
And then you'll assign it a value dynamically when a user clicks a state...
public function createPopUp(event:USAMapEvent):void {
var stateSelected:String = event.code;
dp = xml[stateSelected] as XMLList; //define your datagrid's data provider
dynamically based on the code
Alert.show(stateSelected, 'Alert Box', mx.controls.Alert.OK);
PopUpManager.addPopUp(panel, this, true);
PopUpManager.centerPopUp(panel);
}
TS
VarioPegged Guest
-
Jaguar280 #3
Re: using string variable to define object
Hey Variopegged!
thank you so much for the reply! i follow your logic. i made the changes and
everything works just like its supposed to :-). thank you once again... ive
been messing with this issue for such a long time!
Jaguar280 Guest



Reply With Quote

