Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Using Variables- I Pray To You Gods of AS3/PHP and Flash For Help!

New Here ,
Oct 22, 2010 Oct 22, 2010

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.

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 23, 2010 Oct 23, 2010

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

...
Translate
Community Expert ,
Oct 23, 2010 Oct 23, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 23, 2010 Oct 23, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 23, 2010 Oct 23, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 23, 2010 Oct 23, 2010
LATEST

You are welcome.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines