Flash Lite 2.x 入门 |
|
|
|
| 教程:创建 Flash Lite 应用程序 > 创建应用程序 > 创建特色餐屏幕 > 将导航和文本添加到特色餐屏幕 | |||
在本部分中,您将在 Specials 屏幕上添加交互,使用户能够控制每个动画之间的过渡。您还将添加动态文本字段,以显示每个图像的名称和说明。
此文本字段会显示屏幕上显示了其图像的特色餐的名称。


stop();
fscommand2("SetSoftKeys", "Home", "Next");
title_txt.text = "Summer salad";
description_txt.text = "Butter lettuce with apples, blood orange segments, gorgonzola, and raspberry vinaigrette.";
此代码在两个动态文本字段中显示第一种特色餐的名称说明。它还会使播放头停止在当前帧上,并注册设备的软键。
stop(); title_txt.text = "Chinese Noodle Salad"; description_txt.text = "Rice noodles with garlic sauce, shitake mushrooms, scallions, and bok choy.";
stop(); title_txt.text = "Seared Salmon"; description_txt.text = "Filet of wild salmon with caramelized onions, new potatoes, and caper and tomato salsa.";
stop(); title_txt.text = "New York Cheesecake"; description_txt.text = "Creamy traditional cheesecake served with chocolate sauce and strawberries.";
gotoAndStop("specials");
这段代码将播放头返回到动画序列的开始处。动画序列中的第一个和最后一个图像相同,这会产生一种连续动画的幻觉。
接下来,您将在 Specials 屏幕上添加导航,使用户能够在每种特色餐的图像和说明之间导航。
Key.removeListener (myListener);
var myListener:Object = new Object ();
myListener.onKeyDown = function () {
var keyCode = Key.getCode ();
if (keyCode == ExtendedKey.SOFT1) {
// 处理左软键事件
gotoAndPlay ("home");
}
else if (keyCode == ExtendedKey.SOFT2) {
// 处理右软键事件
play ();
description_txt.text = "";
title_txt.text = "";
}
};
Key.addListener (myListener);
左软键可将播放头移到主应用程序屏幕,右软键可使图像动画前进到动画序列中的下一幅图像。
有关使用事件侦听器的详细信息,请参阅《开发 Flash Lite 2.x 应用程序》中的"使用按键侦听器处理按键事件"。
|
|
|
|