zoukankan      html  css  js  c++  java
  • 一个相册效果

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

  • 相关阅读:
    WPF 基于 Azure 的认知服务 情绪分析 语言检测 关键短语提取
    白板类应用的模式交互设计方案
    dotnet Multi-platform App UI 多平台应用 UI 框架简介
    Windows 窗口样式 什么是 WS_EX_NOREDIRECTIONBITMAP 样式
    Windows 对全屏应用的优化
    GitHub Action 新上线 WPF .NET Core 自动构建模板
    为何 WPF 对 vcruntime140 有引用
    用 C# 写脚本 如何输出文件夹内所有文件名
    排序、去重与离散化
    二分
  • 原文地址:https://www.cnblogs.com/sinsoul/p/1871284.html
Copyright © 2011-2022 走看看