# onLoad swf inside main swf

**URL:** <https://forum.kirupa.com/t/onload-swf-inside-main-swf/264562>\
**Category:** flash\
**Created:** [June 27, 2008, 7:22am UTC](https://forum.kirupa.com/t/onload-swf-inside-main-swf/264562 "2008-06-27T07:22:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dt694](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@dt694](https://forum.kirupa.com/u/dt694)\
**Post date:** [June 27, 2008, 7:22am UTC](https://forum.kirupa.com/t/onload-swf-inside-main-swf/264562/1 "2008-06-27T07:22:43Z")

</div>

My main swf (site.swf) contains a movie clip loader that loads a second swf “item\_menu.swf”. Inside this second swf, I also have a movie clip loader “cityLoader\_mc” that loads another swf “itemA1.swf” but the onLoad function only works for the button “A1\_btn”. It does not work to load the swf by default. Please help !  
Do I have to use something before onLoad since it’s not the root swf or something?

Here is the code

```auto
onLoad = function() {
	cityLoader_mc.loadMovie("itemA1.swf");
}
	
		
// Button actions
citySlider_mc.A1_btn.onRelease = function() {
	cityLoader_mc.loadMovie("itemA1.swf");
}

citySlider_mc.A2_btn.onRelease = function() {
	cityLoader_mc.loadMovie("itemA2.swf");
}

```

I am using flash CS3 with AS 2.0  
I would like to keep it super basic because I picked up Action Script two weeks ago.

Thanks for your help!!!

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 27, 2008, 8:14am UTC](https://forum.kirupa.com/t/onload-swf-inside-main-swf/264562/2 "2008-06-27T08:14:09Z")

</div>

**this.onLoad**?

also you may have to call the function to make sure

---

<div class="post-metadata">

**Author:** ![dt694](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@dt694](https://forum.kirupa.com/u/dt694)\
**Post date:** [June 27, 2008, 6:05pm UTC](https://forum.kirupa.com/t/onload-swf-inside-main-swf/264562/3 "2008-06-27T18:05:29Z")

</div>

Hey “randomagain” !  
Thanks a lot for your answer, I just tried “this” (see below) but unfortunately it did not work. Would you have any other suggestions to load that swf by default as it is being loaded too?

```auto
this.onLoad = function() {
	cityLoader_mc.loadMovie("itemA1.swf");
}
	
		
// Button actions
citySlider_mc.A1_btn.onRelease = function() {
	cityLoader_mc.loadMovie("itemA1.swf");
}

citySlider_mc.A2_btn.onRelease = function() {
	cityLoader_mc.loadMovie("itemA2.swf");
}

```

Thanks.

S.
