FlashVacuum Forum Index
FlashVacuum Forum IndexForum Index    FAQFAQ    SearchSearch    StatisticsStatistics    ShouBboxShoutBox    RegisterRegister    Log inLog in       
FlashVacuum Forum Index >> ActionScript 2.0 :: FMX 2004 >> sendAndLoad headaches
Post new topic   Reply to topic Users browsing this topic: 0 Registered, 0 Hidden and 0 Guests
Registered Users: None
View previous topicEmail this thread to a friendPrinter-friendly versionLog in to check your private messagesView next topic
Author Message
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/16/2006, 3:41 pm    Post subject: sendAndLoad headaches Reply with quote

This is in the first frame:
AS:
var send_lv:LoadVars = new LoadVars();
var receive_lv:LoadVars = new LoadVars();
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function(success:Boolean) {
      if (success) {
            send_lv.datastr = this.toString();
            trace(send_lv.datastr);
            send_lv.sendAndLoad("output.php", receive_lv, "POST");
            receive_lv.onLoad = function(success:Boolean):Void  {
                  if (success) {
                        // do what you want here
                        myText.text = "success";
                  } else {
                        myText.text = "failed2";
                  }
            };
      } else {
                        myText.text = "failed1";
      }
};
my_lv.load("test.txt");


Testing it locally and watching it in the debugger, seeing the trace and "success" statement, it all seems to be doing what it is supposed to, yet on the server - nothing. Not even the error message. Probably not the best, nesting that second onLoad statement, but I've been pulling my hair out over this little thing and am trying anything.

This has to be simple. Any help greatly appreciated.
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
CyanBlue
FV Staff


Joined: 24 Jul 2003
Posts: 2012
Location: Chantilly, VA
usa.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/16/2006, 3:47 pm    Post subject: Reply with quote

Howdy and Welcome... Smile

The script looks okay to me... A couple of questions for you...

#1. What's the full URL to the output.php and your tester HTML file that I can try???

#2. What's the output from the output.php when you execute it???

#3. You are sure your host supports the PHP, right???

#4. Your HTML, SWF and PHP files are sitting in the same directory, right???

_________________
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/16/2006, 4:03 pm    Post subject: Reply with quote

CyanBlue!! Bless you!!

Quote:
#1. What's the full URL to the output.php and your tester HTML file that I can try???

http://www.jacobschase.com/pdf/output.php
http://www.jacobschase.com/pdf/test2.html

Quote:
#2. What's the output from the output.php when you execute it???


Sorry, I'm a php idiot. Here is the php file which processes a ascii formatted pdf and downloads a normal pdf to the client's machine:
<?php
$pdfdata = $_POST['datastr'];

// Defines the header for the page and outputs a PDF file
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=myPDF.pdf");
header("Pragma: no-cache");
header("Expires: 0");

// $pdfdata is the variable sent from flash.
// $pdfdata contains a few non compliant characters and this fixes that
$pdfdata = str_replace(") \'", ") '", $pdfdata);
$pdfdata = str_replace("\)", ")", $pdfdata);
$pdfdata = str_replace("\(", "(", $pdfdata);

// This should be the same as CFOUTPUT
// It basically redefines the headers for the page and prints out the data in $pdfdata
// outputing a pdf file.
echo $header.'\n'.$pdfdata;

?>


Quote:
#3. You are sure your host supports the PHP, right???

Yep.
http://www.jacobschase.com/pdf/phpinfo.php

Quote:
#4. Your HTML, SWF and PHP files are sitting in the same directory, right???

Yep.

Tried it on another server as well, with the same results.

Thanks for your time.
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
CyanBlue
FV Staff


Joined: 24 Jul 2003
Posts: 2012
Location: Chantilly, VA
usa.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/16/2006, 4:49 pm    Post subject: Reply with quote

Hm... Interesting...

If I try to load that test.txt file, I cannot...
The simplest form of load() function does not work... Interesting... It must have to do with what's inside of the text file... Hm...
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/16/2006, 5:05 pm    Post subject: Reply with quote

Well I can't even attach it or a zipped version.

Can you grab it here?:

http://www.jacobschase.com/pdf/test.zip

Here is a working verison of the the script that bypasses the whole flash thing:

http://www.jacobschase.com/pdf/Archive.zip
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
CyanBlue
FV Staff


Joined: 24 Jul 2003
Posts: 2012
Location: Chantilly, VA
usa.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 9:05 am    Post subject: Reply with quote

Well... That won't solve much problem...
Do me a favor and post a link where I can grab the ZIP file that contains FLA, TXT and PHP files all together so that I can fiddle with it on my machine...

Oh, when you say 'testing locally', you mean that you were actually typing http://localhost/whatever.php within the IE via your IIS, correct???
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 9:29 am    Post subject: Reply with quote

Here is the fla, the output.php, the text file, and the html holder. There is also a index.php file that pushes that same string literal to the same php page to process it (ouput.php). I thought it was relevant since the text gets processed properly with that same output.php file, even though it's not getting sent from flash.

In regards to your question, all I was referencing was that it seemed to be working correctly when testing it from flash. I don't have php running on my local machine.

Thanks for your time.
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
CyanBlue
FV Staff


Joined: 24 Jul 2003
Posts: 2012
Location: Chantilly, VA
usa.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 1:11 pm    Post subject: Reply with quote

Um... I guess you forgot the URL... Wink

The thing is that if you do not have PHP running in your local machine, Flash detects it as if it is a flat text file, so the outcome will be totally different... So, you probably want to point to the PHP file in the server...
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 3:04 pm    Post subject: Reply with quote

Cheesy Grin

http://www.jacobschase.com/pdf/Archive2.zip
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
CyanBlue
FV Staff


Joined: 24 Jul 2003
Posts: 2012
Location: Chantilly, VA
usa.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 4:16 pm    Post subject: Reply with quote

Arg... Don't have F8 installed... Can you save the FLA file for FMX 2004 and upload it to the server again??? Wink
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 5:00 pm    Post subject: Reply with quote

Hey CyanBlue.

I think I got it figured out over here. I'll get it organized later and post what changed, but basically we did some changes in the fla and the php file, and it's working now.

thanks for your time. Hope it wasn't to much aggravation/brain damage.

Thanks again!!
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
grendel
FV Newbie
No Avatar


Joined: 08 Mar 2006
Posts: 10

blank.gif
Local Time: 7:24 am

Status: Offline

PostPosted: 11/17/2006, 9:32 pm    Post subject: Reply with quote

Well after all that, here is what changed if you're still curious. In the fla, I took out the second nested loop and used "send" to pass the url of the text file:

AS:
var send_lv:LoadVars = new LoadVars();
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function(success:Boolean) {
      if (success) {
            send_lv.datastr = "test.txt";
            trace(send_lv.datastr);
            send_lv.send("output.php", "_self", "POST");
            myText.text = "success";
      } else {
            myText.text = "failed";
      }
};
my_lv.load("test.txt");


In the php file, the textfile url is passed as an argument to a "file_get_contents" command and then is sent through the pdf commands:
<?php
$txtfile = $_POST['datastr'];
//echo 'output:'.$txtfile;
$pdfdata = file_get_contents($txtfile);


// Defines the header for the page and outputs a PDF file
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=myPDF.pdf");
header("Pragma: no-cache");
header("Expires: 0");

// $pdfdata is the variable sent from flash.
// $pdfdata contains a few non compliant characters and this fixes that
$pdfdata = str_replace(") \'", ") '", $pdfdata);
$pdfdata = str_replace("\)", ")", $pdfdata);
$pdfdata = str_replace("\(", "(", $pdfdata);

// This should be the same as CFOUTPUT
// It basically redefines the headers for the page and prints out the data in $pdfdata
// outputing a pdf file.
echo $header.'\n'.$pdfdata;

?>


Anyway, that's where it ended up and it correctly spits out a normal pdf now. Thanks again for your time and sorry about the unorganized mess this morning. Wink
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
Display posts from previous:   
View previous topic :: View next topic  
FlashVacuum Forum Index >> ActionScript 2.0 :: FMX 2004 >> sendAndLoad headaches
Post new topic   Reply to topic
View previous topicEmail this thread to a friendPrinter-friendly versionLog in to check your private messagesView next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Jump to:  



Page generation time : 0.3687s  (PHP : 83%  -  SQL : 17%)   -   SQL queries : 23   -   GZIP : Disabled   -   Debug : On   -   Server Load : 9 pages served in past 5 minutes.