flex gifloader
来源:互联网 发布:老汉卖羊c语言 编辑:程序博客网 时间:2024/05/15 23:47
最近项目需要运用到FLEX,但GOOGLE一下发现可用的资料实在太少了。
找了好久发现google code上在这个还不错,还有很多东西可以好好研究研究
http://code.google.com/p/as3gif/
下面的例子是将动态GIF绑定到SPRITE上
package com.render
{
import flash.display.Sprite;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import mx.core.Application;
import org.bytearray.gif.player.GIFPlayer;
public class SpriteWithBitmap extends Sprite
{
//Pass the source path or url here.
private static const defaultUrl:String = "/consoleweb/console/images/treewait.gif";
public function SpriteWithBitmap(url:String = defaultUrl)
{
loadImg(url);
}
private function loadImg(url:String):void
{
var gifPlayer:GIFPlayer = new GIFPlayer();
var request:URLRequest = new URLRequest(url);
gifPlayer.load(request);
gifPlayer.addEventListener(IOErrorEvent.IO_ERROR,loadFailure);
this.addChild(gifPlayer);
//设置图片居中显示
gifPlayer.x = Application.application.checkTree.width * 0.5 - 32;
gifPlayer.y = Application.application.checkTree.height * 0.5 -32;
}
private function loadFailure(event:IOErrorEvent):void
{
}
}
}
但要动态取到GIF的宽度还是没有头绪,在网上看到过这个
Hi, Thibault Imbert. The width/height property return 0, event after COMPLETE event dispatch. The GIFPlayerEvent has the ‘rect’, but it’s useless.
I’ve edited your GIFPlayer class (you should have done that).
All u needed 2 do is just to create a public var
public var rect:Rectangle;
And after in the readStream method to do so:
rect = aFrames[0].bitmapData.rect;
dispatchEvent (new GIFPlayerEvent( GIFPlayerEvent.COMPLETE , aFrames[0].bitmapData.rect));
U’d probably ask why did i do that. The answer is simple – 2 make thingz more useful.
Ex:
import org.gif.player.GIFPlayer;
import org.gif.events.GIFPlayerEvent;
var myGIFPlayer:GIFPlayer = new GIFPlayer();
myGIFPlayer.addEventListener(GIFPlayerEvent.COMPLETE, onCompleteGIFLoad);
myGIFPlayer.load(new URLRequest(“diego.gif”));
addChild(myGIFPlayer);
function onCompleteGIFLoad(event:GIFPlayerEvent):void
{
updatePos();
}
function updatePos():void
{
trace(“Now we can retrive the width/height in order to place/replace the player”, myGIFPlayer.rect);
}
在上述方法中设置this.x this.y就可以改变gif的位置了
- flex gifloader
- FLEX
- flex
- flex
- FLEX
- Flex
- Flex
- flex
- Flex
- Flex
- Flex
- Flex
- Flex
- Flex
- Flex
- flex
- Flex
- flex
- 在javascript中 读取 struts2 s:datetimepicker中的值
- Optimizing Program Performance-- 使用GPROF来查看系统的性能
- 建立嵌入式gdb调试环境
- CMedia更新至v1.4.3
- Asp.net生成Excel文件并下载(更新:解决使用迅雷下载页面而不是文件的问题)
- flex gifloader
- 偶记
- 【转】C#实现大文件分块发送到客户端
- 认识几个朋友
- C#对话框全接触
- 论php比asp好的独特优势
- I386中bootloader与kernel之间的信息交换
- 刷新父窗口和回事提交
- Office2010 分享之七:Outlook实现域帐号的导出