[flexcoders] Repeaters and Referencing Component IDs

2009-02-19 Thread Merrill, Jason
I have a repeater inside a Viewstack working fine. i.e., the Tree
component gets created over and over as expected, however, I would like
to access an array of all the mx:Image instances, so I can load images
into them with Actionscript later (the file name for the image is not
loaded into the app until after the repeater runs and the XML is
loaded).

I thought inside a repeater, the examples I have seen
(http://www.adobe.com/devnet/flex/quickstart/using_the_repeater/  - see
the last example on that page) indicate that the id tag converts to an
array of each repeated component.  However, when I trace _image.length
(ensuring I'm checking after Application.COMPLETE fires), it's always 1,
even though the dataprovider length for the repeater is 5.  Here is the
relevant MXML part of my script:

mx:ViewStack selectedIndex={buttonBar.selectedIndex}
  mx:Repeater id=cubeSideRepeater dataProvider={arr} 
 mx:VBox width={vBoxWidth} height={toggleButtonBarHeight}
backgroundColor={vBoxBackgroundColor}verticalAlign=middle
horizontalAlign=center hideEffect=cache showEffect=cube
 mx:HBox
  mx:Tree borderThickness=0 width={treeWidth}
height=100% dataProvider={_currentTreeNode} labelField=@label
itemClick=treeItemClicked(event) /
  mx:Spacer width=5/
  mx:Image id=_images /
 /mx:HBox
  /mx:VBox
   /mx:Repeater
/mx:ViewStack

How would you handle this?


Jason Merrill 

 Picture (Device Independent Bitmap) Bank of  America   |  Learning
Performance Solutions Instructional Technology  Media   
Learn about the Adobe Flash platform for rich media experiences - join
the Bank of America Flash Platform Community
http://sharepoint.bankofamerica.com/sites/tlc/flash/default.aspx  

Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
personally, follow more nonsense on Facebook. 





.  
attachment: ole0.bmp

RE: [flexcoders] Repeaters and Referencing Component IDs

2009-02-19 Thread Tracy Spratt
The first thing I would do is crate a custom component that encapsulates
the repeated UI(tree and image), and repeat that.  Then I would create a
setter for the image source (set imageSource()) in the repeated
component.

 

I would give my component and id, say myTree.  Repeater would make an
array of the 5 instances.  Then I could do:

myTree[0].imageSource = myImageUrl;

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Merrill, Jason
Sent: Thursday, February 19, 2009 3:43 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Repeaters and Referencing Component IDs

 

I have a repeater inside a Viewstack working fine. i.e., the Tree
component gets created over and over as expected, however, I would like
to access an array of all the mx:Image instances, so I can load images
into them with Actionscript later (the file name for the image is not
loaded into the app until after the repeater runs and the XML is
loaded).

I thought inside a repeater, the examples I have seen (
http://www.adobe.com/devnet/flex/quickstart/using_the_repeater/
http://www.adobe.com/devnet/flex/quickstart/using_the_repeater/   -
see the last example on that page) indicate that the id tag converts to
an array of each repeated component.  However, when I trace
_image.length (ensuring I'm checking after Application.COMPLETE fires),
it's always 1, even though the dataprovider length for the repeater is
5.  Here is the relevant MXML part of my script:

mx:ViewStack selectedIndex={buttonBar.selectedIndex}

  mx:Repeater id=cubeSideRepeater dataProvider={arr} 

 mx:VBox width={vBoxWidth} height={toggleButtonBarHeight}
backgroundColor={vBoxBackgroundColor}verticalAlign=middle
horizontalAlign=center hideEffect=cache showEffect=cube

 mx:HBox

  mx:Tree borderThickness=0 width={treeWidth}
height=100% dataProvider={_currentTreeNode} labelField=@label
itemClick=treeItemClicked(event) /

  mx:Spacer width=5/

  mx:Image id=_images /

 /mx:HBox

  /mx:VBox

   /mx:Repeater

/mx:ViewStack

How would you handle this?

Jason Merrill

 Bank of  America   |  Learning Performance Solutions Instructional
Technology  Media  
Learn about the Adobe Flash platform for rich media experiences - join
the Bank of America Flash Platform Community
http://sharepoint.bankofamerica.com/sites/tlc/flash/default.aspx  

Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
personally, follow more nonsense on Facebook. 





.  



image001.gif