loadVars.send in Projector

Greetings,

In a flash projector exe file I am using loadVars.send() method to send data to my own server (Developed using Java Socket programming).
Below is my action script code:

myLoadVars = new LoadVars()
myLoadVars.somevar = "someval"
myLoadVars.send("http://10.10.11.35:1500/forflash.txt","","GET");

Everything works fine, but when sending data it is opening new browser window which i doesn't want.

Is is possible to disable the window parameter of send method.

Hope you all getting my question.

Thanks for your time.

Vivek

mvkvivekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OBCTCommented:
try this:
myLoadVars.sendAndLoad("http://10.10.11.35:1500/forflash.txt","","POST");

Cheers

-OBCT
0
mvkvivekAuthor Commented:
Hi,

Thanks for the response.

I tried both the following:

myLoadVars.sendAndLoad("http://10.10.11.35:1500/forflash.txt","","POST");
myLoadVars.send("http://10.10.11.35:1500/forflash.txt","","POST");

It is not sending any response to server and new Window is not opening.

Simple words Nothing happens if I used both the above.

Thanks
0
OBCTCommented:
I'm not sure if you've tried this or if it will even work but it's worth a shot.

myLoadVars = new LoadVars();
myLoadVars.somevar = "someval";
loadVariablesNum("http://10.10.11.35:1500/forflash.txt","0","GET");
or
myLoadVars = new LoadVars();
myLoadVars.somevar = "someval";
loadVariablesNum("http://10.10.11.35:1500/forflash.txt","0","POST");

Cheers

-OBCT
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mvkvivekAuthor Commented:
Thanks agin OBCT!

But I am not trying to load a txt file, I am trying to send data from a flash (Projector) movie to my own HTTP server.

I can able to send data using send method, but the player is opening the browser window.

How can avoid this.

Thanks

Vivek
0
OBCTCommented:
Sorry for not reading your question properly, I have become well known for doing that.
Give me about an hour and I'll see what I can find on fixing your problem.

Cheers

-OBCT
0
OBCTCommented:
Have you tried using this:

myLoadVars = new LoadVars()
myLoadVars.somevar = "someval"
myLoadVars.send("http://10.10.11.35:1500/forflash.txt","0","GET");

The only difference is that I've put a "0" in the window string, this means that everything is being sent to your server, but once I had the same problem and when I used the zero, the window stopped popping up.
I just hope that it fixes your problem.

Cheers

-OBCT
0
mvkvivekAuthor Commented:
Oops....

