Flash Shared Library Assets Gotcha

Shared libraries are a great concept for Flash. You can store items that get used in several movies in a single file and then load them into the parent movies as their needed. I’m going to show you how…

In my Stargate Atlantis DHD Sim project there is a main movie called “dhd”. That has 36 graphical symbols in it that get used for the symbol buttons. Now I want to use those same symbols in a couple of other projects. Instead of just copying and pasting them into each project I think it will be much nicer to have a single .fla file for the symbols and then to dynamically share them with the other projects. This means when I want to update the symbols appearance I can do it in one place and the changes are automatically picked up by the other movies.

To set up this functionality is quite simple and it has an undocumented extra step which enables you to use the symbols via actionscript.

  • Create the movie with just the symbols in it
  • Make each symbol a seperate MovieClip/Button etc
  • Right click it in the library and choose “Linkage”
  • Give it an identifier name such as coolButton3, dont use spaces or funny characters. You can use this name in the parent clip to attachMovie instances of this symbol
  • Tick Export for ActionScript, Export for runtime sharing and Export in first frame
  • for the url type the name of the published shockwave i.e mysymbols.swf
  • publish it File->Publish
  • you might want to check the publish settings and make the name matches what you put in the url field before. I normally just make my .fla file have the same name so it automatically matches.

That is the source movie sorted. Now load up the .fla for the movie you want to use those images in. Lets call it “symboluser.fla”.

  • Open symboluser.fla at the same time as having mysymbols.fla open
  • open the library panel Window->Library or Ctrl-L
  • at the top of the library panel you will have a drop down box that will let you switch between the libraries. switch to the other symbols.fla library but leave your main document open to the symboluser movie.
  • now tap the “new library panel” button. its two from the right of the drop down box. that will open a second library window with your current movies library in it.
  • I store my library items in their own folders so in this case i have a folder called “symbols”. Just drag and drop the folder icon into the current movies library. if you didnt use a folder but just have all the symbols then just select them all and drag n drop them over.
  • Now the final bit which is the hidden gotcha. You’ve got to drag an instance of the clips out of the symboluser library and onto its stage. if you align your flash document to always be anchored at the top left corner (File->Publish Settings->Html) you can just put them all above the top left corner to hide them easily. You can select them all and do a single drag n drop btw
  • pat yourself on the back

Now you can either use them manually on the stage by draggin n dropping instances of them or you can use them via attachMovie i.e. with a clip called coolButton3 we would do:

myButton.attachMovie("newinstancename", "coolbutton3", itsdepth, {_x:20, _y:10});

which would create an instance of the shared library symbol in the myButton clip and position it to x:20, y:10. cool ay 😊

Share Article

Comments: None so far...be the first!

Leave a reply

Please fill in the form fields and improve Skynet by completing the captcha!

Thank you! All comments are moderated so yours will appear shortly.

Don’t be too proud of this technological terror you’ve constructed; the ability to destroy a planet is insignificant next to the power of the Force.

— Darth Vader