Friday, May 8, 2009

Newgrounds Username Variable for use in your games/movies!

If you have already published games/movies to newgrounds then this is something that you must add. It makes your games and movies way cooler and look more professional.

Newgrounds just added a function where your .swf file can recognize what user is playing your file.. Newgrounds automatically loads the username into your movie so the only thing you need to do is call it. The variable that NG loads is: _root.ng_username

Note that this only works if the user is logged in. So you have to make an if statement to see if the user is logged in.
An example is:

if (_root.ng_username == null)
{
textBox.text = "Hello there, how are you?";
{
textBox.text = "Hey, " + _root.ng_username + " how are you!";
}
}

This would make the textbox instanced 'textBox' show Hello there, how are you if the user is not logged in and it would show Hey exampleusername, how are you?

2 comments:

  1. What computer software were computers using before Microsoft was
    invented? I googled it and couldn't find any information on it. Thanks with no jokes or dissing please..

    Feel free to visit my web page ... paginasamarillas-atl.Com

    ReplyDelete
  2. Great post however I was wanting to know if
    you could write a litte more on this topic? I'd be very grateful if you could elaborate a little bit more. Bless you!

    My blog - http://www.love2u.Ro/blog/57056/arthritis-natural-treatment

    ReplyDelete