Be a Supporter!
shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
As: Php Flash Nov. 29th, 2005 @ 08:06 PM Reply

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?

shazwoogle-1
shazwoogle-1
  • Member since: Apr. 13, 2004
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:44 PM Reply

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

thank you i have been trying to do this for ages

Polluted-Mindz
Polluted-Mindz
  • Member since: Jun. 19, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:46 PM Reply

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

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:46 PM Reply

thanks =D

gorman2001
gorman2001
  • Member since: Aug. 18, 2002
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:50 PM Reply

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

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:51 PM Reply

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

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:56 PM Reply

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

thanks =D

maybe use ASP

me+asp = (computer+brain)*implode

Ozcar
Ozcar
  • Member since: May. 12, 2002
  • Offline.
Forum Stats
Member
Level 32
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 08:58 PM Reply

tldr!

cough cough
cough...

I mean... Nice tutorial :)

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

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 09:10 PM Reply

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...

Polluted-Mindz
Polluted-Mindz
  • Member since: Jun. 19, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 09:10 PM Reply

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

authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 09:13 PM Reply

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

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


BBS Signature
Ozcar
Ozcar
  • Member since: May. 12, 2002
  • Offline.
Forum Stats
Member
Level 32
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 09:18 PM Reply

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

Yeah... I was kidding :)

But I read it... for real ;)

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 09:48 PM Reply

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

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

harman-dragon
harman-dragon
  • Member since: Feb. 18, 2003
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 10:32 PM Reply

nice stufff, useful4 many

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Nov. 29th, 2005 @ 10:44 PM Reply

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

yeah thats what i though to =D

RWS
RWS
  • Member since: Mar. 11, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to As: Php Flash Nov. 30th, 2005 @ 01:02 AM Reply

Now to do one except with mySQL instead of txt files

Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to As: Php Flash Nov. 30th, 2005 @ 01:07 AM Reply

This isn't using Flash,is it?

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

:D


wat
a compessor wil raise the volume while lowering the db - chronamut

Zielak
Zielak
  • Member since: Sep. 21, 2005
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Php Flash Nov. 30th, 2005 @ 02:24 AM Reply

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

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Php Flash Nov. 30th, 2005 @ 09:33 AM Reply

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

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to As: Php Flash Nov. 30th, 2005 @ 10:04 AM Reply

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
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to As: Php Flash Nov. 30th, 2005 @ 10:52 AM Reply

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
shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Dec. 3rd, 2005 @ 10:17 PM Reply

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

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Dec. 3rd, 2005 @ 10:26 PM Reply

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...

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Dec. 6th, 2005 @ 07:09 PM Reply

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

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

Dislexsick
Dislexsick
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to As: Php Flash Jan. 1st, 2006 @ 01:09 AM Reply

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

orengg
orengg
  • Member since: Oct. 29, 2002
  • Offline.
Forum Stats
Member
Level 14
Gamer
Response to As: Php Flash Feb. 17th, 2006 @ 02:11 PM Reply

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..

Newsdee
Newsdee
  • Member since: Jan. 21, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As: Php Flash Feb. 17th, 2006 @ 02:32 PM Reply

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

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Mar. 3rd, 2006 @ 10:51 PM Reply

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

pmouth
pmouth
  • Member since: Sep. 30, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to As: Php Flash Mar. 3rd, 2006 @ 11:18 PM Reply

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?

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Php Flash Mar. 4th, 2006 @ 06:49 PM Reply

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