Copy link to clipboard
Copied
Please oh PLEASE!!! You kind souls, help this wretched person.
Cannot get my variables to work. My relevant sections of code:
AS3:
var request:URLRequest = new URLRequest ("http://www.XXXXX.com/pages/XXXX/XXXXindex.php");
request.method = URLRequestMethod.POST;
var flashvars:URLVariables = new URLVariables();
flashvars.idtag = this.loaderInfo.parameters.id;
flashvars.hoster = "";
flashvars.guest = "";
request.data = flashvars;
var loader:URLLoader = new URLLoader (request);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
function onComplete (event:Event):void
{
var flashvars:URLVariables = new URLVariables( event.target.data );
hoster.String = flashvars.hoster;
guest.String = flashvars.guest;
}
var hoster;
var guest;
PHP index.php:
<?php
$hoster = $_COOKIE['hoster'];
$guest = $_POST[guest];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>record</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var swfVersionStr = "10.1.52";
var xiSwfUrlStr = "";
var flashvars = "hoster:<?php echo (urlencode($hoster)) ?>&guest:<?php echo (urlencode($guest))?>";
var params = {};
params.quality = "high";
params.bgcolor = "#d0e2ff";
params.play = "true";
params.loop = "true";
params.wmode = "window";
params.scale = "showall";
params.menu = "true";
params.devicefont = "false";
params.salign = "";
params.allowscriptaccess = "sameDomain";
var attributes = {};
attributes.id = "record";
attributes.name = "record";
attributes.align = "middle";
swfobject.createCSS("html", "height:100%; background-color: #d0e2ff;");
swfobject.createCSS("body", "margin:0; padding:0; overflow:hidden; height:100%;");
swfobject.embedSWF("record.swf?hoster:<?php echo (urlencode($hoster)) ?>&guest:<?php echo (urlencode($guest))?>", "flashContent","750", "650", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
Page loads, but no action. Please tell me what I am missing or doing wrong.
No matter how you get variables - from text file by using URLLoader or from FlashVars - you need to present them as url query string. In query string equal character - not colon - is used to separate pares.
Flash cannot read PHP script variables directly. Again, you need to return text.
In PHP your index file should be something like:
echo ("hoster= $_COOKIE['hoster'];&guest=$_POST[guest]");
If you want to pass flash vars in the embed code:
To read FlashVars from embed code you need to get parameter
...Copy link to clipboard
Copied
It looks like you are trying to pick up a flashvars variable from SWFObject and then add it to your URLVariables object which you have also named flashvars right?
If so in your html shell try this:
var flashvars = {};
flashvars.id = "hoster:<?php echo (urlencode($hoster)) ?>&guest:<?php echo (urlencode($guest))?>";
and then in ActionScript you need to reference the stage to pick up the flashvars id variable, so:
var flashvars:URLVariables = new URLVariables();
this.stage.loaderInfo.parameters.id;
Just make sure this.stage is not null and is actually the stage.
Copy link to clipboard
Copied
No matter how you get variables - from text file by using URLLoader or from FlashVars - you need to present them as url query string. In query string equal character - not colon - is used to separate pares.
Flash cannot read PHP script variables directly. Again, you need to return text.
In PHP your index file should be something like:
echo ("hoster= $_COOKIE['hoster'];&guest=$_POST[guest]");
If you want to pass flash vars in the embed code:
To read FlashVars from embed code you need to get parameters object from loaderInfo of your application.
Here is documentation:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html
Copy link to clipboard
Copied
Knew it had to be a small thing and it was, found it last night. Replaced hoster:<.... with hoster =<.... and works. Thanks for your input all. Us newbies really depend on folks like you.
Copy link to clipboard
Copied
You are welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now