00:00
00:00
Newgrounds Background Image Theme

LightyJaeger just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Php Flash

10,268 Views | 46 Replies
New Topic Respond to this Topic

As: Php Flash 2005-11-29 20:06:08


As: Main

Intro
Hello, in this tutorial i will teach you how to use php with flash
whats php you ask?
* PHP stands for PHP: Hypertext Preprocessor
* PHP is a server-side scripting language, like ASP, Perl

so what?
well a server-side scripting language exicutes a script on a server.

so whata again?
well with php you can do all saughts of awsome dynamic stuff that flash cant do alone
like: make dynamic TXT/XML files which you can save data to.
thats the primary thing i use php for... well only thing...
It can do other things like get data from other places and.. eerr... other stuff...

so lets have a little look at a php script

<?php
echo "hello world"
?>

thats php, simple enough?

any way this tutorial isnt realy about php, rather its about php and flash
so im not going to teach you much more about php it you want more info go to
www.w3schools.com
the php script that we will be using in this tutorial is


<?php
$white = "whitespace";
$name = $_POST['name'];
$info = $_POST['info'];
//--------------------
$fh = fopen("text.txt", "w+");
fwrite($fh, "white=$white&name=$name&info=$info");
fclose($fh);
header("location: http://shazwoogle.t35.com/text.txt");
?>

put that in a text file and save it as save.php

i know i said im not going to teach you php but heres somthing that no tutorial will tell you
the line white=$white&name=$name&info=$info is one large string the string (thats simple) but the first part white=$whie that is asigning another variable to the textFile
because the first variable assigned to the text file gets bugged up quite often and its to tempremental... so i just asign a useless variable at the start of it so the first "real" variable isnt all screwy...

now upload it to you server/website if you dont have any php hosting just use www.t35.com
its pretty bad...popups banner adds... and more crap but there fast and have good browser uploading

ok now for the flash part

put two input textboxes on the stage put the var for one 'name' and the other 'info'
and then add a button and call it submit

then add this to the main frame

var myData:LoadVars = new LoadVars();
name = "";
info = "";
submit.onPress = function() {
if (name != "" && info != "") {
myData.info = info;
myData.name = name;
myData.sendAndLoad("http://shazwoogle.t35.
com/php/guestbook.php", myData, "POST");
}
};

i use sendAndLoad(); because if i use just send(); it will redirect the browser to the php file
which is not all that good =(
but with sendAndLoad(); the browser dosnt go any where which is good =D

if you want an example Go here!
the text file is Right Here

ok to loading loading data is realy easy and it is saughta coverd here As: Load External Data

but this is kinda different since we are using multipull variables we want to pull out idividual
variables and that isnt realy coverd by that tut.

any way we will use the LoadVars class again
put 2 more textboxes onto the stage one with the var 'name2' and the other 'info2'
add this to the main frame


myData.onLoad = function() {
info2 = this.info;
name2 = this.name;
};
myData.load("http://shazwoogle.t35.com/php
/guestbook.txt");

lets have a look at that script
myData.onLoad = function(){
this says as soon as any myData has loaded somthing from and external sauce
do some crap
the crap that it dose is asign some data to info2 amd name2 that data is myData.info
i give it a new variable simply because it makes it easier to use you could use myData.info
or myData.name but that can cause problems because myData is already being used
to send data...

any way the next line
myData.load("http://shazwoogle.t35.com/php
/guestbook.txt");
that simply loads in data from http://shazwoogle.t3..om/php/guestbook.txt

if you want an example Go here
it uses the same php script and text file as the previouse example

so thats mostly it
re-caping

php+flash = good
php*flash+good = cool programs
---
you use the loadVars class to send and load data
you use php scripts to get the data then do somthing with it.

any questions?

Response to As: Php Flash 2005-11-29 20:44:43


WOW this was a HEAPS good tutorial!!!!!

thank you i have been trying to do this for ages

Response to As: Php Flash 2005-11-29 20:46:21


Nice shazz good information presented and was easy to understand. Should do nicely with all the n00bs here in the forum.

Response to As: Php Flash 2005-11-29 20:46:40


thanks =D

Response to As: Php Flash 2005-11-29 20:50:30


excellent tutorial.

u should write more of this kind, and maybe use ASP sometimes, just to give a good "compatibility" feeling...


website :: hugostonge.com

my job :: we+are

Response to As: Php Flash 2005-11-29 20:51:04


At 11/29/05 08:46 PM, Iateur wrote: Nice shazz good information presented and was easy to understand

easy to understand!?!?! realy cool thanks i though it would be hard to understand with my crappy grammer and spelling, and my round the roundabout way of describing things

Response to As: Php Flash 2005-11-29 20:56:09


At 11/29/05 08:50 PM, gorman2001 wrote: excellent tutorial.

thanks =D

maybe use ASP

me+asp = (computer+brain)*implode

Response to As: Php Flash 2005-11-29 20:58:46


tldr!

cough cough
cough...

I mean... Nice tutorial :)

I've been thinking in make one using Flash and CGI :)

Response to As: Php Flash 2005-11-29 21:10:01


At 11/29/05 08:58 PM, Ozcar wrote: tldr!

tldr?

I mean... Nice tutorial :)

thank you =D

I've been thinking in make one using Flash and CGI :)

making what a tldr?
yeah.. i have no idea on CGI...

Response to As: Php Flash 2005-11-29 21:10:36


Thats not a bad Idea you should make one, you probably would explain purely.

Response to As: Php Flash 2005-11-29 21:13:58


At 11/29/05 08:58 PM, Ozcar wrote: tldr!

for those who didnt know...
"too long didnt read"


BBS Signature

Response to As: Php Flash 2005-11-29 21:18:42


At 11/29/05 09:13 PM, authorblues wrote: "too long didnt read"

Yeah... I was kidding :)

But I read it... for real ;)

Response to As: Php Flash 2005-11-29 21:48:57


At 11/29/05 09:13 PM, authorblues wrote: "too long didnt read"

arrh thanks yes well it was over 4000 words long =0

Response to As: Php Flash 2005-11-29 22:32:18


nice stufff, useful4 many

Response to As: Php Flash 2005-11-29 22:44:02


At 11/29/05 10:32 PM, harman_dragon wrote: nice stufff, useful4 many

yeah thats what i though to =D

Response to As: Php Flash 2005-11-30 01:02:10


Now to do one except with mySQL instead of txt files

Response to As: Php Flash 2005-11-30 01:07:45


This isn't using Flash,is it?

If not it should be in PHP:Main in the Programming forum.

:D


wat

Response to As: Php Flash 2005-11-30 02:24:17


MAN THISA TUTORIAL ROXOR !!!!
thx xthx htx htxh xthtx THX

Response to As: Php Flash 2005-11-30 09:33:33


doesn't this belong in PHP main?

anyhow, nice work, you're wrong about one thing...

PHP - Personal Home Page

php.net says on the title PHP Hypertext Preprocessor so it's a common mistake, check ZEND (the creators of php kinda) if you care and wanna see it's relaly Personal Home Page

Response to As: Php Flash 2005-11-30 10:04:31


At 11/29/05 08:50 PM, gorman2001 wrote: u should write more of this kind, and maybe use ASP sometimes, just to give a good "compatibility" feeling...

AS: Flash > ASP > Txt

At 11/29/05 08:06 PM, shazwoogle wrote: Hello, in this tutorial i will teach you how to use php with flash
whats php you ask?

Nice tutorial, could maybe do with being run through a spellchecker first though =)