I tried this and this also popping up.  :o(

Can you upload it for me. Also tell me what server you are using to test this.

Expecting your reply.

Thanks
0
OBCTCommented:
Unfortunatly the server I use crashed and I lost everything so I'm not testing any of this, I'm just passing information from previous encounters of the same problem.
So just to be safe.....if you use the GET method, the data is sucessfully sent to your server but the window pops up, and if you use the POST method, the data is not sent and the window does not pop up.

To be perfectly honest, I don't understand why it is having this problem.
I am currently working on an online game. In the exe file we have the registration form and we use loadVariablesNum to send our data the the database and no window pops up.
Just a few questions...
What is in the window that pops up? Is it blank?
Have you tried this:

myLoadVars = new LoadVars()
myLoadVars.somevar = "someval"
myLoadVars.send("http://10.10.11.35:1500/forflash.txt", ,"GET");  //Now there is no target specified.

I just read an article on macromedia.com on the send function and I think the problem is that flash thinks that "" is a target window, therefore opening up IE.
If it doesn't work, we'll keep trying.

Cheers

-OBCT
0
OBCTCommented:
0
mvkvivekAuthor Commented:
Hi

I have read this article.

Also I tried using
myLoadVars.send("http://10.10.11.35:1500/forflash.txt", ,"GET");  //Now there is no target specified.

Now also windows pops up.

But what you said is perfectly right:

if we use the GET method, the data is sucessfully sent to your server but the window pops up, and if you use the POST method, the data is not sent and the window does not pop up.

Just to add with that.

Both happens only we didn'g give any of four (_blank, _top, _self, _parent) windows property.

I don't know how to over come this...

FYI: If we use loadVariablesNum the window won't pop-up.
Answer for your question:
In the new window it is trying to load the specifed url.

http://10.10.11.35:1500/forflash5.txt?onLoad=%5Btype%20Function%5D&somevar=someval //For Post method
http://10.10.11.35:1500/forflash5.txt?somevar=someval //For Get method.

Hope I'll get some solution for this.

Thanks





0
RounehCommented:
Hi,

Have you considered using the XMLSocket function instead of LoadVars? (If you're coding the Java Socket server yourself it should not pose a problem)

var serverSocket;
function setupSocket() {
   serverSocket = new XMLSocket();
   serverSocket.onData = function() {
     // Do stuff with whatever data the server sends to you
   }
   serverSocket.connect("yourServerHostNameOrIP", portWhereServerIsListening);
   // Note that this socket will be connected until you disconnect it either from the server or through the serverSocket.disconnect() function.
}
function sendSocket(data) {
   // data = any string message
   serverSocket.send(data + '\0');
   // The \0 character is what flash regards as end of message
}

I assume you know what to do with the data from the server side?

Regards,
Rouneh.
0
negatyveCommented:
1. The standalone flash player for windows *always* uses the "GET" method, even if you have specified "POST" (this is a bug)
2. The send method is similar to the movieclip getURL method, so the popop page coming is normal

3 A possible solution is to use sendAndLoad method instead, and have the server send back a response to the calling application

(ie, the server, once received data, send back this string to flash "&received=OK&")

myLoadVars = new LoadVars();
myLoadVars.somevar = "someval";
myLoadVars.onLoad = function(success)
{
      if(success){
            if(this.received == "OK")trace("YEAH!!");
      } else {
            trace("SERVER NOT FOUND");
      }
};
myLoadVars.sendAndLoad("http://10.10.11.35:1500/forflash.txt", myLoadVars, "POST");
0
mvkvivekAuthor Commented:
Thank you experts.

I used sendAndLoad and it works fine. I was wondering why other not working while this is working. Thanks negatyve for your explanation.

Still I have some problems with my own httpServer. Hope i'll solve it and implement this. I'll come back to this once I solved the server problem

Thanks for your time OBCT.

0
mvkvivekAuthor Commented:
I am back again.

Now the loadVars.sendAndLoad is working fine in both PC & Mac.

I tried using XML.sendAndLoad and this is working fine in PC but not in Mac.

Flash Player is sending the information to Server and the server is also responding back but the Flash player never makes the success of onload function to true.

Is this is a bug?

Is anybody tried this over mac?

Thanks in advance
0
negatyveCommented:
Try overwriting the onData event handler:

data_xml.onData = function (rawData)
{
      if (rawData == undefined) {
            this.onLoad(false);
      } else {
            this.parseXML(rawData);
            this.loaded = true;
            this.onLoad(true);
      }
};
data_xml.onLoad = function(success)
{
      if (success) {
            // use your new loaded xml data
      } else {
            trace("XML FILE NOT FOUND");
      }
};
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mvkvivekAuthor Commented:
Great,

It is working fine now.

Possible Can you explain me why we need to overwrite onData?

Thanks for the solution.
0
negatyveCommented:
>Possible Can you explain me why we need to overwrite onData?

it's kind of a known bug on mac. i cannot tell you where i have red it - it's that inner knowledge you do not where it comes from [but it's there] :)
0
negatyveCommented:
beside that. the "loading complete" event for xml and loadvars is onData, which by default calls the onLoad event handler. so, before onload is fired, everything go through "onData" (which is rarelly overwritten). the loadvars one is:

data_var.onData = function (rawData)
{
    if (rawData == undefined) {
         this.onLoad(false);
    } else {
         this.decode(rawData); // decode instead of parseXML - decode is undocumented
         this.loaded = true;
         this.onLoad(true);
    }
};
data_var.onLoad = function(success)
{
    if (success) {
         // use your new loaded data
    } else {
         trace("FILE NOT FOUND");
    }
};
0
mvkvivekAuthor Commented:
Hi,

I still have some problem with the sendAndLoad.

Let me explain my problem.

I have one textfield and two buttons as movieclip in the main time line. Following is the is code which is placed in first frame of the movie.

loadVars_mc.caption_txt.text = "LoadVars";
XML_mc.caption_txt.text = "XML";

myLoadVars = new LoadVars()
myLoadVars.somevar = "someval"

xmlStr = "<tag>value</tag>";
myXML = new XML(xmlStr);


loadVars_mc.onRelease = function() {
      myLoadVars.sendAndLoad("http://10.10.11.35:1500/",myLoadVars,"POST");
}

XML_mc.onRelease = function() {
      myXML.sendAndLoad("http://10.10.11.35:1500/",myXML,"POST");
}

myLoadVars.onLoad = function(success) {
      if (success) {
            trace(this);
      }
}

myXML.onLoad = function(success) {
      trace("on load");
      if (success) {
            trace(this);
            _root.somevar = this;
      }
}

myXML.onData = function (rawData)
{
             trace("inside onData");
     if (rawData == undefined) {
          this.onLoad(false);
     } else {
          this.parseXML(rawData);
          this.loaded = true;
          this.onLoad(true);
     }
}

Both these buttons used to send data (loadvars & XML) to the server. It is working fine in Authoring environment, but it is not sending any data to server in .exe.

Any guess why it is?.....

Many thanks
Vivek
0
mvkvivekAuthor Commented:
Anybody is reading this....?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.