【发布时间】:2011-07-18 10:27:03
【问题描述】:
我正在使用 flex 3 开发一个简单的 Mxml 应用程序。我使用了简单的文本和组合框。 组合框包含左右上下的项目,当我单击组合框中的每个元素时,滚动文本将沿选定的方向滚动,它工作正常。 我的问题是如何通过按键盘上、下、右和左键来修改此应用程序。而不是使用组合框元素??
我的应用代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Script>
<![CDATA[
public var mytimer:Timer=new Timer(10);
[Bindable]public var arr:Array=new Array("upScroll","LeftScroll","right","down");
private function initApp():void
{
mytimer.start();
mytimer.addEventListener(TimerEvent.TIMER,scrollme);
}
private function scrollme(event:TimerEvent):void
{
if(cmb.selectedLabel=="LeftScroll")
{
if(mytext.x==0)
mytext.x=this.width-mytext.width;
mytext.x--;
}
if(cmb.selectedLabel=="upScroll")
{
if(mytext.y==0)
mytext.y=600;
mytext.y--;
}
if(cmb.selectedLabel=="right")
{
if(mytext.x==this.width-mytext.width)
mytext.x=0;
mytext.x++;
}
if(cmb.selectedLabel=="down")
{
if(mytext.y==600)
mytext.y=0;
mytext.y++;
}
}
]]>
</mx:Script>
<mx:Text id="mytext" text="SCROLLING" fontSize="16" fontStyle="italic" fontWeight="bold"/>
<mx:ComboBox dataProvider="{arr}" prompt="Select" id="cmb" change="initApp()"/>
</mx:Application>
【问题讨论】:
标签: actionscript-3 events apache-flex flex3