Enterprise APP

The Solution of embedding image, swf, xml, byteArray 본문

Flex General/Guide

The Solution of embedding image, swf, xml, byteArray

로드스타 2010. 1. 28. 14:08
Image

[Embed(source="assets/photo.jpg")]
private const PhotoImage:Class;

1.
var myPhoto:DisplayObject = DisplayObject(new PhotoImage());

2.
var imgObj:BitmapAsset = new PhotoImage() as BitmapAsset;

 // Modify the object.
 imgObj.bitmapData.noise(4);

// Write the modified object to the Image control.
myImage.source=imgObj;

<mx:Image id="myImage" />

SWF

[Embed(source="MenuAssets.swf", symbol="com.partlyhuman.assets.TopMenuItem")]
protected const TopMenuItem:Class;

addChild(Sprite(new TopMenuItem()));

XML

[Embed(source="test.xml", mimeType="text/xml")]
protected const EmbeddedXML:Class;

var x:XML = XML(new EmbeddedXML());
trace(x.toXMLString()); //it should work!

ByteArray

public class DoomTest extends Sprite {
    [Embed(source="doom1-shareware.wad", mimeType="application/octet-stream")]
    private const DoomWad:Class;

    public function DoomTest() {
        var wad:ByteArray = new DoomWad() as ByteArray;
        new DoomCore(this,wad);
    }
}

Comments