Solved

In Flex, how do I reference a variable in a custom component?

Posted on 2011-02-15
1
251 Views
Last Modified: 2012-05-11
I have a custom component that I am importing in my main.mxml file. In the main.mxml file I create a public var arraycollection. How do I reference values from the arraycollection in the custom component?

Creates array collection in main.mxml:

for (var i:int=0; i<nMastDaysSch; i++) {
	var catchMastDaySch:Object = new Object();
	catchMastDaySch.id = aMastDaysSch[i][0]
	catchMastDaySch.dateS = aMastDaysSch[i][1]
	catchMastDaySch.weekN = aMastDaysSch[i][2];
	catchMastDaySch.day_name = aMastDaysSch[i][3];
	catchMastDaySch.status = aMastDaysSch[i][4];
	catchMastDaySch.notes = aMastDaysSch[i][5];
	acMastDaySch.addItem(i);
}

Open in new window


adds custom components in main.mxml:

<s:DataGroup id="showDays" dataProvider="{acMastDaySch}" itemRenderer="myComps.schedulingComps.MastSchDayPanel" width="1165" height="480">
	<s:layout>
		<s:HorizontalLayout/>
	</s:layout>
</s:DataGroup>

Open in new window

in the custom component file:
<s:Panel id="myPan1" width="250" height="480" chromeColor="#B8CCBB" title="{acMastDaySch.day_name}">

Open in new window

This throws an error.
0
Comment
Question by:skibama1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 125 total points
ID: 34901551
Ok, I think I will be able to assist you with this one.

If your custom component is somehow related to DataRenderer, then is automatically possesses a "data" property which is automatically set by the container.

I would suggest you change your custom component to the following (notice the "data" instead of the "acMastDaySch"):
<s:ItemRenderer>
    <s:Panel id="myPan1" width="250" height="480" chromeColor="#B8CCBB" title="{data.day_name}">
</s:ItemRenderer>

Open in new window


If you use this, you should be able to do what you want.
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question