m hanif f
m hanif f

Reputation: 418

actionscript 3 get ip host domain

I've develop a flash web-based applciation but till now It works well in my localhost and when I try to access via local connection, I remember that I must change all urlrequest that contain 'localhost' term. But, when the IP address changed, I must change the urlrequest again and it's not effectively.

So, How I can get the IP addrees now (Host/domain) such as 10.100.202.24 using actionsript 3?

Upvotes: 0

Views: 645

Answers (2)

dimpiax
dimpiax

Reputation: 12697

Enum is good, but you also can lookup for current url of your application, and generate dynamic prefix with protocol of relative path.

Upvotes: 0

KumoKairo
KumoKairo

Reputation: 678

You should consider creating a new static constant somewhere in your code. It will hold your current remote server adress. Of course, you'll have to manually change all of your 'localhost' references with your new variable.

package
{
    public class Constants
    {
        public static const REMOTE_SERVER_ADRESS:String = "http://localhost/";
    }
}

And reference it like this:

...
var urlRequest:URLRequest = new URLRequest(Constants.REMOTE_SERVER_ADRESS);
...

So when you'll have to change your remote server adress, you just change it in your Constants class and it will instantly take effect on your app

Upvotes: 1

Related Questions