注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

神魔破杜梓的叨叨堂

Programming every day!

 
 
 

日志

 
 
 
 

Flash放大镜效果  

2008-10-06 01:28:12|  分类: My Tech |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

原文来自flashandmath

We show how to easily create a magnifying glass effect in Flash and AS3. The applet below is easy to customize and the instructions are provided in the corresponding 'fla' file that you can download from the link under the image. We also show how to load images at runtime and easily display load progress.

Click on the image to open the live appplet in a separete window.

Flash放大镜效果 - hydra1983 - Edisons Closet

Download

  • A the 'zip' file with the 'fla' and 'jpg' files corresponding to the applet mag_glass.zip

How to customize?

  • To use your own picture, simply change the name of the picture on line 76 of mag_glass.fla in the package. Make sure your picture is in the same directory as your html page (or give an address to your file.) For good magnifying effect, the picture should be of rather high resolution while the displayed picture should be its scaled-down version. All variables will automatically adjust to the dimensions of your image.
  • To change the scale-down factor, change the value of 'shrinkFactor' variable on line 62.
  • To change the size of the rectangular magnifying glass, change the values of the variables 'glassWidth' and 'glassHeight' on lines 42 and 43.
  • To create a circular magnifying glass, set 'glassHeight' and 'glassWidth' to the same value and change line 179 to:
       glass.graphics.drawCircle(glassWidth/2,glassWidth/2,glassWidth/2);

Displaying Load progress

It is very easy. You simply attach an event listener to your instance of the Loader class that listens to the PROGRESS event and displays the result in a dynamic TextField. In our case, we have 'loader' and 'infoBox'. The code looks as follows.

startApp();

 

function startApp():void {

loader=new Loader();

...........................

...........................

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,updateInfo);

}

 

function updateInfo(e:ProgressEvent):void {

infoBox.text="Loading: "+String(Math.floor(e.bytesLoaded/1024))+

" KB of "+String(Math.floor(e.bytesTotal/1024))+" KB.";

}

 

After loading is complete, we remove 'updateInfo' listener as well as other listeners attached to 'loader'.

  评论这张
 
阅读(437)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017