View Full Version : Class Scope Issues

09-18-2004, 05:38 PM
I'm having a nasty scope issue in one of my custom classes. The class is an extension of MovieClip which is creating my own stadium component.

After setting the dataProvider I call a setInterval to one of my class functions which basically builds the UI. Once I am inside that function, I need to reference things in my class file. But to no avail,

Look at the code below. I am having trouble getting _sectionclip to evaluate as well as nCounter when I am inside buildView(). If all the variables exist in the same class and the functions as well, then why only when I call setInterval does the scope change?

class com.dticket.components.StadiumView extends MovieClip{
private var _rsSeats:Object;
private var _rsLength:Number;
private var _sectionclip:MovieClip;
private var nCounter:Number;

private var nBuildInterval:Number;

function StadiumView(){


public function set dataProvider(seatRecords:Object):Void {
nCounter = 0;
_rsSeats = seatRecords;
_rsLength = seatRecords.length - 1;

private function refreshView():Void {
_sectionclip = this.createEmptyMovieClip("mcSection",1);

_sectionclip.onMouseDown = function():Void{_sectionclip.startDrag()};
_sectionclip.onMouseUp = function():Void{_sectionclip.stopDrag()};

nBuildInterval = setInterval(buildView,50,_rsLength,_rsSeats);

private function clearView():Void {

private function buildView(numRecords:Number,seatData:Object):Void {
var iname = "s_"+seatData[nCounter].seat_id;//DBNAME
var seat:MovieClip = _sectionclip.attachMovie("Seat",iname,_sectionclip.getNextHighestDepth());
seat.moveTo(seatData[nCounter].seatX,seatData[nCounter].seatY);//DB NAME
seat["mcFlag"]._visible = false;//Set FLAG to invisible.*/

if(nCounter == numRecords){




09-18-2004, 06:02 PM
I got it. I passed a classpath variable to my function.

10-13-2004, 04:56 PM
I'm having the same issue, how are you passing the classpath to your function?

10-15-2004, 10:01 AM
try to change those two lines:
//nBuildInterval = setInterval(buildView,50,_rsLength,_rsSeats);
nBuildInterval = setInterval(this, "buildView", 50);

//private function buildView(numRecords:Number,seatData:Object):Void {
private function buildView():Void {