flex gifloader
最近项目需要运用到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].bitma
相关文档:
提前声明,本文是个人原创,而且仅代表个人意见还看法,希望大家给予指正。
学习应用Flex应该也有1年了,曾经让我废寝忘食的技术,不敢说现在全部掌握了,但基本原理我已经明白了。这个时候透过了Flex那神秘的外表,透过了一层层的大雾,让我看的越来越清晰了。越来越能想明白 ......
几日前被老总推荐文章一篇,来自7yue兄的blog,作者是Sean Moore ,
原文地址:http://www.insideria.com/2009/04/51-actionscript-30-and-flex-op.html
与其在程序写完了之后臃肿得跑不动,不如平时注意这些关键点,时时提醒自己。翻译出来,以便以后时时查阅。
1 创建新数组时避免使用它的构造函数。
......
Adobe在开发Flex最有利的工具就是Flex Builder,然而,工欲善其事,必先利其"键",快速键对一般开发者来说都非常有用,非但如此,很多快速键与组合键是会与其他软体或系统都有雷同之处,举个例子来说,Ctrl + C就是复制,Ctrl + V就是贴上,看看许多作业系统与编辑软体是不是都一样呢?若你有注意到就会不难发现,其实Flex ......
废话不说,直接代码部分代码摘抄自网上,在此想原作者表示感谢
1、服务端 uploadFile.ashx
<%@ WebHandler Language="VB" Class="UploadFile" %>
Imports System
Imports System.Web
Imports System.Web.HttpServerUtility
Imports System.IO
Imports System.Web.HttpRequest
Public Class UploadFile : Impl ......