Flex 中嵌入资源

952阅读 0评论2008-04-02 panzt
分类:

转自:

嵌入图像(多个实例)

xmlns:mx=””
layout=”horizontal” width=”350″ height=”250″>


[Embed(source=”assets/logo.png”)]
[Bindable]

public var Logo:Class;

]]>

嵌入一个图像(单个实例)

xmlns:mx=””
width=”200″ height=”240″>

嵌入使用 scale-9 缩放的图像


xmlns:mx=””
layout=”vertical” width=”400″ height=”480″>


[Embed(
source=”assets/fancy_border.png”,
scaleGridTop=”55″, scaleGridBottom=”137″,
scaleGridLeft=”57″, scaleGridRight=”266″

)]

[Bindable]
public var FancyBorderImage:Class;
]]>


使用 CSS 为皮肤嵌入图像


xmlns:mx=””
layout=”horizontal” width=”270″ height=”100″
horizontalAlign=”center” verticalAlign=”middle” >


Button
{
upSkin: Embed(”assets/box_closed.png”);

overSkin: Embed(”assets/box.png”);
downSkin: Embed(”assets/box_new.png”);

}

嵌入 SWF 文件


xmlns:mx=””
layout=”horizontal” width=”290″ height=”290″
horizontalAlign=”center” verticalAlign=”middle”>


[Embed(source=”assets/hourglass.swf”)]

[Bindable]
public var Hourglass:Class;
]]>


嵌入 SWF 库资源


xmlns:mx=””
viewSourceURL=”src/EmbeddingSwfLibraryAssets/index.html”
layout=”horizontal” width=”450″ height=”240″
horizontalAlign=”center” verticalAlign=”bottom”     >


[Embed(source=”assets/library.swf”, symbol=”BadApple”)]

[Bindable]
public var BadApple:Class;
[Embed(source=”assets/library.swf”, symbol=”Pumpkin”)]

[Bindable]
public var Pumpkin:Class;

]]>

height=”151.8″/>

嵌入声音文件


layout=”vertical” horizontalAlign=”center” verticalAlign=”center” >


import mx.core.SoundAsset;
import flash.media.*;

[Embed(source=”assets/pie-yan-knee.mp3″)]

[Bindable]
public var Song:Class;

public var mySong:SoundAsset = new Song() as SoundAsset;
public var channel:SoundChannel;

public function playSound():void
{

// Make sure we don’t get multiple songs playing at the same
time
stopSound();

// Play the song on the channel
channel = mySong.play();
}

public function stopSound():void
{

// Stop the channel, but only if it exists
if ( channel != null ) channel.stop();
}

]]>




嵌入字体


xmlns:mx=””
layout=”horizontal”
horizontalAlign=”center”
verticalAlign=”center”   >


@font-face
{
font-family: Copacetix;

src: url(”assets/copacetix.ttf”);
unicode-range:
U+0020-U+0040, /* Punctuation, Numbers */

U+0041-U+005A, /* Upper-Case A-Z */
U+005B-U+0060, /* Punctuation and Symbols */
U+0061-U+007A, /* Lower-Case a-z */
U+007B-U+007E; /* Punctuation and Symbols */

}
.MyTextStyle
{
font-family: Copacetix;
font-size: 24pt;
}

width=”100%”/>

上一篇:AMF 简介
下一篇:Flex中处理事件