# onLoadInit in class definition

**URL:** <https://forum.kirupa.com/t/onloadinit-in-class-definition/126771>\
**Category:** Uncategorized\
**Created:** [October 27, 2004, 4:14am UTC](https://forum.kirupa.com/t/onloadinit-in-class-definition/126771 "2004-10-27T04:14:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CfSupreme](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CfSupreme](https://forum.kirupa.com/u/CfSupreme)\
**Post date:** [October 27, 2004, 4:14am UTC](https://forum.kirupa.com/t/onloadinit-in-class-definition/126771/1 "2004-10-27T04:14:01Z")

</div>

Hey all, how’s it going. I have a quick question/minor problem with my code, and was wondering if any of you could enlighten me on the situation.

In a nutshell, here is the deal… I have a class that deals with image galleries and such, and in the constructor of my class

```auto

  function ImageGallery()
  {
     _imgFullLoader = new MovieClipLoader();
     _imgFullListener = new Object();
     _imgFullListener.onLoadInit = function(targetMC:MovieClip):Void
     {
  	   targetMC._x = targetMC._width * (_imgCount + 10);
     }
  }
  

```

The \_imgCount variable is a number that I’ve declared, initialized to 0, and it is incremented each time a new image is loaded. The problem is, that within the onLoadInit code block, it is being treated as undefined. The  
images load fine, but their x values remain constant, since \_imgCount is treated as undefined. How do I make it to where onLoadInit can retrieve the true value of \_imgCount within the class definition?

Thanks in advance. Talk to you later.
