
임베디드 FLEX
글 수 19
2008.10.13 10:18:55 (*.138.143.22)
85906
Embed 명령을 이용하여 이미지를 내장하고 타이머 이벤트와 랜덤 함수를 이용하여Image 컴포넌트에 이미지를 임의로 표시한다.
소스 및 폼
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Image;
private const TIMER_INTERVAL:int = 200; // m sec 단위
private var tmTimer : Timer;
private var randomData : int;
[Bindable] [Embed(source='image/black.png')] private var imgBlack:Class;
[Bindable] [Embed(source='image/red.png')] private var imgRed:Class;
[Bindable] [Embed(source='image/blue.png')] private var imgBlue:Class;
[Bindable] [Embed(source='image/green.png')] private var imgGreen:Class;
[Bindable] [Embed(source='image/white.png')] private var imgWhite:Class;
private function init():void {
tmTimer = new Timer( TIMER_INTERVAL );
tmTimer.addEventListener(TimerEvent.TIMER, updateTimer);
tmTimer.start();
}
private function updateTimer(evt:TimerEvent):void {
randomData = Math.round(Math.random() * 4 );
switch(randomData)
{
case 0 : imgTarget.source = imgBlack; break;
case 1 : imgTarget.source = imgRed; break;
case 2 : imgTarget.source = imgBlue; break;
case 3 : imgTarget.source = imgGreen; break;
case 4 : imgTarget.source = imgWhite; break;
}
}
]]>
</mx:Script>
<mx:Image x="178" y="140" width="64" height="64" source="{imgBlack}" id="imgTarget"/>
</mx:Application>
실행 화면 캡쳐
예제 실행
unable to transcode image 'image/black.png'
어찌해야하찌요.