dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Dynamically get variable names?

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Location
    California
    Posts
    149

    Dynamically get variable names?


    I'll do my best to explain.
    I'd like to know if there is a way to dynamically detect the variable names when a text file is loaded into a Flash movie using LoadVars. I'm doing a test with a file and here is the output:

    Variable _level0.instance1.loadText = [object #58, class 'LoadVars'] {
    onLoad:[function 'onLoad'],
    header:"This is my text.",
    firstParagraph:"Lorem ipsum dolor sit amet."
    }

    So basically how can I detect that there are 2 variables being passed in?

    Hope that makes sense
    Thanks

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    something like
    for(var j in obj)
    trace(j + ' ' + typeof(obj[j]) + ' ' + obj[j];

    Obj should be a valid reference to the loadvars object

    Musicman

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Location
    California
    Posts
    149
    I don't quite understand. Here is my LoadVars function:

    loadText = new LoadVars();
    loadText.load(path);
    loadText.onLoad = function(success) {
    trace (loadText);
    };

    How do I implement your code?

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    this should work...

    loadText = new LoadVars();
    loadText.load(path);
    loadText.onLoad = function(success) {
    for(var j in loadText)
    trace(j + ' ' + typeof(loadText[j]) + ' ' + loadText[j];
    };

    Musicman

  5. #5
    Senior Member
    Join Date
    Oct 2000
    Location
    California
    Posts
    149
    ahh...now I get it.
    Thanks for the help MM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center