ForumsProgramming ForumPublic Arguments

2 3243
KhimaeraUK
offline
KhimaeraUK
24 posts
Nomad

Nono, not a domestic row in the street...

I have some arguments (an array, as it happens) that I'm passing into the constructor of a class. But I want the arguments to be accessible outside of just the constructor function.

At the moment I'm using this terrible workaround...

...
public var publicArray:Array = new Array();
public function theConstructor(theArray):void {
publicArray = theArray;
...

So defiing a public array in the class dec., and then pointing it at the argument array in memory (so not actually duplicating the information (as emptying the public array also destroys information in the argument array))...

There must be a more sensible solution to this?

Thanks in advance =]

  • 2 Replies
Fighterlegend
offline
Fighterlegend
44 posts
Nomad

Erm, I think you would use something like this:

public var publicArray:Array = new Array();
public function theConstructor(theArray:Array):void {
publicArray = theArray;

to describe the variable inside the function..

KhimaeraUK
offline
KhimaeraUK
24 posts
Nomad

How bizarre. I shall stick with my original solution then. =]

Showing 1-2 of 2