Skip to main content
Participant
March 1, 2011
Question

Some trouble with LoadVars class in SSAS application

  • March 1, 2011
  • 2 replies
  • 711 views

I want to poll external script in applcation using LoadVars instance. That's code:

myVars.onLoad = function (success) {
if (success) {
trace ("variable: "+ myVars.flv);
trace(this.toString());
for( var prop in this ) {
trace (" key " + prop + " = " + this[prop]);
}
application.PlayFLV(myVars.flv);

} else {
trace (" Error loading variables ");
}
}
};

So i can see in Administration Console raw value in this instruction:

trace(this.toString());

but I see also "variable: undefined" on line:

trace("variable: " + myVars.flv);

Note: in cycle for i can see all "key = property" pairs i need, including .flv property, but it writes "undefined" as i mentioned!

What's going wrong!?

more: When i'm trying to add array declaration like this:

var propy:Array = new Array();

an application falling down with error: NetConnection.Connection.Failed?!

Can someone explain what's going on? How can I access to required property??

    This topic has been closed for replies.

    2 replies

    March 1, 2011

    About your second question... server side actionscript is not typed, so

    var a:Array

    Will throw an error. Just declare the variable with no type

    March 1, 2011

    Looks like a scope problem.

    You're evaluating myVars.flv from within a member function of myVars. As a result, the code is looking for a property named myVars as a property of myVars (read: myVars.myVars.flv). Changing myVars.flv to this.flv should fix it.

    NBS-adminAuthor
    Participant
    March 3, 2011

    Yes it's not strictly typified and

    var a = new Array();

    is working, thanks.

    I've tested this.flv before post has been created. No result. So that's a code:

    myVars.onLoad = function (success) {
    if (success) {
        trace(this.flv);     trace(this.toString());
    for( var prop in this ) {
      if (prop == "flv"){
          trace (" key " + prop + " = " + this[prop]);
      } else {
          trace("Nothing!")
      }
      }
    application.PlayFLV(this.flv);
      } else {
    trace (" Error loading variables "); }
    }
    };

    That's output in Administration console:

              undefined         
              flv=testing%2f33%2eflv
              File is:undefined    //call application.PlayFLV(this.flv)

    I guess property .flv is not visible in if condition:

    OK, then I remove if condition, so code snippet is next:

    myVars.onLoad = function (success) {
        if (success) {
              trace(this.flv);
              trace(this.toString());
              for( var prop in this ) {
              trace (" key " + prop + " = " + this[prop]);
              }

    and response in console is:

    undefined
    flv=testing%2f33%2eflv
      key flv = testing/33.flv     !! here property .flv is defined
      key contentType = application/x-www-form-urlencoded
      key loaded = true
      key onLoad = function (success) {
            if (success) {                    trace(this.flv);                                     trace(this.toString());
                   for (var prop in this) {
                         trace(" key " + prop + " = " + this[prop]);
                                          }
                        application.PlayFLV(this.flv);
            } else {
               trace(" Error loading variables ");
                   }    }
    File is:undefined

    Very queer issue isn't it?? I need to get this naughty property!!