PDA

View Full Version : Exchange Variables between PHP and ActionScript


Zeek
01-14-2002, 09:20 PM
I want to call an PHP3-script out of action-script (with sending an
variable "person") and get back another variable (depending on
the first) to use in ActionScript.

To do this I used:
>>
person="bob"
loadVariablesNum ("get.php3", 0, "GET");
<<

in ActionScript. The PHP3-script does the following:
>>
clearstatcache ();
$exist = "";
$exist = file_exists ("$person.txt");
if ($exist == 1){
$lines = file("$person.txt");
$output = trim($lines[0]);
/* I need the first line only and want to drop the rest */
echo("&newmessage=$output");}
<<

Now I want to use the variable "newmessage" in ActionScript. I
created a text field "text" (multi line, html) and added the
following code to a button:
>>
on (release) {
text+=newmessage;
} /*to append the text to the existing.*/
<<

All that seems to work.. but the problem I have is, that the
output seems to be a bit buggy by linefeeds.

e.g. If the content of "bob.txt" (which the PHP will read out)
is "Hello world<br>" (not more not less) and I click the button for
three times, my text field looks like:
>>
Hello world


Hello world


Hello world



>>

But it should look like:
>>
Hello world
Hello world
Hello world
<<

If I call the PHP3-script in my browser by typing
"www.domain.com/script.php3?name=bob" I get back:
>>
Hello world

<<

So where do the linefeeds come from and what can I do to
remove them? Please help! :confused:


Zeek

Jesse
01-15-2002, 03:57 AM
Does it happen when your field isn't HTML enabled?

hccfilms
01-15-2002, 09:45 AM
Is it possible to use CSS with the text file??
If so, I can help u....

Zeek
01-15-2002, 02:48 PM
Hey Jesse,

I tried it with an non-html text field.. now the result (after clicking
three times) is:
>>
Hello world<br>

Hello world<br>

Hello world<br>

<<

So there's still the same problem.. :( Please help...

Zeek

Zeek
01-15-2002, 02:54 PM
Hey hccfilms,

I guess even a html related text field in Flash isn't able to
interpret CSS... and the text file itself is written by a php3-
Script.

But I would like to read your idea anyways...

Greetz,

Zeek

Zeek
01-15-2002, 03:23 PM
To everybody:

To figure out what the problem is, I added another text field to
my flash film called "leng".. after pushing the button, ActionScript
does the following:
>>
[...]
leng=length(newmessage);
<<

After executing I got the following result (after cllicking twice):

Main text field:
>>
Hello world<br>

Hello world<br>

<<

And the other text field (saying the length of the string):
>>
17
<<

That would explain the two additional line feeds (cause "Hello
world<br>" is not longer than 15 characters long...

So is there any command in ActionScript to cut off the string... e.g.
like the "mid"command in Visual Basic. Then I could do the
following:
>>
-cutcommand-(newmessage, length(newmessage)-2);
<<

or something... hope yall understand what I mean :confused:

Zeek

Zeek
01-15-2002, 04:00 PM
I got... yeah baby I got it *sing*

I've found the "cut command" I was searching for myself.. I just
had to add it before "newmessage" was appended. Now the
ActionScript looks like:
>>
on (release) {
newmessage=newmessage.substring(0, length(newmessage)-2);
text+=newmessage;
}
<<

That was the solution!

Thanx to everybody,

Zeek