Solved

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

Posted on 2011-02-15
1
246 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

15 Experts available now in Live!

Get 1:1 Help Now