# Dispatchevent to Child

**URL:** <https://forum.kirupa.com/t/dispatchevent-to-child/270481>\
**Category:** flash\
**Created:** [September 10, 2008, 12:26pm UTC](https://forum.kirupa.com/t/dispatchevent-to-child/270481 "2008-09-10T12:26:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jareish](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@Jareish](https://forum.kirupa.com/u/Jareish)\
**Post date:** [September 10, 2008, 12:26pm UTC](https://forum.kirupa.com/t/dispatchevent-to-child/270481/1 "2008-09-10T12:26:10Z")

</div>

I’ve got 2 files. Main.swf loads text.swf and then dispatches an event to text.swf to let it know what text to load in it’s textfield. After reading ton’s of tutorials and googling for hours I still can’t figure it out.

Main.swf:

```auto
 
var theText:String = "text1";
var loader:Loader = new Loader();
loader.load(new URLRequest("text.swf")); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addme);
 
function addme(e:Event)
{
 addChild(loader);
 dispatchEvent(new Event("Changer", true)); 
}

```

text.swf

```auto
 
addEventListener("Changer", CreateTextfield);
function CreateTextfield(event:Event)
{
 trace(event.target.theText)
}

```

I don’t get any errors, except if I mispell “Changer” or leave the quotes out. That makes me think the code is fine. If I put the dispatchevent in text.swf It works. It just wont work when I put it in main.swf

I don’t get it. Every tutorial I found starts talking about custom event classes, importing them and public this, private that. So I tried that aproach, by importing a custom event class in both files, put them all in 1 folder. I tried different custom event classes I found on the web. No success.

Do I approach this wrongly?
