Adobe Dreamweaver Forums



Last 10 THreads :         ProgressEvent reporting incorrect properties? (Last Post : ErikMadsen - Replies : 0 - Views : 1 )           »          Clock .getUTC not working (Last Post : bolszo - Replies : 0 - Views : 1 )           »          Sound.position (Last Post : hoppe11 - Replies : 2 - Views : 3 )           »          ProgressBar and myPlayer (Last Post : W_Bell - Replies : 2 - Views : 3 )           »          Controlling a virtual keyboard from Director MX 2004 (Last Post : RandallH - Replies : 0 - Views : 1 )           »          How to use custom functions from Dlls (Last Post : dotnetuser - Replies : 0 - Views : 1 )           »          Flash Controls Not Displaying in Embedded File (Last Post : QADesign - Replies : 2 - Views : 3 )           »          Re: Where to Install fonts (Last Post : quality11 - Replies : 0 - Views : 1 )           »          Making a photo with rounded corners (Last Post : Linda Rathgeber - Replies : 3 - Views : 4 )           »          Online shop with barcode scanner (Last Post : Hunter Elliott - Replies : 1 - Views : 2 )           »         


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
  #11 (permalink)  
Old 10-01-2008, 02:59 PM
istrasci
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue

There are several ways to do this.

1) Create an array of CheckBoxes and access with if (fruit[n].selected)

2) Use a repeater to create N checkboxes and access through the repeater. I'm
still a beginner with repeaters, so I think it would look something like:

<mx:Repeater id="rep" dataSource={some_array_with_N_elements}>
<mx:CheckBox .../>
</mx:Repeater>

Then you'd access with something like: if (rep[n].CheckBox.selected)
Actually, I'm positive that's not totally correct, so you'd have to check
documentation on how to access with repeaters.

3) Use the getChildByName() method in conjunction with building the string in
the Actionscript code like you are doing. But then you'd have to set the
"name" property of each checkbox in such a way that they are similar enough to
each be constructed using the loop index. Something like this:

<mx:CheckBox name="fruit1" .../>
<mx:CheckBox name="fruit2" .../>
...

Then in the Actionscript code, you'd access with: if
(getChildByName("fruit"+n).selected)


If you know how to use repeaters, then option 2 is probably the best and most
concise. If not, it might be more trouble than it's worth (at least at this
point) to learn how to use them, and go with option 1 or 3..

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

There are several ways to do this.

1) Create an array of CheckBoxes and access with if (fruit[n].selected)

2) Use a repeater to create N checkboxes and access through the repeater. I'm
still a beginner with repeaters, so I think it would look something like:

<mx:Repeater id="rep" dataSource={some_array_with_N_elements}>
<mx:CheckBox .../>
</mx:Repeater>

Then you'd access with something like: if (rep[n].CheckBox.selected)
Actually, I'm positive that's not totally correct, so you'd have to check
documentation on how to access with repeaters.

3) Use the getChildByName() method in conjunction with building the string in
the Actionscript code like you are doing. But then you'd have to set the
"name" property of each checkbox in such a way that they are similar enough to
each be constructed using the loop index. Something like this:

<mx:CheckBox name="fruit1" .../>
<mx:CheckBox name="fruit2" .../>
...

Then in the Actionscript code, you'd access with: if
(getChildByName("fruit"+n).selected)


If you know how to use repeaters, then option 2 is probably the best and most
concise. If not, it might be more trouble than it's worth (at least at this
point) to learn how to use them, and go with option 1 or 3..

Reply With Quote


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

There are several ways to do this.

1) Create an array of CheckBoxes and access with if (fruit[n].selected)

2) Use a repeater to create N checkboxes and access through the repeater. I'm
still a beginner with repeaters, so I think it would look something like:

<mx:Repeater id="rep" dataSource={some_array_with_N_elements}>
<mx:CheckBox .../>
</mx:Repeater>

Then you'd access with something like: if (rep[n].CheckBox.selected)
Actually, I'm positive that's not totally correct, so you'd have to check
documentation on how to access with repeaters.

3) Use the getChildByName() method in conjunction with building the string in
the Actionscript code like you are doing. But then you'd have to set the
"name" property of each checkbox in such a way that they are similar enough to
each be constructed using the loop index. Something like this:

<mx:CheckBox name="fruit1" .../>
<mx:CheckBox name="fruit2" .../>
...

Then in the Actionscript code, you'd access with: if
(getChildByName("fruit"+n).selected)


If you know how to use repeaters, then option 2 is probably the best and most
concise. If not, it might be more trouble than it's worth (at least at this
point) to learn how to use them, and go with option 1 or 3..

Reply With Quote
  #14 (permalink)  
Old 10-01-2008, 02:59 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue


"miglara" <webforumsuser@macromedia.com> wrote in message
news:gbr2u5$r00$1@forums.macromedia.com...
> 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!


Flex 3 Training From the Source has an example of exactly this. Actually, I
think they have several.


Reply With Quote
  #15 (permalink)  
Old 10-01-2008, 02:59 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue


"miglara" <webforumsuser@macromedia.com> wrote in message
news:gbr2u5$r00$1@forums.macromedia.com...
> 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!


Flex 3 Training From the Source has an example of exactly this. Actually, I
think they have several.


Reply With Quote


  #16 (permalink)  
Old 10-01-2008, 02:59 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Basic Checkbox Issue


"miglara" <webforumsuser@macromedia.com> wrote in message
news:gbr2u5$r00$1@forums.macromedia.com...
> 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!


Flex 3 Training From the Source has an example of exactly this. Actually, I
think they have several.


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

Thanks a lot, I wasn't familiar with repeaters but it seems that that's the best way to go.

Thanks!

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

Thanks a lot, I wasn't familiar with repeaters but it seems that that's the best way to go.

Thanks!

Miguel
Reply With Quote


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

Thanks a lot, I wasn't familiar with repeaters but it seems that that's the best way to go.

Thanks!

Miguel
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 10:29 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