Simple Actionscript Syntax question

ryanmm

Member
Messages
38
Reaction score
0
Points
6
just trying to pass some variables from flash to php with getURL

getURL("CompSummary.php?url3=" + url3, "_self");

url3 keeps coming back as undefined

However I printed out url3 using dynamic text in the flash movie just to check it and it does indeed exist, and is defined.

I also tried creating a string and passing that to getURL

var path = "CompSummary.php?url3=" + url3;
getURL(path, "_self");

still no luck.

ideas?
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
Some Basic tutorial.Hope this helps.
<?
$first="this";
$second = "that";

echo "myfirst=$first&mysecond=$second";
exit;
?>

Flash Actionscript:

var lvSend = new LoadVars();
var lvReceive = new LoadVars();
lvSend.SendAndLoad("www.domain.com/script.php",lvReceive,"POST");

lvReceive.onLoad = function(bSuccess) {
if(bSuccess == true) {
trace(this.myfirst);
trace(this.mysecond);
}
}
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Is the undefined variable problem in the Flash movie, or in the PHP script? If the latter, why have you not shown sample PHP code?
 

ryanmm

Member
Messages
38
Reaction score
0
Points
6
no the problem is with the actionscript.

The variable DOES exist in the movie and IS set to the right value.

I set some dynamic text to = the value of url 3 just to test this very thing.

when the movie is launched, right there at the top of the screen, it says "url3 = 123456"

i got this simply by coding:

_root.myDynText = url3;

so url3 is defined and has a value in the movie.

however when I try to use getURL to reload the page based on url3
getURL("CompSummary.php?url3=" + url3, "_self");
it doesnt work, url3 isn't being passed
I would guess this really is a syntax problem with
getURL("CompSummary.php?url3=" + url3, "_self");

I tired using a string:

var path = "CompSummary.php?url3=" + url3;
getURL(path, "_self");

this didnt work either.

however, if i do this:
_root.myDynText = path;

CompSummary.php?url3=123456
prints out just fine

its like getURL just wont accept variables
 
Last edited:

ryanmm

Member
Messages
38
Reaction score
0
Points
6
Here's the php. it works like a gem with everything except this flash

PHP:
$_SESSION['url3'] = $_GET['url3'];

//if url3 doesnt exist, exit
if(!isset($_SESSION['url3']))
{
	PrintError('Sorry, url3 doesn\'t exist.','index.php');
	exit;
}
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Here's the php. it works like a gem with everything except this flash
How do you know? Do you mean if you browse to "CompSummary.php?url3=123456" in a browser, you don't get the message that url3 doesn't exist?

You apparently haven't read my sig, nor the site from a previous link on posting sample code as you haven't written a complete sample. After filling out the scraps posted thus far into a complete example, there's no issue I see with undefined values.

get.as (compiled with mtasc):
Code:
class GetTest extends MovieClip {
    static var base:String = 'CompSummary.php';
    static var url3:String = '123456';

    public function onLoad () {
         this.getURL(base + '?url3=' + url3, '_self');
    }
}

getter.xml (compiled with swfmill):
Code:
<?xml version="1.0" encoding="iso-8859-1" ?>
<movie version="8" width="80" height="16" framerate="12">
  <background color="#FFFFFF"/>
  <frame>
    <library>
      <clip id="getst" import="build/get.swf" class="GetTest" />
    </library>
    <place id="getst" name="getter" depth="1" />
  </frame>
</movie>

CompSummary.php:
PHP:
<?php
header('Content-type: text/plain');

function PrintError($msg, $file) {
    echo $msg;
}

# even without calling session_start(), this works
$_SESSION['url3'] = $_GET['url3']; 

if(!isset($_SESSION['url3'])) {
    PrintError('Sorry, url3 doesn\'t exist.','index.php'); 
    exit; 
} 

echo "url3: $_SESSION[url3]\n";

index.html
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head><title></title></head>
  <body>
    <object data="getter.swf" type="application/x-shockwave-flash" id="getter" height="50" width="200">
      <param value="sameDomain" name="allowScriptAccess" />
      <param value="high" name="quality" />
      <param value="#FFFFFF" name="bgcolor" />
    </object>
  </body>
</html>

Opening index.html results in the loading of page "CompSummary.php?url3=123456".
 

ryanmm

Member
Messages
38
Reaction score
0
Points
6
The problem is in the flash actionscript, not the php.
I have solved the problem a different way by making a new php file that the flash refers to.
instead of "compsummary.php?id=123456" its now "ReloadFromFlash.php" Then I use a session var to get "123456"
Your code looks excellent, btw. Thank you for trying to help me.
 
Last edited:
Top