Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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…
Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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