Solved

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

Posted on 2011-02-15
1
247 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
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

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…
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now