# Question about Flash and Javascript

**URL:** https://forum.kirupa.com/t/question-about-flash-and-javascript/311477
**Category:** flash
**Created:** [July 7, 2010, 7:10pm UTC](https://forum.kirupa.com/t/question-about-flash-and-javascript/311477 "2010-07-07T19:10:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jesse2000](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jesse2000](https://forum.kirupa.com/u/jesse2000)
#### Post date: [July 7, 2010, 7:10pm UTC](https://forum.kirupa.com/t/question-about-flash-and-javascript/311477/1 "2010-07-07T19:10:33Z")

</div>

I want to send a variable to javascript, then in the javascript for it to take that flash variable and then evalute it using an if statement. Can I use the loadvars command?

[COLOR=“red”][COLOR=“DarkOliveGreen”]import flash.net.URLLoaderDataFormat;  
import flash.net.URLRequest;

// ----------------------------------------------------------------  
// Assign a variable name for our URLVariables object  
var variables:URLVariables = new URLVariables();  
// Build the varSend variable  
// Be sure you place the proper location reference to your PHP config file here  
var varSend:URLRequest = new URLRequest([COLOR=“Red”]“Javascript.js”[/COLOR]);  
varSend.method = URLRequestMethod.POST;  
varSend.data = variables;  
// Build the varLoader variable  
var varLoader:URLLoader = new URLLoader;  
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;  
varLoader.addEventListener(Event.COMPLETE, completeHandler);

```
	variables.select = answer_txt.text;
	variables.sendRequest = "loaded";	
	
	varLoader.load(varSend);[/COLOR][/COLOR]

```

Once it sends the variable I want to insert it into an if statement in in the javascript file

[COLOR=“Blue”]// JavaScript Document

\<script language=“JavaScript” type=“text/javascript”\>  
\<!–  
var SentVariable = “variable from Flash”;

if ( SentVariable = “loaded”) {  
do something  
}  
//–\>  
\</script\>[/COLOR]
