Page 1 of 1
PHP in Flash
Posted: Tue Jun 24, 2003 12:43 pm
by Gappa
Ok, just trying to do something pretty simple, load a php file (well its out put ell you know what i mean

... hopefully) into a flash document.
Now I have a Dynamic Text box (instance name "text") in this flash doc. (HTML enable)
and I want it to load up test5.php into this text box
so I have used:
Code: Select all
loadVariables("test5.php", "text");
this is giving me nothing at all...

what have i missed?
Posted: Tue Jun 24, 2003 11:20 pm
by Gappa
No one around here use flash, or did i post this in the wrong forum?

Posted: Wed Jun 25, 2003 2:34 am
by m@ndio
hi,
I use flash all the time but have never really delved into loading in content... sorry
check out
http://www.flashkit.com its got 100000's of projects I am sure you will find what you are looking for.
Posted: Wed Jun 25, 2003 3:13 am
by patrikG
I haven't tied PHP to Flash, but it doesn't appear to be too difficult if you have a look at
http://uk2.php.net/swf and the
MING-functions.
PHP offers the ability to create Shockwave Flash files via Paul Haeberli's libswf module.
Note:
SWF support was added in PHP 4 RC2.
The libswf does not have support for Windows. The development of that library has been stopped, and the source is not available to port it to another systems.
For up to date SWF support take a look at the MING functions.
Requirements
You need the libswf library to compile PHP with support for this extension. You can download libswf at ยป
ftp://ftp.sgi.com/sgi/graphics/grafica/flash.
Installation
Once you have libswf all you need to do is to configure --with-swf[=DIR] where DIR is a location containing the directories include and lib. The include directory has to contain the swf.h file and the lib directory has to contain the libswf.a file. If you unpack the libswf distribution the two files will be in one directory. Consequently you will have to copy the files to the proper location manually.
Posted: Wed Jun 25, 2003 3:33 am
by mikusan
I have been trying to load variables from php into flash, but i am taken up by the php rite now... very powerful together i must say...
this is as far as i got... i am not sure if this is also what you are looking for... Flash won't read php per se...but u can load variables...
Code: Select all
myLoader = new LoadVars(); //Create new object myLoader of class LoadVars
myLoader.load("text.txt"); //Tis could be .php too i think
myLoader.onLoad = function() { //here you would do something
trace("name: "+name+" Option:"+option+" Colour: "+color+"!");
}
I have never tried it out, if u manage please tell me how....
you place the variables in the format var=something&anothervar=somethingelse
Posted: Wed Jun 25, 2003 4:10 am
by volka
and macromedia hosts a tutorial about flash<->php that should be helpful
http://www.macromedia.com/devnet/mx/fla ... x_php.html
Posted: Wed Jun 25, 2003 5:03 am
by Gappa
Thanks guys, I'll check all this stuff out and report back.. if I get it going, I'll post how i did it for those that care hehe..
Been able to get a standard txt file to load, no luck with php yet...
Posted: Wed Jun 25, 2003 4:47 pm
by mikusan
how did you load standard text file?
what format?
Posted: Wed Jun 25, 2003 5:11 pm
by trollll
Devshed has a good tutorial on data-driven Flash which has a page on getting content from
MySQL to PHP to Flash using the LoadVars object.
Along the same line as using the LoadVars object, I find it very helpful to load objects into Flash using the XML object. You pretty much use it the ame way, but end up with a handier organization of info. Just have it use a PHP file as the XML source and have the PHP write out the XML. I've used it for everything from loading simple chat messages to navigation trees with hundreds of nodes and half a dozen layers of children.
Check out Macromedia's
actionscript dictionary, specifically the section dealing with the
XML Object. On a related note, you can check out devshed's tutorial on
XML Sockets in Flash, but I haven't really played with that much.
With loading variables into Flash from any source, you just have to make absolutely sure that you not only format php's output correctly, but that you wait until it has finished loading to try to access the variables. Took me forever to figure that one out...

