• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS3 URLLoader.load not working

Community Beginner ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

I have a Flash app that I use to capture a webcam pic and save the image to a server database using classic ASP. I used to use NavigateToURL. Since the recent security updates (I'm testing with Flash 14.0.0.145) I've switched to URLLoader.load. It works on my local test environment, but does not work on the QA server at the client site, that is, the ASP doesn't receive the data and the photo isn't stored in the DB (I have absolutely NO ACCESS to the customer's server).

  • It is NOT cross-domain. The Flash swf is on the same server/same domain as the page I'm loading to.
  • Load fires the completeHandler, and I don't get any errors (but loader.data is blank; not sure what to look at to see number of bytes sent???)
  • In the ASP page, I tried storing Request.TotalBytes to see if I'm getting anything but it doesn't work (no database entry is made).

Ideas for things to try, solution?

Code:

function UploadImage(e:MouseEvent):void {

  var previewW:int = 94;

  var previewH:int = 118;

  var CropRectX:int = CropRect.x + 83;

  var CropRectY:int = CropRect.y + 28.5;

  //create a bitmap the size of the crop box

  var croppedBD:BitmapData = new BitmapData(CropRectCurrWidth, CropRectCurrHeight, false, 0x0000CC44);

  //create a rectangle relative to the cropbox in the video pane

  var rect:Rectangle = new Rectangle(CropRectX, CropRectY, CropRectCurrWidth, CropRectCurrHeight);

  var pt:Point = new Point(0,0);

  //copy the pixels from the crop area to the new bitmapData object

  croppedBD.copyPixels(cameraCaptureBD, rect, pt);

  var jpgEncoder:JPGEncoder = new JPGEncoder(100); // argument is the quality parameter

  var jpgStream:ByteArray = jpgEncoder.encode(croppedBD);

  //source: http://stackoverflow.com/questions/597947/how-can-i-send-a-bytearray-from-flash-and-some-form-data-t...

  var loader:URLLoader = new URLLoader();

  configureListeners(loader);

  var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

  var request:URLRequest = new URLRequest(SaveURL);  //value: "SavePhoto.asp"

  request.requestHeaders.push(header);

  request.method = URLRequestMethod.POST;

  request.data = jpgStream;

  try

  {

  loader.load(request);

  try

  {

  navigateToURL(new URLRequest(DoneURL), "_top");  //DoneURL = "PrintPassesFrame.asp#" & [passID Num]

  } catch (error:Error)

  {

  msg.text = msg.text + error.message;

  }

  } catch (error:Error)

  {

  msg.text = msg.text + error.message;

  }

         function configureListeners(dispatcher:IEventDispatcher):void {

            dispatcher.addEventListener(Event.COMPLETE, completeHandler);

            dispatcher.addEventListener(Event.OPEN, openHandler);

            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);

            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

            dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

        }

         function completeHandler(event:Event):void {

            var loader:URLLoader = URLLoader(event.target);

  msg.text = msg.text + "completeHandler: " + loader.data;

   

            var vars:URLVariables = new URLVariables(loader.data);

  msg.text = msg.text + "The answer is " + vars.answer;

        }

         function openHandler(event:Event):void {

  msg.text = msg.text + "openHandler: " + event;

        }

         function progressHandler(event:ProgressEvent):void {

            trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);

  msg.text = msg.text + "progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal;

        }

         function securityErrorHandler(event:SecurityErrorEvent):void {

  msg.text = msg.text + "securityErrorHandler: " + event;

        }

         function httpStatusHandler(event:HTTPStatusEvent):void {

  msg.text = msg.text + "httpStatusHandler: " + event;

        }

         function ioErrorHandler(event:IOErrorEvent):void {

  msg.text = msg.text + "ioErrorHandler: " + event;

        }

}

TOPICS
ActionScript

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 28, 2014 Jul 28, 2014

i can't help you with that.

use a network analyzer to see what's going on.

Votes

Translate

Translate
Community Expert ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

you have to debug on the server.  if you can't upload your test files to the server, there's no way to debug.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

I am testing on the server, I meant that I can't change settings on the server, such as security policies.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

Update:

On database insert receive #2032: Stream Error

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

change your allowscriptaccess to always.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

I just tested setting allowscriptaccess to always (it was sameDomain) but it didn't help.

Here are the messages I'm getting:

openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]

progressHandler loaded:391 total: 391

httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=500 redirected=false responseURL=null]

ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032"]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

what's the url to your embedding swf?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

<param name="movie" value="WebCamPhotoCapture.swf" />

Does this answer your question?

full source:

<script language="JavaScript" type="text/javascript">

  AC_FL_RunContent(

  'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',

  'width', '700',

  'height', '275',

  'src', 'WebCamPhotoCapture',

  'quality', 'high',

  'pluginspage', 'http://www.adobe.com/go/getflashplayer',

  'align', 'middle',

  'play', 'true',

  'loop', 'true',

  'scale', 'showall',

  'wmode', 'window',

  'devicefont', 'false',

  'id', 'WebCamPhotoCapture',

  'bgcolor', '#ffffff',

  'name', 'WebCamPhotoCapture',

  'menu', 'true',

  'allowFullScreen', 'false',

  'allowScriptAccess','always',

  'movie', 'WebCamPhotoCapture',

  'FlashVars','SaveURL=<%response.write SavePhotoURL%>&DoneURL=<%response.write DoneURL%>',

  'salign', ''

  ); //end AC code

</script>

<noscript>

  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="700" height="275" id="WebCamPhotoCapture" align="middle">

  <param name="SavePhotoURL" value="/visitorsystem/SavePhoto.asp?file=photo.jpg" />

  <param name="allowScriptAccess" value="always" />

  <param name="allowFullScreen" value="false" />

  <param name="movie" value="WebCamPhotoCapture.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="WebCamPhotoCapture.swf" quality="high" bgcolor="#ffffff" width="700" height="275" name="WebCamPhotoCapture" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />

    <PARAM NAME=FlashVars VALUE="SaveURL=<%response.write SavePhotoURL%>&DoneURL=<%response.write DoneURL%>">

  </object>

</noscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

no.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2014 Jul 28, 2014

Copy link to clipboard

Copied

i can't help you with that.

use a network analyzer to see what's going on.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 29, 2014 Jul 29, 2014

Copy link to clipboard

Copied

The true problem had nothing to do with Flash/AS3. It was a problem with a badly formed SQL statement in the server-side vbscript. The network analyzer (I used Microsoft Network Analyzer) allowed me to see every network traffic event that occurred when I launched the Save Photo function. I could then scan the events for the error and traverse the event tree and find the SQL error which was the root cause of the problem. This was impossible otherwise because the ASP page runs in the background.

Thanks kglad, for leading me in the right direction!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2014 Jul 29, 2014

Copy link to clipboard

Copied

LATEST

you're welcome, and congratulations on solving that problem!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines