# Custom function onLoad

**URL:** <https://forum.kirupa.com/t/custom-function-onload/239562>\
**Category:** Uncategorized\
**Created:** [September 23, 2007, 1:29pm UTC](https://forum.kirupa.com/t/custom-function-onload/239562 "2007-09-23T13:29:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xannax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/xannax/32/3350_2.png) [@Xannax](https://forum.kirupa.com/u/Xannax)\
**Post date:** [September 23, 2007, 1:29pm UTC](https://forum.kirupa.com/t/custom-function-onload/239562/1 "2007-09-23T13:29:26Z")

</div>

Ok I don’t know how to put this; I’m sorry if the title is confusing.  
it might be a very stupid question, and maybe it has been answered before, but I have no idea what to search for.  
Here’s my problem: I have a class (called “Page”), that contains a loader that loads data off a php script. now I have an event launched when the loader finishes loading, and that populates some variables.  
Here’s my problem: I want to create an empty function within the class that is also launched when the loader finishes loading. In fact, I have text boxes in the flash file that I want automatically populated upon loading.  
to sum it up, I would have a class file Page.as:

```auto

package{
import blah
public class Page{
        private var currRequest:URLRequest = new URLRequest();
        private var currLoader:URLLoader = new URLLoader();
        public function Page(){
            currLoader.addEventListener(Event.COMPLETE, completeHandler);try{
                currLoader.load(currRequest)
                }    
                catch(error:Error){trace("Unable to load URL");}
            }//end of constructor method
        public function onLoad(){};
        private function completeHandler(event:Event):void{
            onLoad()
            }
}
}

```

yeah i know there is lot of stuff missing, I’m just putting the essential so you get the idea.  
And in my flash file:

```auto

var tempPage:Page = new Page();
tempPage.onLoad = function(){/ **function goes here** /}

```

Now, I tried to declare the public function in many places, but it never works.  
How can I have a custom function that is launched when the loader has loaded?  
I tried putting a boolean in my class called isLoaded and check on it with a timer from my flash file, but I’m sure there should be a more elegant way to do it.  
Thanks in advance
