As3 loading swf + class access

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