Groups | Blog | Home
all groups > flash actionscript > september 2004 >

flash actionscript : need help to LoadVars


Cata M
9/23/2004 10:16:24 PM
i have a php file that generates an array and the length of this array

//php file

$picture //array
$length

and a *.fla file that loads this variamles like this:

//fla file

on (release)
{
var myData = new LoadVars();
myData.load("test.php","get");
myData.onLoad = function()
{
var pictures = myData.pictures;
var length = myData.length;
trace(length);
};
}

the problem is that after i push the button the variables are still not
asigned, how do i correct this. also i want to learn how to transmit variables
from flash to an external php. i know that it can be done with my_var.send, but
how?

any help is apreciated!

_____
Cata M
Mr Tomo
9/23/2004 11:12:15 PM
Hi,

To get the php variables try:
button.onRelease = function(){
loadVariables("test.php", 0, "GET");
}

....then just split your php array up.

To post variables back out again try:

btn.onRelease = function(){

ExternalVar1 = internalValue1;
ExternalVar2 = internalValue2;

loadVariablesNum("outward.php", 0, "POST");
}





Cata M
9/24/2004 12:41:17 PM
Sorry, I have tryed loadVariables(), long a go, but no luck. I was able to load in a textfield a variable from a text file, but that was all... any other suggestion?

_____
Cata M
Mr Tomo
9/24/2004 11:17:11 PM
...then you must be displaying your php string incorrectly. It should look like this "MyString=variable1&variable2 etc...

Cata M
9/24/2004 11:58:19 PM
my php looks like this:

<?php
$a=1;
// this function constructs $img array, that contain the name of the pictures
in the $current_dir
//in the final version the current dir whil by dynamicaly asigned
function construct_array()
{ $current_dir = 'c:\inetpub\wwwroot\xxx\pictures';
$dir = opendir($current_dir);
$i = -1;
while ($file = readdir($dir))
{
$i++;
$img[$i] = $file;
}
closedir($dir);
return $img;
};
// this function returns the length of the above array
function array_length()
{
$img = construct_array();
$i = 0;
while ($img[$i]!='')
{
$i++;
};
$l = $i-1;
return $l;
};
//$picture is the array that contains the name of the pictures from
$current_dir
//this variable will be passed to flash
$pictures = construct_array();
//$length is the length of $pictures array
//this variable will be passed to flash
$length = array_length();
?>
AddThis Social Bookmark Button