# Public static function

**URL:** https://forum.kirupa.com/t/public-static-function/308787
**Category:** Uncategorized
**Created:** [April 30, 2010, 1:55am UTC](https://forum.kirupa.com/t/public-static-function/308787 "2010-04-30T01:55:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![phastings](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@phastings](https://forum.kirupa.com/u/phastings)
#### Post date: [April 30, 2010, 1:55am UTC](https://forum.kirupa.com/t/public-static-function/308787/1 "2010-04-30T01:55:34Z")

</div>

i’m trying to target a function in one class from another. i’m able to call the function using(public static function imagecount()) but i can’t a variable out side of that function. when i do i get this error:

1120: Access of undefined property \_imagecount.

so below from call ‘person’ i want to call fucntion ‘imagecount’ in class ‘model’. the call works but when i try and define a variable in class ‘model’ that is incremented in the ‘imagecount’ function i get the above error. any idea how i can do this. it seem that my function has to be of type public static to be accessed from the other class.

///////////////// model class

package com.model  
{

```
import flash.events.*;
import flash.net.*;
import flash.display.*;
      
public class Model extends EventDispatcher
{
    public var _imagecount:int=0;
      
    public function Model(){}
    

    
    public static function imagecount():void{

        _imagecount=_imagecount+1;
        //trace("imagecount");
    }

```

}

///////////////// person class

package com.person  
{

```
import flash.display.*;
import flash.events.*;

import com.model.*;

public class Person extends Sprite
{

      private function onImageLoad(e:Event):void{
        
        
        _mediaLoader.removeEventListener(Event.COMPLETE, onImageLoad);
                    
        var image:Bitmap = Bitmap(_mediaLoader.getLoadedData());
          _imageContainer.addChild(image);
        
        Model.imagecount(); ////here i'm calling the function trying to add to the count number.

```

}

}
