Skip to main content
Known Participant
June 30, 2010
Question

urlloader, not getting answer

  • June 30, 2010
  • 1 reply
  • 666 views

hi, i have this (more or less):

----------------------------------------

var loader_grabar_imagen:URLLoader = new URLLoader();

loader_grabar_imagen.dataFormat = URLLoaderDataFormat.VARIABLES;

function grabar_bd_imagen(_cadena:Array):void {

(...) // do some stuff


    var _enviar:URLVariables = new URLVariables("dibujo="+_convertido);
    var _request:URLRequest = new URLRequest(url_grabar_dibujos);
    _request.method = URLRequestMethod.POST; // POST, ya que por el tamaño del dibujo como string no pasa por GET
    _request.data = _enviar;
    //
    try
    {
        loader_grabar_imagen.load(_request);
    }
    catch (error:Error)
    {
        confirmar_NO_grabar();
    }
}

function grabar_resultado(event:Event):void {

    gotoAndStop("some_frame")
}

loader_grabar_imagen.addEventListener(Event.COMPLETE, grabar_resultado);

--------------------------------------------

in summary: i declare an urlloader. there is a function that tells it to 'load'. there is also another function which is set as 'event.complete' for that urlloader, which should run when that thing finishes. since the first sentende in the complete handler is a goto, it does not depend of the answer per se, but just that ot gets an answer, or that the event is triggered and the handler is called. if it 'completes loading', it should call the handler, thats all.

the problem: is not happening. there is no answer, and there is a block when the loader starts the query to avoid changes meanwhile, it does not get any answer (it does not jump to the frame).. any pointers?

tnx

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 30, 2010

are you calling that function grabar_bd_imagen()?    use the trace() function to confirm.  if confirmed, do you see an error message?  if not, are you attemping a cross-domain load?

Known Participant
June 30, 2010

hi, tnx for your answer. the situation is more or less: i need to send some data to a database, and confirm with either the id given to the new row in the database or -1 if error in the insert query. it seems the database is working ok, if i call the server script, it will echo the result i want (in the browser). in the actionscript, i declared an urlloader, and for this loader i declared both a complete event handler and io error event handler. it seems the part of sending data to the database works ok, since the database is changed, the new row inserted (the data is originated in the flash movie) and everything ok so far, but i need the answer, and it seems the handler for the 'complete' (neither error) is never called. i am not using trace since i am testing directly on the server (i have no php as local at the moment), it sends the data but since the on complete handler is never called (it does not execute the goto), i have no answer on what happened about the query. i am sure i added event listener as posted above, the handler function is declared, i have no idea why there is no answer, so the program gets stuck, since there is no answer after the loader.load

Known Participant
June 30, 2010

solved. the problem was like this: in the first frame it was:

define startup loader

set startup cpmplete handler

try to load startup loader

define other loaders for operations while running

set handlers for those loaders

stop

----

it was kindda sloppy when i wrote the startuploader.load() after defining its handler. the handlers and functions after that sentence were defined, but stand alone code was not executed. that was a mistake, though it should have not executed (it seems) only if the handlers for the events were executed in a linear way, in the same thread, not as a result of an event