Flash question

  • Started
  • Last post
  • 2 Responses
  • OBBTKN

    Hi everyone.

    I need some help in flash:
    I´ve got a little questionaire what is sended using asp and writen on a sql database.
    Everything is ok, but i need to capture the "OK" response from the server.

    The AS i´ve got:

    stop();
    _root.variables = _root.variables;
    loadVariablesNum("data.asp?", 0, "POST");
    if(this.writing=="Ok") {
    gotoAndStop("ok")
    else
    gotoAndStop("error")};

    I know, i need to create a function...

    Any suggestion?

    Thanks in advance

  • maximillion_0

    from the manual:

    loadVariablesNum("params.txt", 2);
    function checkParamsLoaded() {
    if (_level2.done == undefined) {
    trace("not yet.");
    } else {
    trace("finished loading. killing interval.");
    trace("-------------");
    for (i in _level2) {
    trace(i+": "+_level2[i]);
    }
    trace("-------------");
    clearInterval(param_interval);
    }
    }
    var param_interval:Number = setInterval(checkParamsLoaded, 100);

    your asp file will need to output some data to the file that is called. the data should be name / value pairs ie. var1="hello"&var2="goodbye"&done...

  • maximillion_0

    in as2 this is a much better way to do this

    var submitListener:Object = new Object();
    submitListener.click = function(evt:Object) {
    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
    if (success) {
    result_ta.text = result_lv.welcomeMessage;
    } else {
    result_ta.text = "Error connecting to server.";
    }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.name = name_ti.text;
    send_lv.sendAndLoad("http://www... result_lv, "POST");
    };
    submit_button.addEventListener... submitListener);