如何通过按钮切换图片(AS3)
1、我们用的是AnimateCC,新建AS3文档。

3、分别将这几张图片转换为影片剪辑,并分别设置实例名为image0,image1,image2设置好后对齐这几张图片。

4、接下来制作按钮。这里我们用影片剪辑制作按钮。

6、接下来在主时间轴加如下代码:var image_index:int=0;var image_count:int=3;initImage();function initImage():void{ for(var i:int=0;i<image_count;i++) { if(i!=image_index) { this["image"+i].visible=false; } this["btn"+i].addEventListener(MouseEvent.CLICK,ChangeImage); } this["btn"+image_index].gotoAndStop(2);}function ChangeImage(e:MouseEvent):void{ var obj:Object=e.currentTarget; var t:int=int(obj.name.slice(3)); if(t==image_index) { return; } this["btn"+image_index].gotoAndStop(1); this["image"+image_index].visible=false; image_index=t; obj.gotoAndStop(2); this["image"+image_index].visible=true;}

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:92
阅读量:86
阅读量:75
阅读量:47
阅读量:26