Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

loadVars.send in Projector

Posted on 2003-11-21
20
Medium Priority
?
656 Views
Last Modified: 2008-01-09
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

0
Comment
Question by:mvkvivek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 4
  • +1
20 Comments
 
LVL 9

Expert Comment

by:OBCT
ID: 9802017
try this:
myLoadVars.sendAndLoad("http://10.10.11.35:1500/forflash.txt","","POST");

Cheers

-OBCT
0
 

Author Comment

by:mvkvivek
ID: 9802168
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
 
LVL 9

Expert Comment

by:OBCT
ID: 9802206
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:mvkvivek
ID: 9802238
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
 
LVL 9

Expert Comment

by:OBCT
ID: 9802256
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
 
LVL 9

Expert Comment

by:OBCT
ID: 9802289
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
 

Author Comment

by:mvkvivek
ID: 9802325
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
 
LVL 9

Expert Comment

by:OBCT
ID: 9802359
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
 
LVL 9

Expert Comment

by:OBCT
ID: 9802362
0
 

Author Comment

by:mvkvivek
ID: 9802431
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
 

Expert Comment

by:Rouneh
ID: 9803578
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
 
LVL 27

Expert Comment

by:negatyve
ID: 9807464
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
 

Author Comment

by:mvkvivek
ID: 9808299
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
 

Author Comment

by:mvkvivek
ID: 9823821
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
 
LVL 27

Accepted Solution

by:
negatyve earned 500 total points
ID: 9823879
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
 

Author Comment

by:mvkvivek
ID: 9824047
Great,

It is working fine now.

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

Thanks for the solution.
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9824061
>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
 
LVL 27

Expert Comment

by:negatyve
ID: 9824074
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
 

Author Comment

by:mvkvivek
ID: 9849104
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
 

Author Comment

by:mvkvivek
ID: 9856673
Anybody is reading this....?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question