3 Replies Latest reply on Oct 5, 2006 12:16 PM by crazyjoemilan

    Access Shared Library Assets via ActionScript?

    punjab4833
      Does anyone know if it is possible to have assets from a shared library accessed via ActionScript?

      What I want to do is have bitmaps stored in the library of a flash movie. I'll assign them linkages and then publish the SWF (for example, to mymovie.swf).

      I want to then be able to loadMovie("mymovie.swf"), and access the Bitmaps from the mymovie file using their linkage IDs, so that I could dynamically create bitmaps that were loaded from a separate flash library.

      I do NOT want to have to import those bitmaps from within the FLA file at authoring time. Is this possible?
        • 1. Re: Access Shared Library Assets via ActionScript?
          crazyjoemilan Level 2
          yes. using loadmovie, you'll load your master .swf into your current movie. Then you'll load in your bitmaps using the instance names they're given.

          You'll have to pay close attention to the path where you're loading the master movie, but yes, then you can play with it.
          • 2. Re: Access Shared Library Assets via ActionScript?
            punjab4833 Level 1
            Can you give a specific example with some actionscript? I've tried doing something like this I think.

            Say I have icons.fla, that has a bitmap loaded into the library. I've assigned that a linkage of "myicon", and it's checked to export to actionscript.

            Then I have a loadicons.fla. On the root timeline, I do:

            import flash.display.BitmapData;
            _root.createEmptyMovieClip("icon_loader", 1);
            _root.icon_loader.loadMovie("icons.swf");

            var bmap:BitmapData = BitmapData.loadBitmap( /* WHAT DO I PUT IN HERE? */);

            At this point, how do I reference a linkage from the icons.swf library? If you help me get this to work, you are a god:)
            • 3. Re: Access Shared Library Assets via ActionScript?
              crazyjoemilan Level 2
              so then your movieclips will be in _root.icon_loader

              so if you have a bitmap in an MC instance called icon1 on the _root level of icons.swf, you can reference ICONONE by saying

              _root.icon_loader.ICONONE

              From there you can do whatever you'd like with it. If you want to display info about ICONONE you'll have to call for it after the movie loads. ie- use a preloader to kick back when its done, or an event listener.