flash/flex图片幻灯片(小图列表,大图展示)

先看图片

再上源码

此效果jquery版的请看此处:http://www.cnblogs.com/liulun/archive/2010/11/07/1871145.html

jquery版的没有这个FLASH版的要好

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               backgroundColor="Black"
               creationComplete="init();">
 
    <fx:Script source="AllenAS.as">
    </fx:Script>
 
    <fx:Declarations>
        <mx:HTTPService id="picser"
                       showBusyCursor="true"
                       result="httpHandle(event)"
                       useProxy="false"
                        resultFormat="e4x"
                        method="GET"
                       >
        </mx:HTTPService>
        <s:Move id="picMove" target="{spics}">
             
        </s:Move>
    </fx:Declarations>
    <s:BorderContainer x="0" y="0"
                       width="100%" height="100%"
                       backgroundColor="#000000"
                       borderVisible="false">
        <mx:Image id="bigImg"
                  horizontalCenter="0" verticalCenter="0" />    
    </s:BorderContainer>
    <s:BorderContainer x="0" y="0"
                       width="55" height="100%"
                       backgroundAlpha="0"
                       borderVisible="false">
        <mx:Image id="btnLeft1"
                  horizontalCenter="0" verticalCenter="0"
                  source="@Embed(source='pic/l1.jpg')" 
                  mouseOver="btnLeft_mouseOverHandler(event)"
                  mouseOut="btnLeft_mouseOutHandler(event)"
                  buttonMode="true" />
        <mx:Image id="btnLeft2"  visible="false"
                  horizontalCenter="0" verticalCenter="0"
                  source="@Embed(source='pic/l2.jpg')" 
                  mouseOver="btnLeft_mouseOverHandler(event)"
                  mouseOut="btnLeft_mouseOutHandler(event)"
                  click="btnLeft1_clickHandler(event)"
                  buttonMode="true"/>
    </s:BorderContainer>
    <s:BorderContainer y="0" width="55"
                       height="100%" right="0"
                       backgroundAlpha="0"
                        borderVisible="false">
        <mx:Image id="btnRight1"
                  horizontalCenter="0" verticalCenter="0"
                  source="@Embed(source='pic/R1.jpg')"
                  mouseOver="btnRight_mouseOverHandler(event)"
                  mouseOut="btnRight_mouseOutHandler(event)"
                  buttonMode="true"/>
        <mx:Image id="btnRight2" visible="false"
                  horizontalCenter="0" verticalCenter="0"
                  source="@Embed(source='pic/R2.jpg')"
                  mouseOver="btnRight_mouseOverHandler(event)"
                  mouseOut="btnRight_mouseOutHandler(event)"
                  click="btnRight1_clickHandler(event)"
                  buttonMode="true"/>
    </s:BorderContainer>
    <s:BorderContainer id="spics" width="100%" height="86" bottom="0" backgroundAlpha="0" borderVisible="false">
        <s:HGroup id="picgroup"  horizontalCenter="0" verticalCenter="0" gap="4">
        </s:HGroup>      
    </s:BorderContainer>
 
</s:Application>
 
 
 
 
 
 
 
import flash.events.MouseEvent;
import flash.net.URLRequest;
 
import mx.controls.Alert;
import mx.controls.Image;
import mx.messaging.messages.ErrorMessage;
import mx.rpc.events.ResultEvent;
 
import org.bytearray.gif.events.FileTypeEvent;
import org.bytearray.gif.events.FrameEvent;
import org.bytearray.gif.events.GIFPlayerEvent;
import org.bytearray.gif.events.TimeoutEvent;
import org.bytearray.gif.player.GIFPlayer;
 
import spark.components.HGroup;
import spark.effects.Move;
 
private var _myGIFPlayer:GIFPlayer=new GIFPlayer();
private var pic_num:int;
private function init():void
{
    var p:String = this.url.substr(this.url.indexOf('?'));
    picser.url = "../share/share_dat.asp"+p;
    picser.send();
}
protected function btnLeft_mouseOverHandler(event:MouseEvent):void
{
    btnLeft2.visible=true;
    btnLeft1.visible=false;
}
protected function btnLeft_mouseOutHandler(event:MouseEvent):void
{
    btnLeft1.visible=true;
    btnLeft2.visible=false;
}
protected function btnRight_mouseOverHandler(event:MouseEvent):void
{
    btnRight2.visible=true;
    btnRight1.visible=false;
}          
protected function btnRight_mouseOutHandler(event:MouseEvent):void
{
    btnRight1.visible=true;
    btnRight2.visible=false;
}
protected function httpHandle(e:ResultEvent):void
{
    var pics:XML =  e.result as XML;
    var piclist:XMLList = pics.children();
    var item:XML;
    for each(item in piclist)
    {
        createOnespic(item.attribute("spic"),item.attribute("bpic"));
    }  
    pic_num = picgroup.numElements;
    var timg:Image = picgroup.getElementAt(pic_num/2) as Image;
    set_pic(timg);
}
private function set_pic(t:Image):void
{
    var temp:Image;
    var index1:int;
    for(var i:int=0;i<pic_num;i++)
    {
        temp = picgroup.getElementAt(i) as Image;      
        if(temp == t)
        {
            index1=i;
        }
        temp.alpha = 0.5;      
        temp.trustContent = true;
    }
    bigImg.load(t.name.toString());
    t.trustContent = false;
    t.alpha = 1;
    if(this.width<pic_num*80)
    {
        picMove.stop();
        picMove.xFrom = spics.x;
        picMove.xTo = this.width/2 - index1*80 - 38;
        picMove.duration=2000;
        picMove.play();
    }
 
}
private function createOnespic(surl:String,burl:String):void
{
    var pic:Image;
    pic = new Image();
    pic.source = surl;
    pic.width = 76;
    pic.height = 76;
    pic.buttonMode = true;
    pic.name = burl;
    pic.addEventListener(MouseEvent.CLICK, img_click);
    pic.trustContent = true;
    pic.alpha = 0.5;
    picgroup.addElement(pic);
}
protected function img_click(event:MouseEvent):void
{
    var t:Image = event.currentTarget as Image;
    set_pic(t);
}
protected function btnLeft1_clickHandler(event:MouseEvent):void
{
    var temp:Image;
    var i:int=0
    for(;i<pic_num;i++)
    {
        temp = picgroup.getElementAt(i) as Image;      
        if(!temp.trustContent)
        {
            break;
        }
    }
    i-=1;
    if(i<0)
    {
        i=pic_num-1;
    }
    set_pic(picgroup.getElementAt(i) as Image);
}
protected function btnRight1_clickHandler(event:MouseEvent):void
{
    var temp:Image;
    var i:int=0
    for(;i<pic_num;i++)
    {
        temp = picgroup.getElementAt(i) as Image;      
        if(!temp.trustContent)
        {
            break;
        }
    }
    i+=1;
    if(i>pic_num-1)
    {
        i=0;
    }
    set_pic(picgroup.getElementAt(i) as Image);
}
        
posted @   liulun  阅读(1561)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示