![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
Hi,
I'm new a Flex and it seems it's more complicated that it should be... but hopefully I'm wrong. I'm trying to create a list of 7 fruits, that include a picture, a checkbox and its label in English. There is a Submit button that when it's clicked, the label of the selected checkboxes changes to Spanish. I have this partially working but my problem is to loop through all 7 elements using a for loop to avoid long lines of code. I attempted doing it like I would do it in javascript: for (i=1; i<8; i++){ if ( "fruit"+i+".selected") { } } } But it's not working. I spent 2 hours surfing in the web but the solutions are related to including a datagrid or a list but it seems too difficult and they don't mention anything about handling pictures. My code is quite simple, something like the following 7 times, just changing the image source and the fruit index. <mx:Image x="479" y="21" source="images/banana.gif" width="50" height="50"/> <mx:CheckBox x="554" y="49" label="Banana" id="fruit1" textAlign="left"/> Your help will be greatly appreciate it! -Miguel |
| Sponsored Links |
|
|||
|
You have to change some things, and ofcourse you can't use JavaScript like
this, you have to use ActionScript. First, loop like this: "for (var i:int = 1; i<8; i++) {". And change the label after the if-condition by: "fruit"+i.label = "Spanish text"; (Maybe a better idea is to get this fromout a ArrayCollection...?) And use the debug-functionality and trace what results you get by, trace("in loop, i: "+i); |
|
|||
|
You have to change some things, and ofcourse you can't use JavaScript like
this, you have to use ActionScript. First, loop like this: "for (var i:int = 1; i<8; i++) {". And change the label after the if-condition by: "fruit"+i.label = "Spanish text"; (Maybe a better idea is to get this fromout a ArrayCollection...?) And use the debug-functionality and trace what results you get by, trace("in loop, i: "+i); |
|
|||
|
You have to change some things, and ofcourse you can't use JavaScript like
this, you have to use ActionScript. First, loop like this: "for (var i:int = 1; i<8; i++) {". And change the label after the if-condition by: "fruit"+i.label = "Spanish text"; (Maybe a better idea is to get this fromout a ArrayCollection...?) And use the debug-functionality and trace what results you get by, trace("in loop, i: "+i); |
|
|||
|
Thanks for your response, but it doesn't seem to be working. It seems that it
doesn't like the combination of the string plus the integer variable. I have: var i:int; i=1; for (i=1; i<8; i++){ if ( "fruit"+i+".selected") And it's showing a compilation error in the condition. I also tried: if ("fruit"+i.selected) but it doesn't do it either :-( Thanks, -Miguel |
|
|||
|
Thanks for your response, but it doesn't seem to be working. It seems that it
doesn't like the combination of the string plus the integer variable. I have: var i:int; i=1; for (i=1; i<8; i++){ if ( "fruit"+i+".selected") And it's showing a compilation error in the condition. I also tried: if ("fruit"+i.selected) but it doesn't do it either :-( Thanks, -Miguel |
|
|||
|
Thanks for your response, but it doesn't seem to be working. It seems that it
doesn't like the combination of the string plus the integer variable. I have: var i:int; i=1; for (i=1; i<8; i++){ if ( "fruit"+i+".selected") And it's showing a compilation error in the condition. I also tried: if ("fruit"+i.selected) but it doesn't do it either :-( Thanks, -Miguel |
|
|||
|
the if-condition won't work indeed.
I can't test it out right now, but i think you have to use: var b:Boolean = Boolean(); var fruitId:String = String(); in loop ... { fruitId = "fruit"+i; b = fruitId.selected; if (b) { doYourThing } Use the trace function which will lead you through this. |
|
|||
|
the if-condition won't work indeed.
I can't test it out right now, but i think you have to use: var b:Boolean = Boolean(); var fruitId:String = String(); in loop ... { fruitId = "fruit"+i; b = fruitId.selected; if (b) { doYourThing } Use the trace function which will lead you through this. |
|
|||
|
the if-condition won't work indeed.
I can't test it out right now, but i think you have to use: var b:Boolean = Boolean(); var fruitId:String = String(); in loop ... { fruitId = "fruit"+i; b = fruitId.selected; if (b) { doYourThing } Use the trace function which will lead you through this. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise