2 Replies Latest reply on Oct 28, 2010 1:07 PM by mlavie

    How to Add an Asset to a Library

    mlavie Level 1

      I am trying to add an asset to a library in CS5, using the Library.store() method.

       

      I tried the following:

       

       

          var assetItemsArray:Array = new Array();
          assetItemsArray.push(page.allPageItems);
          var asset:Asset = library.store(assetItemsArray);

       

       

      but got this error message:

      Error: Invalid value for parameter 'using' of method 'store'. Expected Array of PageItems, Movies, Sounds, Graphics or XMLElements, but received ((TextFrame)).

       

      What am I doing wrong?

       

      TIA,

      mlavie

        • 1. Re: How to Add an Asset to a Library
          Harbs. Level 6

          You are feeding it an array of arrays...

           

          try:

          library.store(page.allPageItems);

           

          However that will give you nested items. You probably want this instead:

           

          library.store(page.pageItems.everyItem().getElements());

           

          Harbs

          • 2. Re: How to Add an Asset to a Library
            mlavie Level 1

            I see it's "Harbs to the rescue" again... 

             

            Indeed, I had tried

             

            library.store(page.allPageItems);

             

            but it wouldn't compile in ActionScript, so I assumed that was not the way to go. Once you confirmed that that IS the solution, I tried

             

            library.store(page.allPageItems as Array);

             

            and that worked like a charm! And I DO need the nested items, thank you!

             

             

            mlavie