Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-02-15
1
Medium Priority
?
255 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 500 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

Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

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…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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