# Onload not running!

**URL:** https://forum.kirupa.com/t/onload-not-running/42530
**Category:** Uncategorized
**Created:** [February 10, 2004, 2:49am UTC](https://forum.kirupa.com/t/onload-not-running/42530 "2004-02-10T02:49:07Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![hga77](https://avatars.discourse-cdn.com/v4/letter/h/4bbf92/32.png) [@hga77](https://forum.kirupa.com/u/hga77)
#### Post date: [February 10, 2004, 2:49am UTC](https://forum.kirupa.com/t/onload-not-running/42530/1 "2004-02-10T02:49:07Z")

</div>

This should be easy to answer…

I have 2 swf’s:

Section.swf (to be loaded in main)  
Main.swf

In section.swf, on the first frame I have this:

[AS]  
onLoad = function(){  
// start doing stuff  
}[/AS]  
When I run the section.swf on its own, the onload function works, and the “doing stuff” code runs. But when I load it into main, this onload (within the section.swf, above) does not run!

I desperately need to fix this. Any help please…thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 2:52am UTC](https://forum.kirupa.com/t/onload-not-running/42530/2 "2004-02-10T02:52:20Z")

</div>

take everything out of onload and just stick it in the timeline.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 2:55am UTC](https://forum.kirupa.com/t/onload-not-running/42530/3 "2004-02-10T02:55:24Z")

</div>

I did that, the code still wont run!!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 2:56am UTC](https://forum.kirupa.com/t/onload-not-running/42530/4 "2004-02-10T02:56:02Z")

</div>

whats the code?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 3:05am UTC](https://forum.kirupa.com/t/onload-not-running/42530/5 "2004-02-10T03:05:42Z")

</div>

ok…  
just look at the onload function on the top…

[AS]  
this.onLoad = function() {  
/_Initialise variables_/  
stage\_width = 512;  
stage\_height = 384;  
var image\_Initial\_Position\_x = -(stage\_width/2);  
var image\_Initial\_Position\_y = -(stage\_height/2);  
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
MovieClip.prototype.useHandCursor = false;  
window = this.createEmptyMovieClip(“border”, 2);  
border.beginFill (0xFF0000, 100);  
border.lineStyle(1, 0, 100);  
border.lineTo(stage\_width, 0);  
border.lineTo(stage\_width, stage\_height);  
border.lineTo(0, stage\_height);  
border.lineTo(0, 0);  
endFill();  
setMask(window);  
this.createEmptyMovieClip(“clip”,“clip”,1);  
clip.\_x = image\_Initial\_Position\_x;  
clip.\_y = image\_Initial\_Position\_y;  
clip.loadMovie(“car original.jpg”);  
preload(clip);  
};  
[/AS]

outside this function (onload) I have proto functions, but that all works fine…

I just need the onload to run when this fla is being loaded into the main.

Thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 3:17am UTC](https://forum.kirupa.com/t/onload-not-running/42530/6 "2004-02-10T03:17:04Z")

</div>

and when I dont include the onload function, the preload(clip) function call doesnt run.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 10:56am UTC](https://forum.kirupa.com/t/onload-not-running/42530/7 "2004-02-10T10:56:44Z")

</div>

bottom line, onLoad isnt used like that. You would basically only use it with OOP classes associated with movieclips.

where is preload defined?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 10, 2004, 1:44pm UTC](https://forum.kirupa.com/t/onload-not-running/42530/8 "2004-02-10T13:44:03Z")

</div>

thanks senocular …I just changed the onload to a this.onEnterFrame function and it worked…thanks again
