FORUMS: list search recent posts

Random quotes in Flash with PHP

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Random quotes in Flash with PHP
on Jul 6, 2007 at 7:04:46 pm

I have this on timeline of a swf that is loaded into the main:

loadVariablesNum("quotes.php?noCache="+Math.floor(random(1000000)/random(1000)), 0);

There is a dynamic text box later in the timeline with the variable 'quote' assigned to it.

the php is:

echo ""e=$quotes[$random]";

text file has quotes, one per line like:

an apple a day.
this is another.

very simple, yet nothing displays in the box. Not even "Undefined"

I also tried combining the quotes inside of the PHP:

$quote = array(

1 => "a",

2 => "b",

3 => "c",

4 => "d",

5 => "e",


srand ((double) microtime() * 1000000);

$randnum = rand(1,5);



What else would I need to get this to work?

Return to posts index

Re: Random quotes in Flash with PHP
on Jul 7, 2007 at 8:46:29 am

Coupla thoughts.

Is that a typo at the start of >> echo ""e=$quotes[$random]";
should that ampersand be at the start of your output ..?

Don't you want to put quote marks around your "random quote string" ?

You want your php to output quote="some random quote" - is it doing that?

Should your echo be
echo "quote = '"'.$quotes[$random].'"' " ;
or some other device to get the " signs around your ouput, after the equals sign ..?

Then when Actionscript gets
quote ="some random quote"

it should accept that as a variable definition.

AND - I wonder why you need the "+Math.floor(random(1000000)/random(1000))" addition to your url, and then whether it's working around your quotes placement ?

As your php should be generating a random quote anyway and outputting it, is there any need for a random element in the url ...?

Isn't there a cross-domain thing - you're testing with swf and php url in the same domain, or with a cross-domain policy file in place ...?

Return to posts index

Re: Random quotes in Flash with PHP
on Jul 7, 2007 at 12:38:46 pm

On testing, it seems that PHP accepts the vars using file() without or without qotes so scrub that last post !

If you're testing locally you may need to make sure you go through a webserver e.g locahost so that your php gets served as output. If this doesn't make sense, test on remote server ...

The text file needs one quote per line

try Flash :
loadVariablesNum("http://youraddress/quote.php", 2);

The variable name in the Flash file wants
an identifier for level - e.g;

For the php, try :
$random = (rand()%$number_quotes);
echo "quote=$quotes[$random]";

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved