library fonts selector
  • sstarksstark September 2012

    Hello,

    I couldn't get the selector $$ to work with library fonts, I had to instead iterate through the entire library and look for all instances that are fonts.

    I feel like I am doing this the hard way, or I am missing something?

    Tries:

    $$("fonts");

    but instead, need to use:

    var libraryItems = dom.library.items;
    var i = libraryItems.length;
    while (i--) {
    var item = libraryItems[i];
    if (item.itemType == "font") {
    processFont(item);
    }
    }

     

  • DaveDave September 2012

    Sorry for the delay in replying... the forum's been a bit quiet for a bit!

    It's:

    $$(':font');

    That's a pseudo (filter) class, just like CSS. In this case, looking for an item, the type of which, is "font".

    You could also pick ":movieclip", ":graphic", etc. as well as the other pseudo properties like ":last", ":random", or ":children".

    Back to your syntax, as you've just done this...

    $('fonts');

    ...xJSFL would look for any items named "fonts", so "assets/fonts" or such like, would be found.

    There's a handy table here with the all the syntaxes: http://www.xjsfl.com/support/api/elements/selectors#selectors-table

     

  • sstarksstark September 2012

    I tried a few things but it didn't work, I'll try your suggestions and let you know. thanks!

  • DaveDave September 2012

    Any reason it wasn't clear in the first place? Are the docs not up to scratch?

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