flex 点击按钮图片切换
2019-04-15 16:49发布
生成海报
- "1.0" encoding="utf-8"?>
- "http://www.adobe.com/2006/mxml" layout="absolute">
-
- import mx.controls.*;
- private var num:int;
- private function pic(direction:String):void{
- if(direction == 'next'){
- this.num++;
- if (this.num >= xmlPic.pic.length()){this.num = xmlPic.length()-1;}
- }
- if(direction == 'prev'){
- this.num--;
- if(this.num < 0){this.num = 0;}
- }
- myimg.load(xmlPic.pic[num].@path);
- }
- ]]>
- "xmlPic" source="data/pic.xml" />
- "0" width="400" height="300">
- "0" width="100%" height="100%">
- "100%" height="100%" horizontalAlign="center" verticalAlign="middle">
- "myimg" width="158" height="120" source="{xmlPic.pic[0].@path}"/>
-
- "prev" label="上一张" click="pic('prev')"/>
- "next" label="下一张" click="pic('next')"/>
-
-
-
-
xml文件
pic.xml
- xml version="1.0" encoding="utf-8"?>
- <pics>
- <pic name="图1" path="assets/small/1.jpg"/>
- <pic name="图2" path="assets/small/2.jpg"/>
- <pic name="图3" path="assets/small/3.jpg"/>
- <pic name="图4" path="assets/small/4.jpg"/>
- <pic name="图5" path="assets/small/5.jpg"/>
- <pic name="图6" path="assets/small/6.jpg"/>
- <pic name="图7" path="assets/small/7.jpg"/>
- <pic name="图8" path="assets/small/8.jpg"/>
- pics>
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