Image Actionscript3-使用按钮在图像之间切换

Image Actionscript3-使用按钮在图像之间切换,image,actionscript-3,apache-flex,flash-builder,Image,Actionscript 3,Apache Flex,Flash Builder,我正在FlashBuilder中打开一个新的flex项目,我正在尝试用三个按钮,猫、狗和鸟来创建一个界面。当按下每个按钮时,我想在屏幕底部的图像框中填入相应的动物图像 我在搞清楚如何在AS3中显示图像时遇到了很多麻烦。有人能帮我指出正确的方向吗?如果您不介意swf嵌入这三个图像,最简单的方法之一是: 嵌入代码 [Embed(source="/../assets/cat.jpg")] static private const Cat:Class; [Embed(source="/../assets

我正在FlashBuilder中打开一个新的flex项目,我正在尝试用三个按钮,猫、狗和鸟来创建一个界面。当按下每个按钮时,我想在屏幕底部的图像框中填入相应的动物图像


我在搞清楚如何在AS3中显示图像时遇到了很多麻烦。有人能帮我指出正确的方向吗?

如果您不介意swf嵌入这三个图像,最简单的方法之一是:

嵌入代码

[Embed(source="/../assets/cat.jpg")]
static private const Cat:Class;
[Embed(source="/../assets/dog.jpg")]
static private const Cat:Class;
[Embed(source="/../assets/bird.jpg")]
static private const Cat:Class;
容器初始化

private var imageBox:Sprite = new Sprite;
// initialize imagebox position/chose parent here, for instance:
container.addChild(imageBox);
cat按钮点击处理程序

imageBox.removeChildren();
imageBox.addChild(new Cat);
imageBox.removeChildren();
imageBox.addChild(new Dog);
imageBox.removeChildren();
imageBox.addChild(new Bird);
狗按钮点击处理程序

imageBox.removeChildren();
imageBox.addChild(new Cat);
imageBox.removeChildren();
imageBox.addChild(new Dog);
imageBox.removeChildren();
imageBox.addChild(new Bird);
鸟按钮点击处理程序

imageBox.removeChildren();
imageBox.addChild(new Cat);
imageBox.removeChildren();
imageBox.addChild(new Dog);
imageBox.removeChildren();
imageBox.addChild(new Bird);

我假设你的项目有assets&src目录,分别包含你的图像和你的as3代码

你应该尝试用谷歌搜索这些基本的东西。关于这个话题有很多信息