Connecting Tech Pros Worldwide Help | Site Map

php vars to flash

anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#1: Mar 11 '09
Hi,

How can i pass a random digit that is created using a php var into flash so i can use it in AS. Once its in AS what would i write so that the digit is show in flash?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Mar 11 '09

re: php vars to flash


Using flashvars.

Read: http://www.kirupa.com/developer/acti...gvariables.htm

Although, I'd suggest you use SWFObject to embed your flash and pass variables to the SWF.
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#3: Mar 11 '09

re: php vars to flash


thanks....i've just read through the blog page and I think it would be best to use SWFObject as well....seems much more safer and secure.....and more compatible with all browsers
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#4: Mar 11 '09

re: php vars to flash


Quote:

Originally Posted by anfetienne View Post

thanks....i've just read through the blog page and I think it would be best to use SWFObject as well....seems much more safer and secure.....and more compatible with all browsers

Sure thing.

Let me know if you hit any snags.

- Mark.
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#5: Mar 12 '09

re: php vars to flash


just a quick question.....when passing variables, i see in the swfobjec t they have it assigned to a dynaic text box. what i want is so that the variable is used only in actionscript....do i have to assign it to a text box or is there a way for this to just be used in actionscript?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#6: Mar 13 '09

re: php vars to flash


You don't have to assign anything to anything.

Say you're passing the flash vars like so:

Expand|Select|Wrap|Line Numbers
  1. window.onload = function()
  2.     {
  3.         var flashvars = {
  4.             testFlashVar: "Hello from Bytes.com!"
  5.         };
  6.             var params = {
  7.                 wmode: "transparent"
  8.             };
  9.             var attributes = {};
  10.             swfobject.embedSWF([...]);
  11.     }
  12.  
In your AS, the variable is available by (at root) :
Expand|Select|Wrap|Line Numbers
  1. trace( testFlashVar );
  2.  
Does this help?
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#7: Mar 13 '09

re: php vars to flash


that's great.....thanks for that markus
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#8: Mar 13 '09

re: php vars to flash


Quote:

Originally Posted by anfetienne View Post

that's great.....thanks for that markus

You're welcome.

- Mark.
anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#9: Mar 20 '09

re: php vars to flash


just to double check if i send a php var to flash using SWFObject

say....
<?
$testVar = "anfetienne";
?>

window.onload = function()
{
var flashvars = {
testFlashVar: "<?PHP print $testVar;?>"
};
var params = {
wmode: "transparent"
};
var attributes = {};
swfobject.embedSWF([...]);
}

to be able to use testFlashVar in flash actionscript all i need to do is use

trace( testFlashVar ); to bring it in then afterwards i can put testFlashVar anywhere in the actionscript?

also should it be......swfobject.embedSWF(test.swf); or swfobject.embedSWF([test.swf]);?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#10: Apr 3 '09

re: php vars to flash


1. Yep, that's correct.

2. Check out the documentation for SWFObject to understand how to embed it.
Reply


Similar Flash / Actionscript bytes