away3d / away3d-core-fp11

Away3D engine for Flash Player 11
http://www.away3d.com
Other
639 stars 274 forks source link

GifMaterial added #662

Open peteshand opened 10 years ago

peteshand commented 10 years ago

Gif Texture, Material and Method can be used to load and display animated gifs within an away3d material Dependencies: My fork of "Flash-Animated-GIF-Library" https://github.com/peteshand/Flash-Animated-GIF-Library

mkfui commented 8 years ago

var stream:URLStream = new URLStream(); gifLinkToByteArray(“diego.gif”);

function gifLinkToByteArray(url:String){ stream.addEventListener( Event.COMPLETE, completeHandler ); stream.load(new URLRequest(url)); } function completeHandler( e:Event ):void { var bytes:ByteArray = new ByteArray(); stream.readBytes( bytes ); gPlayer = new GIFPlayer(true); gPlayer.addEventListener(GIFPlayerEvent.COMPLETE, OnDecodeComplete); gPlayer.loadBytes(bytes); }

var tex:GifTexture = new GifTexture(gPlayer); var gifMaterial:GifMaterial = new GifMaterial(tex);

var geo:PlaneGeometry = new PlaneGeometry(100, 100, 1, 1, false); var mesh:Mesh = new Mesh(geo, gifMaterial); _view.scene.addChild(mesh);

private function OnDecodeComplete(ev:GIFPlayerEvent):void {

gPlayer.resize(0.25, 0.25); }

sir, not work, TypeError: Error #1009: Cannot access a property or method of a null object reference.

by this way,

gPlayer = new GIFPlayer(true); gPlayer.addEventListener(GIFPlayerEvent.COMPLETE, OnDecodeComplete); gPlayer.loadBytes(new mygif());

got this [Fault] exception, information=ArgumentError: Error #2015: Invalid BitmapData.

can anyone demonstrate it for me ? i need it urgently

peteshand commented 8 years ago

Hey @mkfui you can download a sample app from https://github.com/peteshand/awy3dGifExample