[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

passing parameter with addEventListener

Asked by coldchillin in Adobe Flex

I'm trying to pass an extra parameter to an event listener that I have added dynamically, and I have implemented this solution with a slight variation before.

The error I am getting is "A term is undefined or has no properties".

So it may seem confusing, but here's what I'm doing: I'm creating a set of buttons, among other things, from an array.

When rendered, the button ids will read as:
btnWarrantyPContact
btnServicePContact
btnShippingPContact
btnPartsPContact
...

In the code you will see the first assignment to a label "lbl", and THIS WORKS. Within the IF block is the code that no longer works (I'm thinking it has something to do with being in the function within the function...?). The commented line below that shows a hard-coded ID field, which also works when used.

So, the "offending" code works above, and it's hard-coded value works as a replacement...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
acAddtRev = event.result as ArrayCollection;
 
var addtRevItems:Array = ["Warranty","Service","Shipping","Parts"];
 
for(var i:int = 0; i < addtRevItems.length; i++){
this["lbl" + addtRevItems[i].toString() + "CPerson"].text = acAddtRev.getItemAt(0)[addtRevItems[i].toString() + "CMID"];
 
if(acAddtRev.getItemAt(0)[addtRevItems[i].toString() + "Count"] == 1){
	this["btn" + addtRevItems[i].toString() + "CContact"].addEventListener(MouseEvent.CLICK, function (e:MouseEvent):void {
	showContact(e, acAddtRev.getItemAt(0)[addtRevItems[i].toString() + "CMID"]); 
							});
/*this["btn" + addtRevItems[i].toString() + "PContact"].addEventListener(MouseEvent.CLICK, function (e:MouseEvent):void { showContact(e, 26791); }); */
					} 
				}
[+][-]10/21/09 06:42 AM, ID: 25623818Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/21/09 11:31 AM, ID: 25626838Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/21/09 11:58 AM, ID: 25627127Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/21/09 11:55 PM, ID: 25631383Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 10:11 AM, ID: 25752208Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 12:43 AM, ID: 25757572Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625