# Scope troubles?

**URL:** <https://forum.kirupa.com/t/scope-troubles/169045>\
**Category:** Uncategorized\
**Created:** [November 12, 2005, 9:03pm UTC](https://forum.kirupa.com/t/scope-troubles/169045 "2005-11-12T21:03:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![medicated](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@medicated](https://forum.kirupa.com/u/medicated)\
**Post date:** [November 12, 2005, 9:03pm UTC](https://forum.kirupa.com/t/scope-troubles/169045/1 "2005-11-12T21:03:21Z")

</div>

I’m having some problems doing some simple tasks in oop actionscript. The following code seems logical to me, but it doesn’t work. Is there a problem with the way that I am “trying” to use the this keyword.

Okay…to clarify.

1. I create a Category object.
2. I try to access the object’s properties via accessor methods.

At step 2, the subjects array is filled with undefined(ie. subjects[0] == undefined). Is there something I’m missing in my logic? I know that inside of the nested onLoad function the serverside page is being contacted and it returns the correct values into getVars. If I perform a getVars.toString, it looks fine. Sorry if this question is unclear… :s This is just a really simple task that I can’t get working.

```auto

                                        [left]class Category {[/left]
       [left]	private var category:String;[/left]
       [left]	private var subjects:Array;[/left]
       [left]	public function Category(category:String) {[/left]
       [left] this.category = category;[/left]
       [left] load();[/left]
       	}
    [left]	public function getSubjects(category:String):Array {[/left]
       [left] return this.subjects;[/left]
       	}

    [left]	public function load():Void {[/left]
       [left] var thisRef:Category = this;[/left]
       [left] var setVars:LoadVars = new LoadVars();[/left]
       [left] var getVars:LoadVars = new LoadVars();[/left]
       [left] // stop browser from returning cached results[/left]
       [left] setVars.cacheKiller = new Date().getTime();[/left]
       [left] setVars.category = category;[/left]
       [left] getVars.onLoad = function(success) {[/left]
       [left] if (success) {[/left]
       [left] thisRef.subjects.push(getVars.subject1);[/left]
       [left] thisRef.subjects[1] = getVars.subject2;[/left]
       [left] thisRef.subjects[2] = getVars.subject3;[/left]
       [left] thisRef.subjects[3] = getVars.subject4;[/left]
       	  }

    	 }

    [left] setVars.sendAndLoad("getSubjects.aspx", getVars, "GET");[/left]
       	}
    }

```
