Topic: cgi-bin problems

hi,

been playing around with flite which seems to work quite well (some voices are far to slow but kal16 and the time one are fine).

so i was trying to make a simple clock widget that speaks the time, just by extending the sampleclock.fla on the wiki.

i made a perl script based on others around the forum to serve up the crossdomain.xml file and run flite_time with the current time as an argument and it works fine just putting the url into my browser (get a valid crossdomain.xml and the speaking works). but i can't for the life of me work out how to get flash to trigger it.

if i load the flash in my browser and enable policy file logging it says "Error: Ignoring policy file at http://192.168.1.43/cgi-bin/custom/speak?POLICY due to meta-policy 'master-only'." which i guess is due to the changes in flash 9/10 so won't be wrong for the chumby?

by adding touch calls in my cgi script i can see that when run on the chumby (either from chumby.com or via chumbyflashplayer.x) the policy file is grabbed, but the second file is never requested (though the "CLICK" trace is written).

what am i doing wrong? any ideas?

my cgi-bin script:

chumby:/psp/cgi-bin# cat speak 
#! /usr/bin/perl

#
# get the arguments in the URL
#

$request = $ENV{'QUERY_STRING'};  # get the URL parameters
$request =~ s/\%20/ /g;           # unencode spaces - may need other later
@fields = split/\?/, $request;    # split into seperate arguments
$fields[0] = uc($fields[0]);      # convert to upper case

if ($fields[0] eq "TIMENOW") #say the current time
{
  my $test= system("/bin/touch /psp/nowtime");
    ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
    my $rc = system("/psp/usr/bin/flite_time $hour:$minute");

  print "content-type:text\/html\r\n\r\n";   
  print "done=true\r\n\r\n";
}
if ($fields[0] eq "POLICY") # URL get policy
{
  my $test= system("/bin/touch /psp/policy");
  # send the crossdomain policy file
  print "Content-type:text\/xml\r\n\r\n";
  print "<\?xml version=\"1.0\"\?>\r\n\r\n";
  print "<cross-domain-policy>\n";
  print "  <allow-access-from domain=\"\*\" \/>\n";
  print "<\/cross-domain-policy>\n";
}

and the addition to the sampleclock.fla:

this.onMouseDown = function() {
    System.security.loadPolicyFile("http://192.168.1.43/cgi-bin/custom/speak?POLICY")    
    var speak:XML = new XML();
    speak.load("http://192.168.1.43/cgi-bin/custom/speak?TIMENOW")
    trace("CLICK");
};

Re: cgi-bin problems

Try changing the content type of your cross domain output to "text/x-cross-domain-policy" and also adding the header "X-Permitted-Cross-Domain-Policies: all".  Let us know if it works!

Re: cgi-bin problems

thanks! that gets me a bit further. now when running with the debug version of flash 10 on my pc i get a "OK: Policy file accepted". but the .load still never hits the cgi script either on the chumby or on my pc. i don't understand why the trace that comes after it fires, but the .load doesn't seem to do anything.

so i guess the problem is definitely in my actionscript and not to do with the cross domain stuff now.

i tried taking the LoadPolicyFile outside of the onMouseDown so it happens as soon as the widget is loaded in case it needed some time to finish, i tried using XML and LoadVars objects to do he requesting - none seem to do anything. other people on this forum seem to be using similar code, i must be doing something silly...

looks like i'm stuck again :-(

Re: cgi-bin problems

Looking at it again, I notice that speak is a local variable to this function.  Since xml.load is asynchronous, it's likely that speak is going away before the actual HTTP load starts.  Try making speak a global variable or a member of a class that sticks around.

Re: cgi-bin problems

thanks ben, yes that was it! now my chumby speaks to me wink

still trying to get my head around as2, and i don't think the ambiguous nature of the flash ide (all this timeline business is confusing!) is helping matters! now i've got it to work i will try writing something using mtasc or haxe and then package something up here.