Posted by jabberwocky in SWF Studio V3 on Jan 26 2008, 06:40 pm

Man. Sorry if the tone of this string comes across a bit agitated...

I am trying to use SWF Studio to launch either a .asp page or a .pdf from a button press event. I've gone over and over the KB and Forum listing with no success.

Here's what I've got:

btnSubmitter.onRelease = function(){
//var toPassCourse:String = form.Course.text;
//getURL("\\data/contact.asp?Course=" + toPassHolder.text + "&First_Name=" + form.First_Name.text + "&Last_Name=" + form.Last_Name.text + "&Email=" + form.Email.text + "&Phone=" + form.Phone.text + "&Org=" + form.Organization.text, _blank, "GET");
ssDefaults.synchronousCommands = true;
ssCore.Shell.invoke({path:"startdir://Form.pdf", verb:"open", topmost:true});
//ssCore.Shell.launch({resource:"startdir://Form.pdf", type:"document"});
}

When I run this guy, nothing happens. Nothing. This script block ocurrs in the first frame of a one frame movie. The btnSubmitter is on the same level as the code. I'm running version 3.4 and I really need a solution to launching an asp page or a pdf. ANY HELP IS GREATLY APPRECIATED.


Posted by mbd in SWF Studio V3 on Jan 27 2008, 07:52 pm

Well, unless you call a server in your getURL you won't be able to "open" an ASP page. An ASP page needs to be run on a server. Your SWF Studio application will be running on the desktop, so you have to specify the server you want to call.

The invoke should work to open the PDF as long as Acrobat is installed and SWF Studio isn't returning an error message.

Have you checked to see if the command is returning an error?

...
var return_obj = ssCore.Shell.invoke({path:"startdir://Form.pdf", verb:"open", topmost:true});

if (return_obj.success)
{
ssDebug.trace('The command completed successfully');
}
else
{
ssDebug.trace('ERROR: '+return_obj.Error.description);
}
...


Make sure you enable the debug option (Output panel) and then build your EXE again, have SWF Studio open when your run the EXE, and make sure the Trace tab is displayed so you can see the trace message.


Posted by jabberwocky in SWF Studio V3 on Jan 28 2008, 11:44 am

thanks for your reply mbd!

I applied the code you mentioned and it seemed to work fine. There were no error messages that I could see and the pdf doc opened.

So... I guess I can play around with that some more.

However, it is preferred that I link out to the .asp file i mentioned before. I have an IIS web site defined and the url path is: http://localhost/afff/contact.asp

Can you shed some light on how to achieve this?

Again, thanks!


Posted by mbd in SWF Studio V3 on Jan 28 2008, 12:16 pm

The file is located at the link you specified, not a relative path, which is what you had in your getURL code. Flash doesn't default a relative path for a SWF running in an application to localhost, it defaults to the folder next to the application.

Even if your ASP document is next to the application, that's not how an ASP document works. It needs to be read and interpreted by IIS and the resulting data is sent to whatever requested the page.

Relative paths work in a browser because the Flash Player defaults relative paths to the domain where the SWF is from. The SWF is already being served by a server.

Change your relative path to the full path you posted.


Posted by jabberwocky in SWF Studio V3 on Jan 28 2008, 04:53 pm

mdb.. thanks again! Have you ever been in a situation where you knew that what you are trying to do won't work, but you can't figure out why? That's what is happening with me. Perhaps the largest brain fart ever...

In any event, I've applied the full path the getURL function, but it still doesn't launch the page.

Here's the code:


btnSubmitter.onRelease = function(){
   //var toPassCourse:String = form.Course.text;
   getURL("http://localhost/afcea/data/contact.asp?Course=" + toPassHolder.text + "&First_Name=" + form.First_Name.text + "&Last_Name=" + form.Last_Name.text + "&Email=" + form.Email.text + "&Phone=" + form.Phone.text + "&Org=" + form.Organization.text, _self, "GET");
   //ssDefaults.synchronousCommands = true;
   //ssCore.Shell.invoke({path:"startdir://Form.pdf", verb:"open", topmost:true});
   //ssCore.Shell.launch({resource:"startdir://Form.pdf", type:"document"});
}


