Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help understanding scope in AS3

Status
Not open for further replies.

frozenpeas

Technical User
Sep 13, 2001
893
CA
Hi all,

I am finally making the switch to AS3 but am having some problems. I think it boils down to a misunderstanding about scope.

public class Main contains:
Code:
public var xmlData:XMLLoader = new XMLLoader();

public class XMLLoader.as contains:
Code:
public var myArray:Array = new Array("square","circle","triangle");

The problem is: I can access xmlData.myArray from my Main class but not from other classes.

For example, if (after xmlData is created) Main.as defines:
Code:
public var myGame:Game = new Game();

I cannot access xmlData.myArray from within the public Game class, even though all the classes reside in the same package. Instead, I get Error 1120: Access or undefined property xmlData.

Can someone help me gain a better understanding of this?

Thanks.

frozenpeas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top