-
Nitin Oza
I want to get user's name and score stored and displayed. Some how I have managed to to get high score stored and displayed. How to ask user to input user name. I have InputText, I also have SharedObject I am not able to link the two. I am using following code. Actionscript 3.0 and CS3.
var so:SharedObject = SharedObject.getLocal("SaveDataNameSubmit");
so.data.useername=text_in.text;
so.flush();
usedby.text="" + useername;
AND.......
var so:SharedObject = SharedObject.getLocal("SaveDataCount04");
so.data.tops01;
so.data.tops02;
so.data.tops03;
so.data.tops04;
so.data.tops05;
so.flush();
count01.text = "" + so.data.tops01;
count02.text = "" + so.data.tops02;
count03.text = "" + so.data.tops03;
count04.text = "" + so.data.tops04;
count05.text = "" + so.data.tops05;
addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(e:MouseEvent){
switch(e.target){
case increase:
score++;
scorebox.text = ""+ score;
if (score > so.data.tops01 && score < so.data.tops05 && score < so.data.tops04 && score < so.data.tops03 && score < so.data.tops02){so.data.tops01 = score;}
if (score > so.data.tops01 && score > so.data.tops02 && score < so.data.tops03 && score < so.data.tops04 && score < so.data.tops05){so.data.tops02 = score;}
if (score > so.data.tops01 && score > so.data.tops02 && score > so.data.tops03 && score < so.data.tops04 && score < so.data.tops05){so.data.tops03 = score;}
if (score > so.data.tops01 && score > so.data.tops02 && score > so.data.tops03 && score > so.data.tops04 && score < so.data.tops05){so.data.tops04 = score;}
if (score > so.data.tops01 && score > so.data.tops02 && score > so.data.tops03 && score > so.data.tops04 && score > so.data.tops05){so.data.tops05 = score;}
break;
Please Help Me
Regards
Nitin Oza
nitinjd5@gmail.com
-
Senior Member
You can use a textinput component in combination with a submit button (component). Then you have the following script:
import fl.controls.TextInput;
import fl.controls.Button;
import flash.net.SharedObject;
var userName:String;
var myInput:TextInput;
var submitBut:Button;
submitBut.label = "Submit";
var so:SharedObject = SharedObject.getLocal("gameobjects", "/");
submitBut.addEventListener("click", submitName);
function submitName (event:Event)
{
userName = myInput.text;
so.data.username = userName;
}
trace("Name: "+so.data.username);
You can have this before the user can play the game and has to enter the name.
I am not sure, I answered your question, because it was not so clear.
- The right of the People to create Flash movies shall not be infringed. -
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|