# How to load the contact.swf into the main.swf?

**URL:** <https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551>\
**Category:** flash\
**Created:** [September 27, 2004, 6:27pm UTC](https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551 "2004-09-27T18:27:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsundqvi](https://avatars.discourse-cdn.com/v4/letter/t/49beb7/32.png) [@tsundqvi](https://forum.kirupa.com/u/tsundqvi)\
**Post date:** [September 27, 2004, 6:27pm UTC](https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551/1 "2004-09-27T18:27:08Z")

</div>

Hi  
I just made my first contact form with flash MX. It works very well. But when I load the contact.swf into main movie, something goes wrong because I receive empty e-mails. If I run (only) contact.swf by itself, I’ll get e-mail with content. I’m pretty sure that this is a very simple case but I can’t solve it by myself. I would be very happy if someone helped me.

Thanking in advance

**This is the code in the layer1 of contact.swf:**  
   
function clrData(){  
this.formData.name = “”;  
this.nameIn.text = “”;  
this.formData.company = “”;  
this.companyIn.text = “”;  
this.formData.address = “”;  
this.addressIn.text = “”;  
this.formData.zip = “”;  
this.zipIn.text = “”;  
this.formData.city = “”;  
this.cityIn.text = “”;  
this.formData.phone = “”;  
this.phoneIn.text = “”;  
this.formData.email = “”;  
this.emailIn.text = “”;  
this.formData.message = “”;  
this.messageIn.text = “”;  
phone2In.setValue(false);  
letterIn.setValue(false);  
email2In.setValue(false);  
permissionIn.setValue(true);

}

function myOnLoad(success){  
errBox.setEnabled(true);  
if(success){  
errBox.setIcon(“info”);  
errBox.setTitle(“Kiitos”);  
errBox.setMessage(“Kiitos viestistäsi. Vastaamme sinulle mahdollisimman nopeasti”);  
errBox.\_visible=true;  
clrData();  
}  
else{  
errBox.setIcon(“Virhe”);  
errBox.setTitle(“Järjestelmävirhe”);  
errBox.setMessage(“Valitettavasti lähetyksen aikana havaittiin ongelmia. Ole hyvä täytä ja lähetä lomake uudelleen”);  
errBox.\_visible=true;  
}  
}  
function goPostal(){

errBox.setIcon(“info”);  
errBox.setTitle(“Viestiä lähetetään”);  
errBox.setMessage(“Viestiä lähetetään”);  
errBox.\_visible=true;  
errBox.setEnabled(false);  
formData.sendAndLoad(“[http://sloop.fi/cgi-bin/mail.cgi](http://sloop.fi/cgi-bin/mail.cgi)”, replyData, “post”);  
}

**And here’s the code in layer2 (contact.swf):**  
   
formData = new LoadVars();  
formData.name = “”;  
formData.company = “”;  
formData.address = “”;  
formData.zip = “”;  
formData.city = “”;  
formData.phone = “”;  
formData.email = “”;  
formData.message = “”;  
formData.phone2 = “”;  
formData.letter = “”;  
formData.email2 = “”;  
formData.permission = “”;  
replyData = new LoadVars();  
replyData.onLoad = myOnLoad;  
globalStyleFormat.FMessageBoxTitleText = new TextFormat( “Arial Bold”, 15, 0xffffff);  
globalStyleFormat.applyChanges();  
errBox.setButtonWidth(50);

**This is the code of contact button in the main movie (main.swf):**

on (release) {  
loadMovieNum(“contact.swf”, 1);  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2004, 11:53am UTC](https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551/2 "2004-09-28T11:53:15Z")

</div>

i figure you have a submit button in the contact swf, the loadmovie becomes a level, so in order to target the contact swf, \_leveln should be used.(the n being the integer correlating with the depth of the loaded movie), as with \_root.movieclip, \_leveln.target, so everywhere you have a targeting, like formdata.name, it’s line should be \_leveln.formdata.name.

the rationale is this, when you have the contact swf, it is written in the first person, ie, \_root is the constant, when contact.swf is brought within another, the dynamics change, the writing then becomes third person as \_root. no longer applies, as it is the shell or main swf. so in effect, you collect data and it’s inaccessable, because you didn’t define where it is located. I hope this helps  
tumuat

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2004, 8:19pm UTC](https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551/3 "2004-09-28T20:19:43Z")

</div>

Hi,

Yeah, I finally solved my mystery problem - thanks for your support. I changed the code of contact button into the main movie. Here’s the new code:

on (release) {  
\_root.currMovie = “yhteystiedot”;  
container.loadMovie(\_root.currMovie+".swf");  
}

I Created a new empty movie clip (name: container (Instance name is also container)) into the main.swf.

**This is how the code changed into the contact.swf:**

Layer2:

\_root.formData = new LoadVars();  
\_root.formData.name = “”;  
\_root.formData.company = “”;  
\_root.formData.address = “”;  
\_root.formData.zip = “”;  
\_root.formData.city = “”;  
\_root.formData.phone = “”;  
\_root.formData.email = “”;  
\_root.formData.message = “”;  
\_root.formData.phone2 = “”;  
\_root.formData.letter = “”;  
\_root.formData.email2 = “”;  
\_root.formData.permission = “”;  
replyData = new LoadVars();  
replyData.onLoad = myOnLoad;  
globalStyleFormat.FMessageBoxTitleText = new TextFormat( “Arial Bold”, 15, 0xffffff);  
globalStyleFormat.applyChanges();  
errBox.setButtonWidth(50);

**The code which located in layer1 didn’t change at all.**

I’m very grateful for your support. It is very nice to see this forum really works.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 29, 2004, 1:33am UTC](https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551/4 "2004-09-29T01:33:31Z")

</div>

ahhh… i see, nice use of corrective surgery… shoulda seen that, but i am blind when it comes to simplicity…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 2, 2004, 1:32am UTC](https://forum.kirupa.com/t/how-to-load-the-contact-swf-into-the-main-swf/65551/5 "2004-10-02T01:32:48Z")

</div>

> I’m very grateful for your support. It is very nice to see this forum really works.

yes it does really work, its helped me out of a couple of pickles, and its wonderful to see another happy user 😉
