# Load image total in external class

**URL:** <https://forum.kirupa.com/t/load-image-total-in-external-class/284452>\
**Category:** flash\
**Created:** [March 19, 2009, 11:11am UTC](https://forum.kirupa.com/t/load-image-total-in-external-class/284452 "2009-03-19T11:11:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobcooper](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@bobcooper](https://forum.kirupa.com/u/bobcooper)\
**Post date:** [March 19, 2009, 11:11am UTC](https://forum.kirupa.com/t/load-image-total-in-external-class/284452/1 "2009-03-19T11:11:16Z")

</div>

Hi there,

I’m a bit of a class newbie so be nice…

I am trying to get an array of images from a php file using LoadVars… I have an external as file called ImageTotal.as with the following code:

```auto
class ImageTotal {
    
    private var galleryVars;
    private var galleryArray:Array;
    private var imageTotal:Number;
    
    function ImageTotal(){}
    
    
    public function getTotal(){
        galleryVars = new LoadVars();
        galleryVars.onLoad = function(){
            galleryArray = galleryVars.filelist.split("|");
            galleryArray.pop();
            imageTotal = galleryArray.length;
            trace(imageTotal);
            
            
        }
        galleryVars.load("http://localhost/michael_price/update2/images/filmography/files.php");
    }
    
}

```

I am then running the following code from a separate movie:

```auto
import ImageTotal;

var iTotal:ImageTotal = new ImageTotal();
iTotal.getTotal();

```

However when I trace imageTotal I get undefined… now I know the php file works because I have tested it loading the galleryVars from the main timeline, but I really want to have it all in a separate class and can’t seem to get it to work.

Any ideas?

Thanks,

Bob
