This wouldn't help, because Jeremy doesn't dispatch the CLICK event. The
Flash Player does, and it always creates a MouseEvent.

 

The solution is to extend UIComponent to have an instance var i and then
access event.currentTarget.i in his event handler.

 

- Gordon

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Shannon Hicks
Sent: Tuesday, November 28, 2006 3:07 PM
To: [email protected]
Subject: RE: [flexcoders] accessing variables through events

 

You don't. You would want to create a new custom event that extends
MouseEvent, adding in the parameter you want to pass.

 

Shan

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jeremy Tooley
Sent: Monday, November 27, 2006 9:46 PM
To: [email protected]
Subject: [flexcoders] accessing variables through events

Quick question regarding accessing variables.

I have the following code

public function tracePath():void {

for (var i:int = 0; i < photoFeed.menu.submenu.length(); i++) {
trace([EMAIL PROTECTED])
var results:XMLList = 
[EMAIL PROTECTED];
trace(results);
trace (i);
var myUIComponent:UIComponent = new UIComponent();

myUIComponent.graphics.beginFill(0xFFCC00);
myUIComponent.graphics.drawCircle(60*i, 30, 30);
myUIComponent.buttonMode = true;
myUIComponent.useHandCursor = true;
myUIComponent.addEventListener(MouseEvent.CLICK, 
mouseClickHandler);

this.addChild(myUIComponent);

}
trace(photoFeed.menu.submenu.length() +"hello");
}

and I access using this function
public function mouseClickHandler(event:MouseEvent):void{
trace(this.i);
}

My question is... how do I access the "i" variable from within the 
mouseClickHandler() function
so I could find out certain properties. The above code does not seem to 
find the "i" based on the dynamically created component.

I really want to be able to find out the list collection based on click.

Thanks
Jeremy

 

Reply via email to