Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-09-2008, 02:37 PM   #1
rosem
Member
 
Join Date: Mar 2007
Location: Big Rapids, MI
Posts: 47
Send a message via AIM to rosem
Default 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
rosem is offline   Reply With Quote
Old 09-09-2008, 04:21 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Have PHP echo out those values like this...
PHP Code:
echo("&" "thumb=" "wwwThumb/thumb_{$featured[num].fid}_pic.jpg" "&" "txt=" . {$featured[num].des} . "&"); 
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 09-09-2008, 05:46 PM   #3
rosem
Member
 
Join Date: Mar 2007
Location: Big Rapids, MI
Posts: 47
Send a message via AIM to rosem
Default

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
rosem is offline   Reply With Quote
Old 09-09-2008, 06:04 PM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

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
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 09-09-2008, 07:22 PM   #5
rosem
Member
 
Join Date: Mar 2007
Location: Big Rapids, MI
Posts: 47
Send a message via AIM to rosem
Default

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
rosem is offline   Reply With Quote
Old 09-09-2008, 09:05 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

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/
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 09-11-2008, 03:32 PM   #7
mj7
no idea!
 
mj7's Avatar
 
Join Date: Aug 2008
Posts: 53
Default

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
mj7 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing flash variables to php Ikke87 ActionScript 3.0 0 10-25-2007 02:35 PM
php variables into a flash link softz ActionScript 2.0 1 09-04-2006 08:46 AM
FAQ variables - Flash > PHP betamax ActionScript 2.0 3 09-20-2005 11:54 AM
[Q] Do we need those forums??? CyanBlue General Chat 59 07-27-2004 11:13 AM
Sending Flash variables to PHP alphabug Other Flash General Questions 1 08-02-2003 02:10 AM


All times are GMT. The time now is 04:41 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.