AS3GIF让您播放和编码使用ActionScript 3动画GIF_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > AS3GIF让您播放和编码使用ActionScript 3动画GIF

AS3GIF让您播放和编码使用ActionScript 3动画GIF

 2012/5/10 10:39:20  vini123  程序员俱乐部  我要评论(0)
  • 摘要:这里是下载地址:http://code.google.com/p/as3gif///*****************************************************//以下为包外类----------
  • 标签:使用
这里是下载地址:http://code.google.com/p/as3gif/

//*****************************************************
// 以下为包外类-----------
//*****************************************************

//==============================================================================================
// gifPlayer
// 注:gifPlayer作者是bytearray.org ,此处为引用,如需源码,请查看http://code.google.com/p/as3gif/;
//==============================================================================================

import flash.display.Loader;
import flash.display.Sprite;

import flash.events.Event;
import flash.events.IOErrorEvent;

import flash.net.URLRequest;
import flash.utils.ByteArray;

internal class GifPlayer {
private var _gifPlayerClass:Class;
private var _gifPlayerEvent:Class;
private var _byteArray:ByteArray;
private var _loader:Loader;

private const GIFPLAYERSTR ="Q1dTCVYpAAB4nNU6WXQU15Xv1va6qltSqdUtCQlBA80mBMiAwQZjEJIaJAMNEpgl7nZVt6pVDb3IXS0WrzKOszp2HCdOnDgJJrGD4zWJE2c3xtlmksnQ0gBnznxM5sOT+Zhz5uRzzpnjnnuruoXAMP+jw61679Z999393df2LvgiG2MsAGyg2ccY6xeq1ep74QAOgX344s///YW3Ircx9l6ocSVh8E9naxhnIExFpqb+h099JDKB0Owv/9V3BZiYLZTbi6XxNanTZcsslczTa8azmTWZkpm3HN/OoViMRnIffWnI5EzHXjOWdSZy5mltR7acNycGzLIpnShmxzTv67hVzKsjVrpsFsZzlt9DTpazOUfdgVu4jPiOYjFnmQVltFzKFsYDHpF1wiqUncBQfLBUKpYGaSa7T+1ANm95CNUjLVhl7eDI7hHrgUnLKc/7uPxjVro4ZpU0VGDAGyrx1DGUKnpL2s3XaH3ZAkpmmXkpW8iWtXLJLDhDhT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C69Jn6i693jh086OfcCr1BKAfctBi20nPv9xUz3f/H+k5J1ZuoWgfhfFd3s9dH9e1EZePV55DuejnrpuxoIDeQTy2uqnwcRb6LAs32W/JpJ+YbKp3j15uEIXjtrHhWq2drtUNNN37wNzc8jqFATywlAWYPhfdA+sD6DV+g/AJ/HeYd+GffRSpBgF8qnd0xUBQtSApfvQyHl+Jo8NHGQ7xy05k5Vt+qddiczn9FuF3CKfx32Ffl/tnn0LybS1q7T970f/8Qv+Fh/0vXZM6yQ=="

public function GifPlayer()
{
_byteArray = new Base64(GIFPLAYERSTR);
_loader = new Loader();
createClass();
}
public function createGif($container:Sprite, $url:String, $onComplete:Function = null, $onError:Function = null):void
{
var $_gifPlayer;
var $_fun:Function = function():void
{
$_gifPlayer = new _gifPlayerClass();
$container.addChild($_gifPlayer);
$_gifPlayer.load( new URLRequest ($url) );
$_gifPlayer.addEventListener( _gifPlayerEvent.COMPLETE, $onComplete);
$_gifPlayer.addEventListener(IOErrorEvent.IO_ERROR, $onError );
}
createClass($_fun);
}

private function createClass($onComplete:Function = null):void
{
if (_gifPlayerClass != null ) {
if ($onComplete != null) $onComplete();
return;
}
//trace("create");
var $_completeHandler:Function = function(evt:Event):void {
_gifPlayerClass = _loader.contentLoaderInfo.applicationDomain.getDefinition("org.bytearray.gif.player.GIFPlayer") as Class;
_gifPlayerEvent = _loader.contentLoaderInfo.applicationDomain.getDefinition("org.bytearray.gif.events.GIFPlayerEvent") as Class;
if ($onComplete != null) $onComplete();
}
_loader.loadBytes(_byteArray);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, $_completeHandler);
}
public function get gifPlayerClass ():Class
{
return _gifPlayerClass;
}
public function get gifPlayerEvent ():Class
{
return _gifPlayerEvent;
}
}

//============================================================================
// Base64
// 通用的base64转byteArray;
//============================================================================

internal class Base64 extends ByteArray {
private static  const BASE64:Array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,63,52,53,54,55,56,57,58,59,60,61,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,0,0,0,0,0];
public function Base64(str:String):void {
var n:int, j:int;
for (var i:int = 0; i < str.length && str.charAt(i) != "="; i++) {
j = (j << 6) | BASE64[str.charCodeAt(i)];
n += 6;
while (n >= {
writeByte((j >> (n -=) & 0xFF);
}
}
position = 0;
}
}
发表评论
用户名: 匿名