Embeding external assets and resources


Usually, applications works with assets that has nothing to be with buttons neither application components. Instead they use nicely designed items and draws.

This example shows you the new way to work with visual elements and how to bind a visual element to a Class.

package {
    import flash.display.Sprite;
    import flash.display.DisplayObject;
    import flash.events.*;

    public class ImageTest extends Sprite {
        public function ImageTest() {
            var embedObj:MyDog = new MyDog();
            addChild(embedObj);
        }
    }

    private class MyDog extends Sprite {
    	[Embed(source="dog.swf")]
        public var DogGraphic:Class;

    	public function MyDog() {
    		var dg:DisplayObject = new DogGraphic();
    		dg.scaleX *= -1.5;
    		dg.scaleY *= 1.5;

    		addChild (dg);
    		addEventListener(EventType.ENTER_FRAME,onEnterFrame);
    	}

    	public function onEnterFrame (event:Event) {
    		x += 1;
    	}
    }
}

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
DragManager
Cambiamos de idioma

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!



Bad Behavior has blocked 359 access attempts in the last 7 days.