Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-07-2010, 12:07 PM   #1
Geert81
Member
 
Join Date: Feb 2010
Posts: 54
Default [AS3] Highscore list using Flash and PHP

Hi,

I want to make a highscorelist using AS3 and PHP(MySQL).
I cant find a good tutorial on internet how to make something like that but I got this so far:
ActionScript Code:
import fl.controls.TextInput; import fl.controls.TextArea; var variables:URLVariables = new URLVariables(); variables.name = "Wil"; variables.final = 2000;   var request:URLRequest = new URLRequest();   ////insert in the location of the php script //////////////// request.url = "http://www.justenter.nl/script.php"; //////////////////////////////////////////////////////////////   request.data = variables; var loader:URLLoader = new URLLoader();   loader.load(request); //sends the request   //when the request is done loading, it goes to the completeWriting function loader.addEventListener(Event.COMPLETE, completeWriting);   function completeWriting(event:Event):void {     var writingCompleted:TextField = new TextField;     writingCompleted.autoSize = "center";     writingCompleted.x =200;     writingCompleted.y= 200;     writingCompleted.text = event.target.data;     addChild(writingCompleted);   }

He is sending the score and name to the database but he is doing that when i press ctrl-enter. He is sending the data I have given in:

ActionScript Code:
variables.name = "Wil"; variables.final = 2000;

I want a input textfield and a button. And When I fill in my name in the input textfield he send it to the database when I press the button.
Is there someone that can help me out?

Tnx
Geert81 is offline   Reply With Quote
Old 04-07-2010, 12:20 PM   #2
scorpion9
Senior Member
 
Join Date: Feb 2008
Location: Estonia
Posts: 453
Default

ActionScript Code:
//lets suppose that u have a button movieclip on the stage with the name button_mc //also, u have a textfield with the name input_tf //then u need the following code button_mc.addEventListener(MouseEvent.CLICK,handleClick); function handleClick(event:MouseEvent):void {      if(input_tf.text != "")/or check the length of the text != 0      {            //and then call the function that handles the score saving           SaveScore();      { }
scorpion9 is offline   Reply With Quote
Old 04-08-2010, 06:28 AM   #3
Geert81
Member
 
Join Date: Feb 2010
Posts: 54
Default

Hi,

Tnx for the reply I got everything working now!

Here is my AS3 code:
ActionScript Code:
import fl.controls.TextInput; import fl.controls.TextArea; var variables:URLVariables = new URLVariables(); var request:URLRequest = new URLRequest(); ////insert in the location of the php script //////////////// request.url = "http://www.justenter.nl/script.php"; ////////////////////////////////////////////////////////////// request.data = variables; var loader:URLLoader = new URLLoader(); /////////////////////////////////////////////// var punten:Number = 0; score_btn.addEventListener(MouseEvent.CLICK, onButtonclicked); function onButtonclicked(e:MouseEvent):void {         punten ++;         score_txt.text = String (punten); } score_txt.text = String (punten); //////////////////////////////////////////// submitBtn.addEventListener(MouseEvent.CLICK,submitF)// where submitBtn is your button function submitF(e:Event){ variables.name=nameTF.text; // where nameTF is your input texfield variables.final = score_txt.text// where score is the variable you use to tally user score loader.load(request); //sends the request } //when the request is done loading, it goes to the completeWriting function loader.addEventListener(Event.COMPLETE, completeWriting); function completeWriting(event:Event):void {     var writingCompleted:TextField = new TextField;     writingCompleted.autoSize = "center";     writingCompleted.x =200;     writingCompleted.y= 200;     writingCompleted.text = event.target.data;     addChild(writingCompleted); }

The only problem now is that it is shown like this:

Here are all the flash scores in our database: name1=Wilfinal1=2000name2=Test
final2=1234name3=Zzyzxfinal3=1000name4=Testfinal4= 1000name5=Peterfinal5=44name6=
asdasdfinal6=25name7=Gekheid
final7=20name8=Nick
final8=16name9=
pietjefinal9=11name10=Truusfinal10=2The data has been written to the table!?>


Is there someone that can tell me how I can put this in a nice tabel?
Tnx
Geert81 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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:08 AM.

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