一个相册效果
package { import flash.display.MovieClip; import flash.display.Loader; import flash.display.Shape; import flash.events.MouseEvent; import flash.events.Event; import flash.net.URLRequest; import fl.events.ListEvent; import fl.data.DataProvider; import fl.controls.ScrollBarDirection; import fl.controls.listClasses.ImageCell; /* *author :SinSoul *blogs: http://www.cnblogs.com/sinsoul */ public class Main extends MovieClip { var xml:XML; var loader:Loader; var dp:DataProvider; var shape:Shape; var shape1:Shape; public function Main(): void { init(); } private function init(): void { xml= <root> <image smallImg= "images/1.png" bigImg= "images/1.jpg" /> <image smallImg= "images/2.png" bigImg= "images/2.jpg" /> <image smallImg= "images/3.png" bigImg= "images/3.jpg" /> <image smallImg= "images/4.png" bigImg= "images/4.jpg" /> <image smallImg= "images/5.png" bigImg= "images/5.jpg" /> <image smallImg= "images/6.png" bigImg= "images/6.jpg" /> <image smallImg= "images/7.png" bigImg= "images/7.jpg" /> <image smallImg= "images/8.png" bigImg= "images/8.jpg" /> <image smallImg= "images/9.png" bigImg= "images/9.jpg" /> <image smallImg= "images/10.png" bigImg= "images/10.jpg" /> <image smallImg= "images/11.png" bigImg= "images/11.jpg" /> <image smallImg= "images/12.png" bigImg= "images/12.jpg" /> <image smallImg= "images/13.png" bigImg= "images/13.jpg" /> <image smallImg= "images/14.png" bigImg= "images/14.jpg" /> <image smallImg= "images/15.png" bigImg= "images/15.jpg" /> <image smallImg= "images/16.png" bigImg= "images/16.jpg" /> <image smallImg= "images/17.png" bigImg= "images/17.jpg" /> <image smallImg= "images/18.png" bigImg= "images/18.jpg" /> <image smallImg= "images/19.png" bigImg= "images/19.jpg" /> <image smallImg= "images/20.png" bigImg= "images/20.jpg" /> <image smallImg= "images/21.png" bigImg= "images/21.jpg" /> </root>; dp= new DataProvider(xml); Tlist.dataProvider=dp; Tlist.labelField= 'bigImg' ; Tlist.sourceField= "smallImg" ; Tlist.width= 100 ; Tlist.height= 350 ; Tlist.rowHeight= 80 ; Tlist.columnWidth= 80 ; Tlist.direction=ScrollBarDirection.VERTICAL; shape= new Shape(); shape.graphics.lineStyle( 3 , 0x454545 , 1 ); shape.graphics.beginFill( 0xffffff ); shape.graphics.drawRect( 270 , 100 , 200 , 200 ); shape.graphics.endFill(); addChild(shape); shape1= new Shape(); shape1.graphics.lineStyle( 3 , 0x454545 , 0.7 ); shape1.graphics.beginFill( 0xffffff ); shape1.graphics.drawRect( 280 , 110 , 180 , 180 ); shape1.graphics.endFill(); addChild(shape1); Tlist.addEventListener(MouseEvent.CLICK,onclick); Tlist.addEventListener(ListEvent.ITEM_CLICK,onclick2); } private function drawRect(mc:MovieClip): void { mc.graphics.beginFill(Math.random()* 0xffffff ); mc.graphics.drawRect( 0 , 0 , 400 , 400 ); mc.graphics.endFill(); } private function onclick(e) { trace (ImageCell(e.target). label ); } private function onclick2(e) { loader= new Loader(); loader.load( new URLRequest(Tlist.itemToLabel(e.item))); loader.contentLoaderInfo.addEventListener(Event.COMPLETE,com); } private function com(e:Event) { var a: Number =loader.width; var b: Number =loader.height; if (loader.width>loader.height) { loader.width= 200 ; loader.height= 200 /a*loader.height; loader.addEventListener(Event.ENTER_FRAME,ok); function ok(e:Event) { e.target.x+=((( 200 -loader.width)/ 2 + 270 )-loader.x)/ 12 ; e.target.y+=((( 200 -loader.height)/ 2 + 100 )-loader.y)/ 12 ; e.target.alpha-=( 1 - 0.2 )/ 200 ; if (e.target.x>=(( 200 -loader.width)/ 2 + 270 - 0.05 )&&e.target.y>=(( 200 -loader.height)/ 2 + 100 - 0.05 )) { e.target.removeEventListener(Event.ENTER_FRAME,ok); e.target.alpha= 0 ; } } } else if (loader.height>loader.width) { loader.height= 200 ; loader.width= 200 /b*loader.width; loader.addEventListener(Event.ENTER_FRAME,ok2); function ok2(e:Event) { e.target.x+=((( 200 -loader.width)/ 2 + 270 )-loader.x)/ 12 ; e.target.y+=((( 200 -loader.height)/ 2 + 100 )-loader.y)/ 12 ; e.target.alpha-=( 1 - 0.2 )/ 200 ; if (e.target.x>=(( 200 -loader.width)/ 2 + 270 - 0.05 )&&e.target.y>=(( 200 -loader.height)/ 2 + 100 - 0.05 )) { e.target.removeEventListener(Event.ENTER_FRAME,ok2); e.target.alpha= 0 ; } } } addChild(loader); } } } |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