11 Replies - 1175 Views - Last Post: 13 February 2011 - 12:07 PM

#1 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

[Fixed] Variable Issues [Actionscript 2]

Posted 11 February 2011 - 04:31 PM

I'm trying to have the user enter a name into a text field and then when they click continue it will link them to addcharactertodatabase.asp?name=" What ever they entered in the textfield here". My issue is it redirects to addcharactertodatabase.asp?name=undefined instead. I know this means the variable is not defined but I don't know what went wrong.

Here is the code for my button

on(press) {
var charactername = displayname.text;
getURL("addcharactertodatabase.asp?name=" + charactername, "_top"); 
}


This post has been edited by Glorfindal: 13 February 2011 - 12:18 PM


Is This A Good Question/Topic? 0
  • +

Replies To: [Fixed] Variable Issues [Actionscript 2]

#2 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 03:23 AM

What is displayname ? Is it a name of a textBox ? If yes, where is it ?
Was This Post Helpful? 0
  • +
  • -

#3 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 06:27 AM

It's input textbox that I made into a movie clip.
Was This Post Helpful? 0
  • +
  • -

#4 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 06:44 AM

If its inside a movieclip, then you can't use displayname straight. Suppose the name of your movieclip is tb_mc, then use the textbox like this :

var charactername = tb_mc.displayname.text;

Was This Post Helpful? 1
  • +
  • -

#5 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 08:51 AM

Thanks that helped!

EDIT: I have a new problem now. I am trying to write a script to validate. And make sure it is at least not blank as the content in the field is going to be sent to a database eventually. The problem now is that I when I enter nothing it says "Please enter a name" just like it should. But then when I enter a name it again says "please enter a name again." It essentially returns the same function no matter whether the condition is true or not.
Here is my code

on (press) {
var charactername = namefield.text;
if(charactername=" ") {
var errortext="Please enter a name";
} else {
gotoAndStop(2); 
}
}

This post has been edited by Glorfindal: 12 February 2011 - 09:08 AM

Was This Post Helpful? 0
  • +
  • -

#6 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 10:19 AM

Do you see something strange here :

if(charactername=" ")


:)
Was This Post Helpful? 0
  • +
  • -

#7 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 11:21 AM

I tried it like this to if(charactername="") but then it never validated it. And just always sent me to frame 2.
Was This Post Helpful? 0
  • +
  • -

#8 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 12:10 PM

It should be

if(charactername==" ")


Got the bug ?
Was This Post Helpful? 1
  • +
  • -

#9 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 12 February 2011 - 12:21 PM

That helped thanks.
Was This Post Helpful? 0
  • +
  • -

#10 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 13 February 2011 - 10:51 AM

Okay I have another issue. I'm pretty sure this is a simple syntax issue. I never learned ActionScript syntax because I couldn't find any tutorials for it. Anyway I am having an issue putting multiple variables in the parameter of a function. Here's my code

on(press) {
	getURL("addcharactertodatabase.asp?name=" + charactername + "&gender=" + choosengender + "&race=" + choosenrace + ", "_top")
}

Was This Post Helpful? 0
  • +
  • -

#11 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 13 February 2011 - 11:36 AM

So whats the error/difficulty/problem you are facing ?
It seems to be right.
Was This Post Helpful? 0
  • +
  • -

#12 Glorfindal  Icon User is offline

  • Java Enthusiast
  • member icon

Reputation: 30
  • View blog
  • Posts: 560
  • Joined: 31-December 08

Re: [Fixed] Variable Issues [Actionscript 2]

Posted 13 February 2011 - 12:07 PM

Here's the error ActionScript returns

Quote

**Error** Scene=Scene 1, layer=Actions, frame=6:Line 2: ')' or ',' expected
getURL("http://www.dragonkwest.net/dragonkwest/addcharactertodatabase?name=" + charactername + "&gender=" + choosengender + "&race=" + choosenrace + ", "_top")

**Error** Scene=Scene 1, layer=Actions, frame=6:Line 3: Syntax error.
}

Total ActionScript Errors: 2 Reported Errors: 2


EDIT: Sorry I looked over the error carefully and fixed it.

This post has been edited by Glorfindal: 13 February 2011 - 12:17 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1