# When to use onClipEvent(load)?

**URL:** https://forum.kirupa.com/t/when-to-use-onclipevent-load/84653
**Category:** Uncategorized
**Created:** [March 29, 2005, 2:16pm UTC](https://forum.kirupa.com/t/when-to-use-onclipevent-load/84653 "2005-03-29T14:16:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Rasper](https://avatars.discourse-cdn.com/v4/letter/r/9fc29f/32.png) [@Rasper](https://forum.kirupa.com/u/Rasper)
#### Post date: [March 29, 2005, 2:16pm UTC](https://forum.kirupa.com/t/when-to-use-onclipevent-load/84653/1 "2005-03-29T14:16:00Z")

</div>

I’m having some trouble with this statement.

I want to initialize a few variables when the playhead encounters a movieclip, thus loading it. Normally, you would have to simply use [size=1][color=navy]onClipEvent(load) { }[/color][/size]  
But in order to use this, you have to put this code on the object itself, and can’t use it in the following manner: [size=1][color=navy]mc\_ball.onClipEvent(load){ }[/color][/size]  
This would result in an error.

But that’s exactly what I need, since I don’t want the code to reside on the object itself, but in a framescript.  
So I tried this code: [size=1][color=navy]mc\_ball.onLoad = function() { }[/color][/size] But this doesn’t do anything. No errors, but it simply doesn’t do anything. That’s probably because this is only used in combination with the [size=1][color=navy]\_root.loadMovie(“mc\_ball”)[/color][/size] statement? So, it works only when you dynamically load a movie from the library?

So my question: How can I execute a piece of code when a movieclip is loaded, without having to put the code in a movieclip-script, but in a framescript???

Thanks in advance,  
Kasper
