Creating asset library while working with AS3 projects

While working on an AS3 project I wished I had a easy way of managing asset library required for the project. I had used this technique for that, hopefully this helps others

package assets.sound
import flash.utils.getDefinitionByName;

public class SoundLibrary

[Embed(source="assets/sound/sounds.swf", symbol="SoundCorrect")]
public static const SoundCorrect:Class

[Embed(source="assets/sound/sounds.swf", symbol="SoundWrong")]
public static const SoundWrong:Class

public static function getAssetClass(assetName:String):Class{
return getDefinitionByName("assets.sound::SoundLibrary_"+assetName) as Class;

public function SoundLibrary()

Below is the code snippet to make use of the sound library

var tempClass:Class = SoundLibrary.getAssetClass("SoundCorrect");
var correctSound:Sound = new tempClass() as Sound;;

Library what I had created was for audio’s, this is applicable for assets which can be embedded by flex SDK.

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Leave a Comment

Your email address will not be published. Required fields are marked *

Disclaimer: All published content views of author.