Posted: Wed Jun 25, 2003 10:59 pm
by Gappa
Ahh well im trying to do wjhat i did for loading a text document, which it said in some flashkit tutorial was very simialr to loading a php file.
Not sure if you have to put like "text=dslfdskjfds" for example in the php file like you do with the txt file.
But hmmm, this is my code , never used XML before so I have no idea about that...
Code: Select all
<?php
define('IN_PHPBB', true);
/**
TODO: set $phpbb_root_path
*/
$phpbb_root_path = 'phpBB2/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
$forumId = 3;
$user_ip = '127.0.0.1';
/** calling init_userprefs will instantiate $template */
$userdata = session_pagestart($user_ip, $forumId);
init_userprefs($userdata);
/**
might be you have to change this depending on your config-data
if you see the smilie image filenames instead of the images...
*/
$board_config['smilies_path'] = $phpbb_root_path . $board_config['smilies_path'];
$query = 'SELECT topic_title, topic_id, FROM_UNIXTIME(topic_time,"%W the %D %M @ %r") AS Topic_Date, post_text, bbcode_uid, username FROM phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id JOIN phpbb_users WHERE forum_id='.$forumId.' AND topic_poster=user_id ORDER BY topic_time DESC';
$result = $db->sql_query($query);
?>
<html>
<head>
<style tye="text/css">
body { background-color: #333333; }
</style>
</head>
<body>
<?php
while($row = $db->sql_fetchrow($result))
{
// this field is in <prefix_>posts, I'm skipping it for now and enable all smilies
$row['enable_smilies'] = true;
// enable_bbcode (always true) and enable_html (always false) are ignored as well
$row['post_text'] = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $row['post_text']);
if ( isset($row['bbcode_uid']) && $row['bbcode_uid'] != '' )
$row['post_text'] = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($row['post_text'], $row['bbcode_uid']) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $row['post_text']);
if ($row['enable_smilies'])
$row['post_text'] = smilies_pass($row['post_text']);
?>
<b>
<FONT FACE="Arial" SIZE="-1" COLOR="#FF9900">
<?php echo $row['topic_title']; ?>
</FONT>
</b>
<br />
<FONT FACE="Arial" SIZE="-2" COLOR="#999999">
posted by: <b><?php echo $row['username']; ?></b>
on: <?php echo $row['Topic_Date']; ?>
</FONT>
<br /><hr /><br />
<FONT FACE="Arial" SIZE="-1" COLOR="#FFFFFF"><?php echo $row['post_text']; ?></FONT>
<br /><br />
<FONT FACE="Arial" SIZE="-2">
<a href="http://www.hostultra.com/~Gappa/phpBB2/viewtopic.php?t=<?php echo $row['topic_id']; ?>">
<b><FONT COLOR="#FF9900">Read comments</FONT></b>
</a>
</FONT>
<br /><br /><br />
<?php
}
?>
</body>
</html>
thats what I want to load in the text box (well not to view the code but its output of course

) So are you saying its going to take awhile to process the php, so its not going to work simply chucking in a loadVars in the first keyframe?
damn i wish i could find a template for doing this some where hehe...
Posted: Thu Jun 26, 2003 12:02 am
by trollll
Yeah, that won't work... Loadvars can load variables into Flash from PHP by using URL encoded output like
Code: Select all
echo "topic_title=".$rowї'topic_title']."&username=".$rowї'username']."&Topic_Date=".$rowї'Topic_Date']."&post_text=".$rowї'post_text']."&topic_id=".$rowї'topic_id'];
Then you could have a button which had its dynamic text and action dependant on the variables you have it pull in and have the title as dynamic text on its own.
Posted: Thu Jun 26, 2003 12:06 am
by Gappa
Damn, im confused, maybe, I'll just use an iframe to load that stuff hehe...
Posted: Sun Jun 29, 2003 1:36 pm
by conundrum
Are you using FlashMX?
I just took a FlashMX course and the instructor gave us a choice for an assignment. I took the hardest one which was to learn how to use flash as a front end with php and mysql. I am at the office right now but if you like I made up a tutorial which should show you exactly how to do it. It works very well. I had to read alot of tutorials and filter out some of the tuff to "dumb it down" for myself so I could understand it. When I get home, I'll check this forum again and see if you replied.
Posted: Mon Jun 30, 2003 4:55 am
by m3mn0n
Gappa wrote:Damn, im confused, maybe, I'll just use an iframe to load that stuff hehe...
The easy way out works!
