Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 08-18-2004, 09:40 AM   #1
Join Date: Jul 2004
Location: brighton, uk
Posts: 73
Default problem accessing class properties from eventHandler inside class - solution here!!!


I have a class that is providing the code for a component that allows you to select a name from a List component inside my component. I am populating the internal mx.controls.List component ok with an array that is passed to my component as it is created (using createClassObject).

However, I would like to capture the 'change' event of my List component and do some stuff based on what has been selected. I can get the selected index of the List component ok from within my 'handleEvent' method, but I don't seem to be able to read any of the properties that are available throughout the rest of the code.

Line 75 returns undefined - even though I could read that value anywhere else in the code.

Can anyone guess why I cannot access SO_players_ar from inside my 'handleEvent' method? I also need to be able to make reference to another movieClip and change it's properties, and this also seems to be unavailable.

thanks in advance

class com.stardotstar.bleep.PlayerSelector extends mx.core.UIObject{
	// class properties that allow instances of this class to be created
	// at runtime using createClassObject method of the UIObject
	var className:String = "PlayerSelector";
	static var symbolOwner:Object = PlayerSelector;
	static var symbolName:String = "PlayerSelector";	
	// class properties
	private var _SO_players_ar:Array;
	// instances used in this class
	private var faceIcon_mc:com.stardotstar.x.FaceIcon;	
	private var emptyClip_mc:MovieClip;
	private var listBox:mx.controls.List;
	/* constructor function
	function PlayerSelector(){	
	trace("new Player selector");
	// method: createChildren
	function createChildren(Void):Void{
		// add an empty movieClip that will then create the faceIcon component instance and the listBox instance
		emptyClip_mc = createEmptyMovieClip("emptyClip_mc", 1);	
		emptyClip_mc.createClassObject(mx.controls.List, "listBox",1);
		emptyClip_mc.createClassObject(com.stardotstar.x.FaceIcon, "faceIcon_mc", 2);
		//populate the listBox
		emptyClip_mc.listBox.dataProvider = SO_players_ar;
		// SO_players_ar accessible here
		trace("SOPA " + SO_players_ar[0].label);
	// method: draw
	function draw(Void):Void{
		// position the listBox
		emptyClip_mc.listBox._x = -10;
		emptyClip_mc.listBox._y = -10;
		emptyClip_mc.listBox.setSize(220, 110);
		// add an eventListener to the listBox instance, calling the method handleEvent
		emptyClip_mc.listBox.addEventListener("change", handleEvent );

		// position the faceIcon_mc
		emptyClip_mc.faceIcon_mc._x = 10;
		emptyClip_mc.faceIcon_mc._y = 90;
		// call size method
	// method that is called when the component is sized/resized
	function size(Void):Void{
	// method to do layout stuff
	function doLayout(Void):Void{
	// method to capture events from the listBox change event
	function handleEvent(eObject:Object):Void{
		var iSelectedIndex:Number = eObject.target.selectedIndex;
		trace("handleEvent: " + eObject.target.__dataProvider[iSelectedIndex].label);
		// SO_players_ar NOT accessible here
		trace ("inside handleEvent : " + SO_players_ar[iSelectedIndex].label);
	// get and set methods for the SO_players_ar Array
	public function set SO_players_ar(players_ar:Array):Void{
		_SO_players_ar = players_ar;
	public function get SO_players_ar():Array{
		return _SO_players_ar;		

Last edited by bleepbloop; 08-18-2004 at 12:44 PM. Reason: the problem has now been fixed
bleepbloop is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 10:33 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.