题
我想在 Flex 应用程序中显示一些隐藏的文本,并让它在几秒钟内淡出......
我研究过 Flex 中的延迟和暂停效果,但还没有看到如何实现这种实际简单效果的示例......
现在有人该怎么做或者有好的资源吗?
谢谢。
解决方案
如果我理解正确的话,您想让文本在显示几秒钟后自动淡出吗?
我可能会做这样的事情:(尚未测试代码,因此可能存在拼写错误。)
<mx:Script>
import flash.utils.*;
var fadeTimer:Timer = new Timer(2000); // 2 seconds
fadeTimer.addEventListener("timer", fadeTimerTickHandler);
// Call this to show the hidden text.
function showTheText():void{
theTextField.visible = true;
fadeTimer.start();
}
// This gets called every time the timer "ticks" (2 seconds)
function fadeTimerTickHandler(eventArgs:TimerEvent){
fadeTimer.stop();
fadeTimer.reset();
theTextField.visible = false;
}
</mx:Script>
<mx:Fade id="hideEffectFade" alphaFrom="1.0" alphaTo="0.0" duration="900"/>
<mx:Text id="theTextField" text="The Text" hideEffect="{hideEffectFade}"/>
此外,您需要确保嵌入字体,否则效果将无法在您的文本上发挥作用。看 西蒙的帖子 了解更多信息。
不隶属于 StackOverflow