As an f.y.i. here's the scenario for why we need this app...

Going to conference and we will set up a stand alone laptop without internet. We are hoping for a few leads from attendance and this asp page that I'm trying to get to is for submitting profiles into access (already built and working as stand alone app powered by IIS). I just need to get to the page with the variables from the flash form.

attachments: error.gif  


Posted by northcode in SWF Studio V3 on Jan 28 2008, 05:10 pm

Did that getURL call above produce the output in the image you attached? I can't see how that could happen.

I did a test with your call (I faked up the data) and it failed to work, didn't even bring up an error page in IE.

When I removed the self and "GET" arguments to getURL and just called it with the URL, it worked - that is, it brought up a page with the expected URL (although there was nothing there to call).

A better solution than getURL might be to use LoadVars. With that you don't get any browser windows opened, but you can see exactly what the server returns in response to your request.

You can use GET or POST, whatever works best for you. Here's an example that hits a test CGI script on our server. It's also a pure Flash solution so it doesn't depend on SWF Studio.


LoadVars.prototype.decode = function(str) 
{
   this.$pureloadvars = str;
   var path = this.$pureloadvars;
   path = path.split("&");

   for (var i = 0; i<path.length; i++) 
   {
      path[i] = path[i].split("=");
      this[path[i][0]] = {};
      this[path[i][0]] = path[i][1];
   }
};

send = new LoadVars();
recv = new LoadVars();
recv.onLoad = onLoaded;

function onLoaded()
{
   trace(recv.$pureloadvars);
}

send.fields_name = "tim"
send["9830161"] = "X4R5";
send.whatever = "1";

send.sendAndLoad("http://www.northcode.com/cgi-bin/test.pl", recv, "POST"); 


Posted by jabberwocky in SWF Studio V3 on Jan 28 2008, 08:31 pm

mbd...

you are a bright star.

your post that suggested using the loadVars method was, at first, a bit overwhelming. However, the notion of using this method sparked some additional research. Finally, using the following code, I (we) have managed to get it going.

btnSubmitter.onRelease = function(){
//trace(form.First_Name.text);
var sender = new LoadVars();
sender.fname = form.First_Name.text;
sender.lname = form.Last_Name.text;
sender.phone = form.Phone.text;
sender.email = form.Email.text;
sender.viewing = toPassHolder.text
sender.org = form.Organization.text;
sender.send("http://localhost/afcea/data/contact.asp", "GET");
}

As you can probably tell by now, i'm a "hack" when it comes to coding. For this I apologize. While some vendor products that I use are difficult to find support for, I can honestly say now after logging a few requests for support that you guys (SWF) have always come through for me in a most speedy way. For this I am greatly thankful.

Keep up the great work and thanks again for your assistance.

and remember... "sunshine is for free!" - Chris Jones


Posted by northcode in SWF Studio V3 on Jan 28 2008, 10:12 pm

The only advantage to my version is that you can read the results from the server, so you know whether the operation was successful or not. In your case, using localhost, you can't get a network failure so as long as the data is okay it should work every time.


Posted by jabberwocky in SWF Studio V3 on Jan 29 2008, 09:59 am

I'm guessing that these lines of your code example take care of "network failure" aspect that you mentioned before with the trace statement outputing the failure?

recv.onLoad = onLoaded;

function onLoaded()
{
trace(recv.$pureloadvars);
}

Also, I can't help by associate your code example with php (which I'm not that familiar with). I'm going to review your version some more and see if I can't decipher it on my own. I can see where this could be very handy. Thanks again mdb


Posted by mbd in SWF Studio V3 on Jan 29 2008, 10:18 am

LoadVars onLoad will return a boolean indicating whether or not the send/load was successful or not:

function onLoaded(success:Boolean)
{
   if (success)
   {
      trace(recv.$pureloadvars);
   }
   else
   {
      trace('An error occurred');
   }
}


P.S. Although I like the praise, Tim (northcode) was actually the one who stepped in there with LoadVars.