# Passing variables from parent swf to child swf

**URL:** <https://forum.kirupa.com/t/passing-variables-from-parent-swf-to-child-swf/330650>\
**Category:** flash\
**Created:** [February 22, 2013, 2:11am UTC](https://forum.kirupa.com/t/passing-variables-from-parent-swf-to-child-swf/330650 "2013-02-22T02:11:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roundpaws](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@roundpaws](https://forum.kirupa.com/u/roundpaws)\
**Post date:** [February 22, 2013, 2:11am UTC](https://forum.kirupa.com/t/passing-variables-from-parent-swf-to-child-swf/330650/1 "2013-02-22T02:11:13Z")

</div>

[LEFT][COLOR=#000000][FONT=Arial]I am having problems so I made a very basic main.swf that loads sub.swf.[/FONT][/COLOR][COLOR=#000000][FONT=Arial]Sub.swf has 2 rectangle movieclips (red and blue) that have their alpha = 0.[/FONT][/COLOR][COLOR=#000000][FONT=Arial]Both swfs compile fine and no errors but the red alpha does not get turned on so the value of “spanish” from main.swf variable must not be getting recognised in sub.swf. Any ideas?

[/FONT][/COLOR][COLOR=#000000][FONT=Arial]Main.swf actionscript:

[/FONT][/COLOR][/LEFT]  
import flash.display.Loader;  
import flash.display.MovieClip;  
import flash.events.Event;

var child\_loader:Loader = new Loader();

var req:URLRequest = new URLRequest(“sub.swf”);

child\_loader.load(req);

child\_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

function done(e:Event):void{  
addChild(child\_loader);  
MovieClip(child\_loader.content).language = “spanish”;  
}

sub.swf actionscript:

import flash.display.Loader;  
import flash.display.MovieClip;  
import flash.events.Event;

function callFunction(\_txt:String):void{  
var sublanguage = (MovieClip(parent.parent).language);

```
if (sublanguage == "spanish"){
	red.alpha = 1;
}else if (sublanguage == "english"){
	blue.alpha = 1;
}

```

}
