ayu
ayu

Reputation: 23

how to display name and score in as3

I have a quiz in flash as3. I want to save the name and score from user when they try my quiz. If user end the quiz, I want to display the name and the score from user before. I think to use mySQL and PHP, but I don't sure it will works in another PC without internet. Can anybody help me?

UPDATE : I solved this problem using Shared Object. It really works.

Upvotes: 0

Views: 130

Answers (3)

halilcakar
halilcakar

Reputation: 1648

You can't import flash.filesystem.File unless if don't have an AIR application.

As I know about Flash can't write and read file on computers. If you have a PHP server, you can't easily do this job with sending data's to PHP for saving on SQL and asking for data.

About this:

I think to use mySQL and PHP, but I don't sure it will works in another PC without internet. Can anybody help me?

If there isn't any internet connection on the PC, you can't use PHP or MySQL to save.

If you use PHP and MySQL to save your data's and coins ext. it's gonna always work unless the PC got internet connection.

Upvotes: 0

Namit Sinha
Namit Sinha

Reputation: 1445

For a simple AIR flash application you can simply create an external file

var file1:File = new File("\score.dat");//you can also use File.applicationStorageDirectory
var str:FileStream=new FileStream();
str.open(file1, FileMode.WRITE);
//save your name and score here in some formatted way
str.writeUTFBytes("NAME: Feynman SCORE: 500/500 "); 
str.close();

Similarly to read the file

var fileOpen:FileStream = new FileStream();
fileOpen.open(file1, FileMode.READ);
// this will contain your name/score string
var str:String = fileOpen.readUTF(); 
fileOpen.close();

dont forget to import flash.filesystem.File and import flash.net.FileReference.

But you should be aware of that this file is not secure it could be tampered with. You should look into more secure way to store store data if your application need it eg Shared Objects / cryptographically securing your data / storing it externally (on your servers).

Upvotes: 1

Xue Fang
Xue Fang

Reputation: 108

You might be interested to save datas in an external file (XML,...), this way it should be able to save any score with or without internet.

Upvotes: 1

Related Questions