# Calling user defined function

**URL:** <https://forum.kirupa.com/t/calling-user-defined-function/289208>\
**Category:** flash\
**Created:** [May 27, 2009, 2:44pm UTC](https://forum.kirupa.com/t/calling-user-defined-function/289208 "2009-05-27T14:44:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kukoobash](https://avatars.discourse-cdn.com/v4/letter/k/a3d4f5/32.png) [@kukoobash](https://forum.kirupa.com/u/kukoobash)\
**Post date:** [May 27, 2009, 2:44pm UTC](https://forum.kirupa.com/t/calling-user-defined-function/289208/1 "2009-05-27T14:44:57Z")

</div>

Hi,

First Off a disclaimer: I am sorry if there is a similar posting out there. I have tried searching for a solution and I guess I am too pooped out to even think of better keywords to find a solution.

**Scenario:**

I am trying to load external swf’s into my main swf through nested movieclips.  
Its like this: STAGE \> contents\_mc \> loader\_mc  
Also most of the code is from tutorial’s out on the net.

[COLOR=Blue] **Content\_mc** [/COLOR]  
I have the following MC’s in content\_mc (on 2 separate layers, if you want to know):

- Preloader\_text (PText)
- loader\_mc (LoaderExt)

**Actions on content\_mc:**

```auto

pText._visible = false;
[COLOR=DarkOrchid]**LoaderExt.ClipLoader("home.swf");**
[/COLOR]
function preLoadStart(): Void{[INDENT]pText._visible = true;
[/INDENT]}
    
function preLoadProgress(lBytes, tBytes){

    pText.text = "% "+Math.round((lBytes/tBytes)*100);
 }
 
function preLoadComplete(): Void {

    pText._visible = false;
 }

```

[COLOR=Blue]\*\*  
loader\_mc \*\*[/COLOR](name LoaderExt)

Nothing on the timeline yet

**Actions of loader\_mc:**

```auto

var myMCL = new MovieClipLoader();//create an instance of MovieClipLoader

myMCL.onLoadStart = function (targetMC)
{ trace("------------START ON LOAD
");
        var loadProgress = myMCL.getProgress(targetMC);
        _parent.preLoadStart();
}
myMCL.onLoadProgress = function (targetMC, loadedBytes, totalBytes) {
        
        _parent.preLoadProgress(loadedBytes, totalBytes);

}
myMCL.onLoadComplete = function (targetMC)
{        
        trace("END ON LOAD-----------------");
        var loadProgress = myMCL.getProgress(targetMC);
        _parent.preLoadComplete();
}
myMCL.onLoadInit = function (targetMC)
{
        trace ("Movie clip:" + targetMC + " is now initialized");
        //targetMC._width = 605;
        //targetMC._height = 1048;

}
myMCL.onLoadError = function (targetMC, errorCode)
{
        trace ("ERRORCODE:" + errorCode);
        trace (targetMC + "Failed to load its content");
}

[COLOR=DarkOrchid]**function ClipLoader(ClipToLoad): Void{

    trace("IN LOAD CLIPS");
    myMCL.loadClip(ClipToLoad, this);
}**[/COLOR]

```

**Problem** :  
I am having a problem in calling the function ClipLoader and loading a clip through the loader\_mc MovieClip (the text in **[COLOR=DarkOrchid]Purple[/COLOR]**). The reason I am using this is eventually I will put in code in contents\_mc to load various external swf per conditions i give.

Please please please help. I have a feeling it is a very simple thing that I am forgetting/skipping or I have totally messed up my MC setup…

Thanks in Advance!
