一个相册效果

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);
        }
 
 
 
    }
}

posted @   sinsoul  阅读(455)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥
< 2010年11月 >
31 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 1 2 3 4
5 6 7 8 9 10 11
点击右上角即可分享
微信分享提示