# Can't access number var in my class

**URL:** <https://forum.kirupa.com/t/cant-access-number-var-in-my-class/241705>\
**Category:** flash\
**Created:** [October 17, 2007, 9:12am UTC](https://forum.kirupa.com/t/cant-access-number-var-in-my-class/241705 "2007-10-17T09:12:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![schmichael](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@schmichael](https://forum.kirupa.com/u/schmichael)\
**Post date:** [October 17, 2007, 9:12am UTC](https://forum.kirupa.com/t/cant-access-number-var-in-my-class/241705/1 "2007-10-17T09:12:26Z")

</div>

Hiya, thanks for checking my post. I am really confused as what I am trying to do is so simple!  
All I want to do is increment a counter every time a movie loads. I have a method (updateMovie) that is passed an MC and the url of the swf to load into it. My loader listener object then triggers another method that should count the number of movies loaded. For some reason I can’t access my counter (‘loaded’).  
If anyone can point out where I am going wrong here I would be really really grateful as I can’t understand this at all.  
Thanks for any help  
Schm

Here is some of the code from within my class:  
[AS]  
private var loaded:Number = 0;  
//loads passed swf into mc  
private function updateMovie(mc:MovieClip, url:String) {  
var mclListener:Object = new Object();  
mclListener.onLoadInit = mcLoaded(mc);   
var image\_mcl:MovieClipLoader = new MovieClipLoader();  
image\_mcl.addListener(mclListener);  
image\_mcl.loadClip(url,mc);

```
}
//trigggered when mc is loaded
private function mcLoaded(mc:MovieClip) {
	trace("loaded:"+loaded);//traces undefined
	trace("mc loadeed:"+mc);		
	if (loaded&lt;update_ar.length) {
		loaded++;
		trace("loaded:"+loaded);
	}else{
		trace("all loaded");
	}
}

```

[/AS]
