RE: [flexcoders] Re: Define repeaters at runtime

2009-03-09 Thread Gordon Smith
 I understand that arrays can hold references to components
 so I've recoded to push and pop the images from ImageArray
 to set the properties on the individual Images.

You shouldn't have to push and pop anything. If the ith element of the array is 
a reference to an Image instance, then setting imageArray[i].source in a loop 
should work fine. What are you setting it to, and how does it not work?

Gordon Smith
Adobe Flex SDK Team


From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of smitade
Sent: Friday, February 27, 2009 11:31 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Define repeaters at runtime


--- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, Gordon 
Smith gosm...@... wrote:

 So that the doc team understands... What is it that you found
surprising? That an Array can hold anything, including references to
components?

 Gordon Smith
 Adobe Flex SDK Team

 From: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com 
 [mailto:flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com]
On Behalf Of smitade
 Sent: Thursday, February 26, 2009 9:50 PM
 To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com
 Subject: [flexcoders] Re: Define repeaters at runtime


 It works - please ignore the previous post. Wow, the ability to push
 components into arrays like this opens up so many possibilities -
 especially when working with flex frameworks. I find it strange the
 documentation doesn't highlight this feature - otherwise I missed it.
 Thanks again!


Gordon - sorry for the confusion - I'm confused myself! When I started
this thread I was looking for a way to dump components into an Array
e.g. 64 Images into an array ImageArray so that I could set the
properties of the images by setting the array directly e.g.
for (i=0;i64;i++)
{
ImageArray[i].source=some.png;
}

I mistakenly thought it was working as initially all of the 64 images
have the same source and this was showing up correctly. What I found
out that this is not the case (and probably why I didn't find it in
the docs). I understand that arrays can hold references to components
so I've recoded to push and pop the images from ImageArray to set the
properties on the individual Images. I liked the functionality of
using a repeater defined in MXML where I could reference my
ImageArray directly. I haven't found a way to define this repeater
at runtime though.

Sorry for the long reply - hope it makes sense.



Re: [flexcoders] Re: Define repeaters at runtime

2009-02-27 Thread subeesh a
If you are adding the images to some container , you can get it as

var ImageArray:Array = yourContainer.getChildren();

Subeesh
http://subeesh.co.nr


RE: [flexcoders] Re: Define repeaters at runtime

2009-02-27 Thread Gordon Smith
So that the doc team understands... What is it that you found surprising? That 
an Array can hold anything, including references to components?

Gordon Smith
Adobe Flex SDK Team

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of smitade
Sent: Thursday, February 26, 2009 9:50 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Define repeaters at runtime


It works - please ignore the previous post. Wow, the ability to push
components into arrays like this opens up so many possibilities -
especially when working with flex frameworks. I find it strange the
documentation doesn't highlight this feature - otherwise I missed it.
Thanks again!



[flexcoders] Re: Define repeaters at runtime

2009-02-27 Thread smitade
--- In flexcoders@yahoogroups.com, Gordon Smith gosm...@... wrote:

 So that the doc team understands... What is it that you found
surprising? That an Array can hold anything, including references to
components?
 
 Gordon Smith
 Adobe Flex SDK Team
 
 From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com]
On Behalf Of smitade
 Sent: Thursday, February 26, 2009 9:50 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: Define repeaters at runtime
 
 
 It works - please ignore the previous post. Wow, the ability to push
 components into arrays like this opens up so many possibilities -
 especially when working with flex frameworks. I find it strange the
 documentation doesn't highlight this feature - otherwise I missed it.
 Thanks again!


Gordon - sorry for the confusion - I'm confused myself! When I started
this thread I was looking for a way to dump components into an Array
e.g. 64 Images into an array ImageArray so that I could set the
properties of the images by setting the array directly e.g. 
for (i=0;i64;i++)
{
  ImageArray[i].source=some.png;
}

I mistakenly thought it was working as initially all of the 64 images
have the same source and this was showing up correctly. What I found
out that this is not the case (and probably why I didn't find it in
the docs). I understand that arrays can hold references to components
so I've recoded to push and pop the images from ImageArray to set the
properties on the individual Images. I liked the functionality of
using a repeater defined in MXML where I could reference my
ImageArray directly. I haven't found a way to define this repeater
at runtime though. 

Sorry for the long reply - hope it makes sense. 








[flexcoders] Re: Define repeaters at runtime

2009-02-26 Thread smitade
Thanks Pedro

So is it possible to define an Image Array without a repeater? I'd
like to run through 64 Images using:

for each (var img:Image in ImageArray)
{
... etc
}

Back to google.




[flexcoders] Re: Define repeaters at runtime

2009-02-26 Thread smitade
Tried this but it failed:

In Model.as
public var a_red:Array=new Array();

then later:
Model.getInstance().a_red[1].source=Model.getInstance().red_source;

where red_source is a png image.

for (var i:int=0;i64;i++)
{
 Model.getInstance().a_red.push(Model.getInstance().red);
}

then:
trace(Red Image: ,Model.getInstance().red[1].source);

Error #1069: Property 1 not found on mx.controls.Image and there is no
default value.




[flexcoders] Re: Define repeaters at runtime

2009-02-26 Thread smitade
It works - please ignore the previous post. Wow, the ability to push
components into arrays like this opens up so many possibilities -
especially when working with flex frameworks. I find it strange the
documentation doesn't highlight this feature - otherwise I missed it.
Thanks again!