# As3 loading swf + class access

**URL:** <https://forum.kirupa.com/t/as3-loading-swf-class-access/317552>\
**Category:** flash\
**Created:** [December 24, 2010, 7:55am UTC](https://forum.kirupa.com/t/as3-loading-swf-class-access/317552 "2010-12-24T07:55:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnsto](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@johnsto](https://forum.kirupa.com/u/johnsto)\
**Post date:** [December 24, 2010, 7:55am UTC](https://forum.kirupa.com/t/as3-loading-swf-class-access/317552/1 "2010-12-24T07:55:42Z")

</div>

Hello,

I am new to flash and as3 and i would like to ask a few things regarding sub loading external swf files.

I am experimenting with subloading multiple swf files to a main swf. As i have it so far (and it doesn’t work) is :

I have a main.swf with a main\_class attached and i load in it external swf files that each has a class attached to it that handles some actions on stage elements of each sub swf

Main.swf - main\_class loads:

sub1.swf - sub\_class1  
sub2.swf - sub\_class2  
…

Loading and adding child elements to the main swf works fine but when i make a call to sub\_class from the main.swf in order to access an element in the sub swf i get an 1120: Access of undefined property sub\_elem. (sub\_elem is a MC on the sub swf stage)

var sub:sub\_class1 = new sub\_class1();   
sub.setUpPage();

I have observed 2 things:

1. if i have an action in the sub\_swf init(e) function say sub\_elem.alpha=0;  
I get the 1120 error

2)If i call a function in the sub swf like: sub.setUpPage();  
public function setUpPage():void{ sub\_elem.alpha=0;}

I don’t get an error but the action to make the alpha=0 doesn’t happen.

Is my whole approach wrong? Should i have only one class that contains functions for all swf files + elements attached only on the main.swf or splitting the whole project to individual swf files with their own class and elements is correct?

Any help is greatly appreciated.

Thanks,  
Johnsto
