# Reference Main Document Class from the Document Class of a loaded (child) swf

**URL:** <https://forum.kirupa.com/t/reference-main-document-class-from-the-document-class-of-a-loaded-child-swf/322021>\
**Category:** flash\
**Created:** [May 7, 2011, 1:33pm UTC](https://forum.kirupa.com/t/reference-main-document-class-from-the-document-class-of-a-loaded-child-swf/322021 "2011-05-07T13:33:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lotus\_](https://avatars.discourse-cdn.com/v4/letter/l/9fc29f/32.png) [@lotus\_](https://forum.kirupa.com/u/lotus_)\
**Post date:** [May 7, 2011, 1:33pm UTC](https://forum.kirupa.com/t/reference-main-document-class-from-the-document-class-of-a-loaded-child-swf/322021/1 "2011-05-07T13:33:30Z")

</div>

I have a FLA (say Main.FLA) document class with a child MovieClip on the stage: into the child MovieClip I load other swf files: **each of the files contains its own Document Class** (every swf is a somewhat independent application, say quizzes and so on). For some reason I must use the **Main** document class to store data (scores or so) from the child swfs loaded into the Main swf.

**HOW do I reference the Main class?** I can’t find a way.

Someone suggested me to use Events.  
He said I could use a class similar to this one in the child swf:

package {  
import flash.events.Event;

```
public class QuestionAnsweredEvent extends Event {
    public static const QUESTION_ANSWERED:String = "QuestionAnswered";
    public var data:*;

    public function QuestionAnsweredEvent(type:String, data:*) {
        this.data = data;
        super(type, true);
    }
}

```

}  
and dispatch an Event this way from the loaded swf document class to the Main class:

dispatchEvent(new QuestionAnsweredEvent(QuestionAnsweredEvent.QUESTION\_ANSWERED, questionData));

Now, first of all I don’t know if this could even work. Secondly, I tried to make it work by adding an event listener to my Main class but id did not work.

Could you please suggest me a way to do what I should do?

Thanks!