At 11/30/05 01:07 AM, -Thomas- wrote: This isn't using Flash,is it?

The variables aren't being sent to PHP from thin air, nor are they being loaded into a void from the txtfile

At 11/30/05 09:33 AM, Inglor wrote: doesn't this belong in PHP main?

Nah, I reckon it belongs in the Flash forum. ASers shouldn't need to go to Programming for this kind of stuff, since there's a large lump of Flash involved

anyhow, nice work, you're wrong about one thing...
PHP - Personal Home Page
php.net says on the title PHP Hypertext Preprocessor so it's a common mistake, check ZEND (the creators of php kinda) if you care and wanna see it's relaly Personal Home Page

lol


- - Flash - Music - Images - -

BBS Signature

Response to As: Php Flash 2005-11-30 10:52:49


At 11/30/05 09:33 AM, Inglor wrote: PHP - Personal Home Page
php.net says on the title PHP Hypertext Preprocessor

i thought there was something inherently wrong with an acronym that has the ACRONYM as one of the words. kinda makes a mobius strip in your mind if you think about it for too long...


BBS Signature

Response to As: Php Flash 2005-12-03 22:17:16


At 11/30/05 10:52 AM, authorblues wrote:

kinda makes a mobius strip in your mind if you think about it for too long...

lol.... yeah

Response to As: Php Flash 2005-12-03 22:26:27


At 11/30/05 10:04 AM, Denvish wrote: Nice tutorial, could maybe do with being run through a spellchecker first though =)

yeah i should...

Response to As: Php Flash 2005-12-06 19:09:28


At 11/30/05 10:04 AM, Denvish wrote: AS: Flash > ASP > Txt

cool =D might try and learn asp... its pretty complicated (looks)

Response to As: Php Flash 2006-01-01 01:09:51


Hmmm, I only just learnt about flash + PHP, but I used a vid tut. MUCH better.

Uses the same method pretty much form what i read of this onle, but no fumbling around with fopen and text files
Right here

Response to As: Php Flash 2006-02-17 14:11:33


At 11/30/05 10:52 AM, authorblues wrote:
At 11/30/05 09:33 AM, Inglor wrote: PHP - Personal Home Page
php.net says on the title PHP Hypertext Preprocessor
i thought there was something inherently wrong with an acronym that has the ACRONYM as one of the words. kinda makes a mobius strip in your mind if you think about it for too long...

check the PHP definition,
it's quite accurate.. not too long to read either..... (if you're very lazy.. read this: PHP=PHP hypertext preprocessor, OFFICIALLY, zend technologies are the people who re-invented PHP, but also the ones who renamed it what it is today ^^^^^^^)

nice tut :) could bery very helpful..

Response to As: Php Flash 2006-02-17 14:32:30


PHP used to stand for "Pre Hypertext Processor"... but of course that name is too plain...

Response to As: Php Flash 2006-03-03 22:51:11


wow theres been quite a few responces since the last time i checked =D

Response to As: Php Flash 2006-03-03 23:18:41


At 3/3/06 10:51 PM, shazwoogle wrote: wow theres been quite a few responces since the last time i checked =D

is that because you last posted here 3 months ago?

Response to As: Php Flash 2006-03-04 18:49:00


At 3/3/06 11:18 PM, pmouth wrote: is that because you last posted here 3 months ago?

yeah well i though it died out about 5 hours after i posted it