Store IP Address as a Variable to use with sock.connect() not working - only hardcoded IP works???

Participant ,
Sep 03, 2021 Sep 03, 2021

Copy link to clipboard

Copied

Thanks in advance to anyone who can help troubleshoot this...

I've testing a basic network functionality using a Server side App on a remote LAN computer and a Client side App on the local computer.  The communicate using sock.connect (see code below).  When I introduce a the IP Address from a stored variable which is input in a text field it spits back IOErrors #2031.

 

This is the portion of the code that handles storing the contents of the text field in the :String var and then conneting to the Server using that IP String:

 

saveIP.addEventListener(MouseEvent.CLICK,addIP);
function addIP(Event:MouseEvent){

 

    var inputMyIP:String = enterIP.text; // enterIP is the name of the input text field
    trace(inputMyIP);
    sock.connect(inputMyIP, 25000); //this var version of IP does not work???
   //sock.connect('192.168.0.116', 25000);  // this hard coded IP works
}

The socket class requires the IP to be a string.  I realize that the input field is collecting the user input as .text.  It's being stored in a String so should be converted as necessary right? 

 

Thanks for any help you can lend!

Views

38

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Sep 08, 2021 Sep 08, 2021
Resolved. I figured this out as there's an odd quirt in how Animate treats/interprets text information entered into an InputText Field that's dropped on the Stage via the GUI vs. creating an InputText Field using code - new TextField(); Seems input text fields store user input as a String natively which is what sock.connect() is seeking.  So I solved the issue by creating the user input text field with script vs. GUI. Hope this is helpful.

Likes

Translate

Translate
Participant ,
Sep 08, 2021 Sep 08, 2021

Copy link to clipboard

Copied

LATEST

Resolved. 

I figured this out as there's an odd quirt in how Animate treats/interprets text information entered into an InputText Field that's dropped on the Stage via the GUI vs. creating an InputText Field using code - new TextField();

 

Seems input text fields store user input as a String natively which is what sock.connect() is seeking.  So I solved the issue by creating the user input text field with script vs. GUI.

 

Hope this is helpful.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines