10:59

Flex - Hareketli Metin Komponent Örneği

Hareketli Metin Komponenti:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
creationComplete="init()">

<mx:Script>
<![CDATA[
private var myTimer:Timer = new Timer(10);

[Bindable]
public var text:String;

public function start():void
{
myTimer.start();
}

public function stop():void
{
myTimer.stop();
}
private function init():void
{
myTimer.addEventListener(TimerEvent.TIMER, moveLabel);
}

private function moveLabel(event:TimerEvent):void
{
if (scrollingLabel.x < (0-scrollingLabel.width))
{
scrollingLabel.x = this.width;
}
else
{
scrollingLabel.x --;
}
}
]]>
</mx:Script>

<mx:Label id="scrollingLabel" x="{this.width}" text="{text}"/>
</mx:Canvas>


Komponenti çağırıp fonksiyonlarını tetikleme:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:components="components.*">
<components:ScrollingText id="myScrollingText" text="Basit bir mesaj"
fontSize="18"/>
<mx:Button label="Başla" click="myScrollingText.start()"/>
<mx:Button label="Dur" click="myScrollingText.stop()"/>
</mx:Application>

0 yorum:

Yorum Gönder