# Assign Global Variable

**URL:** <https://forum.kirupa.com/t/assign-global-variable/264526>\
**Category:** flash\
**Created:** [June 26, 2008, 9:19pm UTC](https://forum.kirupa.com/t/assign-global-variable/264526 "2008-06-26T21:19:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 26, 2008, 9:19pm UTC](https://forum.kirupa.com/t/assign-global-variable/264526/1 "2008-06-26T21:19:56Z")

</div>

Okay me and XML @^$7#@!!

I’ve set up a multi-lingual fla now where you select your language with a button on the first frame and that loads in the equivalent xml file. Now Later in my swf I’m trying to load in another swf with loadMovie but I’d like to assign conditional statements to determine what xml is loaded.

for code thus far I have  
//first frame  
var myXML:XML = new XML();  
myXML.ignoreWhite = true;  
loadXMLfunc.onLoad = function(ok:Boolean):Void {

//on buttons  
eng\_btn.onRelease = function() {  
myXML.load(“english.xml”);  
\_global.myXML = “english” //not sure on this bit  
gotoAndPlay(2);

};

//movieclip  
if (\_global.myXML = “english”) {  
loadMovie(“cat.swf”, “level\_1”);  
}else if (\_global.myXML = “french”) {  
loadMovie(“chat.swf”, “level\_1”);  
}

Any advice would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 26, 2008, 10:01pm UTC](https://forum.kirupa.com/t/assign-global-variable/264526/2 "2008-06-26T22:01:58Z")

</div>

\_global.myXML = “english” //not sure on this bit

you’ll have to send a variable or create a variable

so when the MC loads it checks the variable and loads in the respective XML…:stare:

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 27, 2008, 1:53am UTC](https://forum.kirupa.com/t/assign-global-variable/264526/3 "2008-06-27T01:53:04Z")

</div>

Sorry wasn’t being very clear with my question.  
I have the main timeline that changes all the text  
//first frame  
var myXML:XML = new XML();  
myXML.ignoreWhite = true;  
loadXMLfunc.onLoad = function(ok:Boolean):Void {

//on buttons  
eng\_btn.onRelease = function() {  
myXML.load(“english.xml”);  
gotoAndPlay(2);

fr\_btn.onRelease = function() {  
myXML.load(“french.xml”);  
gotoAndPlay(2);  
};

This works fine to this point.  
Now I don’t want to load any more xml into my movieclip I just want flash to check what xml file has already been loaded in order assign a conditional statement  
ie if “english.xml” is loaded then load “cat.swf”,"holder\_mc"  
else if “french.xml” is loaded then load “chat.swf”,“holder\_mc”

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 27, 2008, 5:40pm UTC](https://forum.kirupa.com/t/assign-global-variable/264526/4 "2008-06-27T17:40:57Z")

</div>

So I’m slowly getting there.

on the first frame main timeline  
var babel = “”;

on my buttons I have

eng\_btn.onRelease = function() {  
myXML.load(“english.xml”);  
babel = “english”;  
gotoAndPlay(2);

=“french” ect ect

I can see the var changing in the output

Stuck on the conditional statment in my external movieclip  
onEnterFrame = function() {  
if (\_root.babel == “english”){  
trace(hello);  
}else if (\_root.babel == “french”){  
trace(bonjour);  
}  
}

tried many variations of this and only get “undefined”

Pulling my hair out on this one last step to a big project any advice?
