Adobe Dreamweaver Forums



Last 10 THreads :         Adobe Flash 10 kills Wimpy (Last Post : midiwriter - Replies : 81 - Views : 949 )           »          How to align XML loading text to right (Last Post : Boxing Boom - Replies : 6 - Views : 7 )           »          Why is this not working!!! (Last Post : Boxing Boom - Replies : 8 - Views : 9 )           »          Referencing stage.stageWidth from a class (Last Post : 60Day - Replies : 2 - Views : 3 )           »          XML image gallery problem (Last Post : 2le - Replies : 3 - Views : 4 )           »          ProgressBar and myPlayer (Last Post : W_Bell - Replies : 0 - Views : 1 )           »          Kintana Dummy Page (Last Post : KiahMom - Replies : 2 - Views : 3 )           »          Re: Unable to Edit Text Captions (Last Post : cegrubb - Replies : 0 - Views : 1 )           »          Performing a search within multiple .as files (Last Post : Rothrock - Replies : 2 - Views : 3 )           »          left join won't work in query of query? (Last Post : Amm85 - Replies : 3 - Views : 4 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 02:58 PM
miglara
 
Posts: n/a
Diggs:
Default Basic Checkbox Issue

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



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-01-2008, 02:58 PM
Flextoth
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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);

Reply With Quote
  #3 (permalink)  
Old 10-01-2008, 02:58 PM
Flextoth
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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);

Reply With Quote


  #4 (permalink)  
Old 10-01-2008, 02:58 PM
Flextoth
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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);

Reply With Quote
  #5 (permalink)  
Old 10-01-2008, 02:58 PM
miglara
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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



Reply With Quote
  #6 (permalink)  
Old 10-01-2008, 02:58 PM
miglara
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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



Reply With Quote


  #7 (permalink)  
Old 10-01-2008, 02:58 PM
miglara
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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



Reply With Quote
  #8 (permalink)  
Old 10-01-2008, 02:58 PM
Flextoth
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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.

Reply With Quote
  #9 (permalink)  
Old 10-01-2008, 02:58 PM
Flextoth
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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.

Reply With Quote


  #10 (permalink)  
Old 10-01-2008, 02:58 PM
Flextoth
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 09:09 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk