Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3252455
  • 博文数量: 530
  • 博客积分: 13360
  • 博客等级: 上将
  • 技术积分: 5473
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-13 13:32
文章分类

全部博文(530)

文章存档

2017年(1)

2015年(2)

2013年(24)

2012年(20)

2011年(97)

2010年(240)

2009年(117)

2008年(12)

2007年(8)

2006年(9)

分类:

2009-09-07 17:51:11

  1. "1.0" encoding="utf-8"?>  
  2. ""  
  3.     creationComplete="init();"  
  4.     verticalScrollPolicy="off"  
  5.     verticalGap="100"  
  6.     horizontalScrollPolicy="off"  
  7.     verticalAlign="bottom"  
  8.     width="600"  
  9.     height="200"  
  10.     layout="horizontal">  
  11.           
  12.             
  13.                 import mx.controls.Image;  
  14.                 import mx.controls.Alert;  
  15.                   
  16.                 public var imageArray:Array;  
  17.                 public var timer:Timer;  
  18.                   
  19.                 public static const ORGINSIZE:int = 60;  
  20.                 public static const CROSSSIZE:int = 80;  
  21.                 public static const TWICENUM:Number = 2.5;  
  22.                 public static const OFFSETY:int = 0;  
  23.                 public static const OFFSETX:int = 0;  
  24.                   
  25.                 private function init():void{  
  26.                     imageArray = new Array();  
  27.                     imageArray.push(getImageObj(image1));  
  28.                     imageArray.push(getImageObj(image2));  
  29.                     imageArray.push(getImageObj(image3));  
  30.                     imageArray.push(getImageObj(image4));  
  31.                     imageArray.push(getImageObj(image5));  
  32.                     imageArray.push(getImageObj(image6));  
  33.                     imageArray.push(getImageObj(image7));  
  34.                       
  35.                     timer = new Timer(500);  
  36.                     timer.addEventListener(TimerEvent.TIMER, modifyImage);  
  37.                     timer.start();  
  38.                 }  
  39.                   
  40.                 private function getImageObj(img:Image):Object{  
  41.                     var obj:Object = new Object();  
  42.                     var imageX:Number = img.x + img.width/2;  
  43.                     var imageY:Number = this.height;  
  44.                     obj.image = img;  
  45.                     obj.orgX = imageX;  
  46.                     obj.orgY = imageY;  
  47.                     return obj;  
  48.                 }  
  49.                   
  50.                 private function modifyImage(event:TimerEvent):void{  
  51.                     for(var i:String in imageArray){  
  52.                         var _image:Image = imageArray[i].image;  
  53.                           
  54.                         var _mouseY:Number = stage.mouseY - OFFSETY;  
  55.                         var _mouseX:Number = stage.mouseX - OFFSETX;  
  56.                           
  57.                         if(_mouseY < imageArray[i].orgY && (imageArray[i].orgY - _mouseY) < _image.height * TWICENUM){  
  58.                             var percentX:Number = 0;  
  59.                             var percentY:Number = 0;  
  60.                             var percentXY:Number = 0;  
  61.                             if(_mouseX < imageArray[i].orgX && (imageArray[i].orgX - _mouseX) < _image.width * TWICENUM){  
  62.                                 percentX = 1 - (imageArray[i].orgX - _mouseX)/(_image.width * TWICENUM)  
  63.                                   
  64.                             }else if(_mouseX >= imageArray[i].orgX && (_mouseX - imageArray[i].orgX) < _image.width * TWICENUM){  
  65.                                 percentX = 1 - (_mouseX - imageArray[i].orgX)/(_image.width * TWICENUM)  
  66.                             }  
  67.                             percentY = 1 - (imageArray[i].orgY - ORGINSIZE/2 - _mouseY)/(_image.height * TWICENUM - ORGINSIZE/2)  
  68.                             if(percentY > 1)percentY = 1;  
  69.                             percentXY = percentX * percentY;  
  70.                             imageArray[i].image.width = CROSSSIZE * percentXY + ORGINSIZE;  
  71.                             imageArray[i].image.height = CROSSSIZE * percentXY + ORGINSIZE;  
  72.                         }  
  73.                     }  
  74.                 }  
  75.             ]]>  
  76.           
  77.         "image1" toolTip="Image1" source="@Embed(source='assets/icons/1.png')"   
  78.                             width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image1')"/>  
  79.         "image2" toolTip="Image2" source="@Embed(source='assets/icons/2.png')"  
  80.                         width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image2')"/>  
  81.         "image3" toolTip="Image3" source="@Embed(source='assets/icons/3.png')"  
  82.                         width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image3')"/>  
  83.         "image4" toolTip="Image4" source="@Embed(source='assets/icons/4.png')"  
  84.                         width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image4')"/>  
  85.         "image5" toolTip="Image5" source="@Embed(source='assets/icons/5.png')"  
  86.                         width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image5')"/>  
  87.         "image6" toolTip="Image6" source="@Embed(source='assets/icons/6.png')"  
  88.                         width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image6')"/>  
  89.         "image7" toolTip="Image7" source="@Embed(source='assets/icons/7.png')"  
  90.                         width="{ORGINSIZE}" height="{ORGINSIZE}" click="Alert.show('Click image7')"/>  
  91.  
阅读(9161) | 评论(1) | 转发(0) |
0

上一篇:乐乎社区

下一篇:FLEX3的元标签

给主人留下些什么吧!~~

chinaunix网友2010-05-24 18:22:12

这什么意思。。就给一堆代码。。