Version 1:

public class EmbedTest extends Sprite {
        [Embed(source="clear.png")]
        private static const PRO_CAR : Class;
        public static const ALL_CARS:Array = [PRO_CAR];

        public static function getAsset( index:uint ) : Bitmap {
                return new ALL_CARS[index]();
        }

        public function EmbedTest() {
                addChild(getAsset(0));
        }
}

Version 2:

public class EmbedTest2 extends Sprite {
        [Embed(source="clear.png")]
        private static const PRO_CAR : Class;

        public static function getAsset(name : String) : Bitmap {
                try {
                        return new EmbedTest2[name]();
                } catch (e:Error) {
                        trace ("ERROR asset is not accessible " + name);
                }
                return new Bitmap();
        }

        public function EmbedTest2() {
                addChild(getAsset("PRO_CAR"));
                addChild(getAsset("PRO_CAR2"));
        }
}
        
Am 11.02.2011 15:30, schrieb Sidney de Koning - Funky Monkey Studios:
public static function getAsset( index:uint ):Bitmap {

                        return Bitmap( new ALL_CARS[index]() as Class );
                }

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to