Hi Mark,

What you're trying to accomplish is (don't quote my authority here...)
I think best tackled in Flex with a TileList and a custom
ItemRenderer. You're definitely going into too much depth by altering
component children individually at runtime.

Since there's more than one way to skin a cat, best take a step back
an prepare for a paradigm shift... forget about adding children and
looping through and the like - Flex shouldn't need to follow that kind
of model.

If you need to "loop through" because your sources are live, you can
schedule a call to one of the invalidation methods in the Flex display
architecture, and thereby have Flex redraw the screen (except you
should override the method so it does your stuff too...)

http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=ascomponents_advanced_148_16.html

You'll need an understanding of ItemRenderers:

http://www.adobe.com/devnet/flex/quickstart/using_item_renderers/

The basic concepts:

- Any sort of List has a dataProvider.
- A TileList is a sort of List.
- Your dataProvider is normally an Array or ArrayCollection of items

- A list has a default ItemRenderer which renders the items in the
dataProvider (ordinarily extracting values from the "label" and "data"
properties of objects in the dataProvider's ArrayList)

- Your dataProvider can be a collection of *any object type*
(in your case, I'd recommend creating a class that contains all the
data relevant to each pair of image/text)

- At render-time (to coin a term), an itemRenderer has it's content
"dropped" into it. Flex will populate the with the TileList with
itemRenderers, and set the data property on each itemRenderer. Flex
loops over the dataProvider of the list, passing in one object at a
time.

- Each itemRenderer can now "see" one item (whatever is passed in) of
the dataProvider (one instance of your custom class) in it's local
scope as the "data" property if your itemRenderer is MXML. If it's
ActionScript, you can override the data setter.

So in your case, create a TileList with a columnWidth of 1.
Each item in your TileList dataProvider should be of a custom type
(create whatever type is necessary to store the data relating to each
image and it's text).
Put all your data into an ArrayCollection and bind it to the TileList
dataProvider
Create a custom itemRenderer in MXML (a VBox with an Image on one
side, labels on the other) - bind it's properties (i.e. the image
source, the label text, to the object you expect to be dropped in via
the data property).

If you need any more detailed modifications, look into creating your
itemRenderer with ActionScript.

This is an abstract of a wide range of concepts, so you may have to
look round a bit on docs, blogs and the like, to find examples of
similar stuff (there's plenty out there).

It seems the main thing would be to change the approach your taking
(if I'm making the right assumptions about what you're trying to do).

Best Regards,
Ciarán

On 2/27/07, oneproofdk <[EMAIL PROTECTED]> wrote:
> Hi Ciarán
>
> Just put up a small example for you (and others) to see. Rightclick to
> view source:
> http://flex2.dk/mark/addchild/childTest.html
>
> Very simple app - 2 buttons.
> Add Children - will add 12 vboxes, each containing 2 images
> Loop Through Children - Will loop through tile1.numChildren - printing
> each name into the textarea.
> But.... HOW can I get hold of the names of the images (and even more,
> their source)
>
> I need this to be able to loop through each item, check if the source
> has been updated, and if so, reload the image.
>
> Thanks for your time.
>
> Mark
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>

Reply via email to