unexpected result: setting vars on a library item is persistant
  • sstarksstark March 2012

    So my script is setting a custom var on library items in a collection. To my surprise, the variables retained their data the next time the script was run, so I had to include a loop which reset the data to defaults before running.

     

    This is prety cool!

     

    My question is this: If I were to want this, would the data save to the .FLA file and be retained the next time I opened it?

  • DaveDave March 2012

    Nope.

    But the LibraryItem class is dynamic, therefore you can set properties on it without any problem within a session. Some classes, like Document, you can't.

    xJSFL even defines a shortName getter on the LibraryItem.prototype at startup, so you can do this:

    var item = $library.items[5];
    trace(item.name);
    trace(item.shortName);

    // assets/graphics/Symbol 01
    // Symbol 01

    Generally though, xJSFL doesn't extend native items, it would subclass or wrap them.

    If you're setting variables on native objects, such as a counter, I'd think you'd probably want to think of another way to do what you're doing.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with OpenID Sign In with Google Sign In with Twitter

Sign In Apply for Membership

Tagged