09-09-2008, 02:37 PM
|
#1
|
|
Member
Join Date: Mar 2007
Location: Big Rapids, MI
Posts: 47
|
Help Getting PHP Variables Into Flash
Hey Everyone,
I'm working on a flash project, which pulls a thumbnail and a description from a MySQL database. The client gave me the two variable names that he's currently using on the website (in PHP), they are:
the variable for the website thumbails:
wwwThumb/thumb_{$featured[num].fid}_pic.jpg
variable for the text:
{$featured[num].des}
My question is, how do I prepare these in a standalone PHP file that echos the variables, so I can use it for flash.
Thanks,
Mike
|
|
|
09-09-2008, 04:21 PM
|
#2
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Have PHP echo out those values like this...
PHP Code:
echo("&" . "thumb=" . "wwwThumb/thumb_{$featured[num].fid}_pic.jpg" . "&" . "txt=" . {$featured[num].des} . "&");
|
|
|
09-09-2008, 05:46 PM
|
#3
|
|
Member
Join Date: Mar 2007
Location: Big Rapids, MI
Posts: 47
|
Thank you for the reply. I'm not very familiar with PHP—do I basically just copy and paste that line of code into a PHP document?
Variables in Flash would be "thumbs" and "txt" ?
Thanks,
Mike
|
|
|
09-09-2008, 06:04 PM
|
#4
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
No, that line alone won't work... You'd need that $featured array defined somewhere above that echo line so that it will actually have value for you...
If you use LoadVars(), you can access those values like yourLoadVarsInstance.thumb and yourLoadVarsInstance.txt
|
|
|
09-09-2008, 07:22 PM
|
#5
|
|
Member
Join Date: Mar 2007
Location: Big Rapids, MI
Posts: 47
|
Ah, alright...
So if they already have a page up, and they are using these variables to populate a section of the page (not in flash), could I just put that echo line on that page? I think that's what you meant by having the array defined somewhere.
Thanks a lot for all your help so far!
Mike
|
|
|
09-09-2008, 09:05 PM
|
#6
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Um, no... Those variables are not going to be available on your PHP script unless you somehow make a link to the other PHP script...
Normally we use include statement to do that in PHP, but I cannot really give you any further help on this specific matter because I have no idea what's going on in your environment...
http://us.php.net/include/
|
|
|
09-11-2008, 03:32 PM
|
#7
|
|
no idea!
Join Date: Aug 2008
Posts: 53
|
If you already have the populated variables in a PHP page you can very easily send them to the Flash file by using the flashVars parameter when embedding your swf - for example: (using dreamweaver's default swf insertion code) - note this will only send one thumbnail variable and one text variable - if you want to send the whole array you'll need to use a loader function in Flash and loop out all the variables in a PHP page (I can help if you need)
Code:
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','372','height','290','src','yourSwfHere','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','yourSwfHere','flashVars','webThum=<?php echo "wwwThumb/thumb_{$featured[num].fid}_pic.jpg"; ?>&webText=<?php echo {$featured[num].des};?>' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="372" height="290">
<param name="movie" value="yourSwfHere.swf" />
<param name="quality" value="high" />
<param name="flashVars" value="webThum=<?php echo "wwwThumb/thumb_{$featured[num].fid}_pic.jpg"; ?>&webText=<?php echo {$featured[num].des}; ?>" />
<embed src="yourSwfHere.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="372" height="290"></embed>
</object></noscript>
You should then be able to call _root.webThum and _root.webText from within flash
Last edited by mj7; 09-11-2008 at 03:34 PM.
Reason: missed a bit
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 08:29 PM.
///
|
|