Permalink
Browse files

skeleton

  • Loading branch information...
1 parent 50f6889 commit 82cda913d91308451e4ad13428b2b9988e5a3500 @honzabrecka committed Oct 30, 2014
View
@@ -0,0 +1,20 @@
+# Project build and release directories
+target/
+bin/
+bin-debug/
+bin-release/
+asdoc-output/
+html-template/
+
+# Eclipse/Flex/Flash Builder project files
+.settings/
+.classpath
+.metadata/
+
+# Mac OS
+*.DS_Store
+
+test/libs/
+
+# ant
+build/
View
@@ -0,0 +1,22 @@
+language: objective-c
+before_script:
+ - brew update
+ - brew install ant
+# flash player debugger
+ - brew install caskroom/cask/brew-cask
+ - brew cask install flash-player-debugger
+# apache flex sdk
+ - wget -O flex_sdk.zip http://mirrors.gigenet.com/apache/flex/4.13.0/binaries/apache-flex-sdk-4.13.0-bin.zip
+ - unzip -q flex_sdk.zip -d flex_sdk
+ - wget -O playerglobal.swc http://download.macromedia.com/get/flashplayer/updaters/14/playerglobal14_0.swc
+ - mkdir -p flex_sdk/frameworks/libs/player/11.1
+ - cp playerglobal.swc flex_sdk/frameworks/libs/player/11.1
+ - echo env.PLAYERGLOBAL_HOME=libs/player > flex_sdk/env.properties
+# apache flex unit
+ - wget -O flexunit.zip http://mirrors.gigenet.com/apache/flex/flexunit/4.2.0/binaries/apache-flex-flexunit-4.2.0-4.12.0-bin.zip
+ - unzip -q flexunit.zip
+ - mkdir -p test/libs
+ - cp flexunit/flexunit-*-as3_*.swc test/libs
+ - cp flexunit/flexunit-cilistener-*.swc test/libs
+script:
+ - ant -DFLEX_HOME "flex_sdk" -DFLEXUNIT "flexunit" -DFLASHPLAYER "$HOME/Applications/Flash Player Debugger.app/Contents/MacOS/Flash Player Debugger"
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<actionScriptProperties mainApplicationPath="async-gif-decoder.as" projectUUID="7e84958c-17f2-4d42-9976-d9c42e0df00e" version="6">
+ <compiler additionalCompilerArguments="-locale en_US" autoRSLOrdering="true" copyDependentFiles="false" fteInMXComponents="false" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false" useDebugRSLSwfs="true" verifyDigests="true" warn="true">
+ <compilerSourcePath/>
+ <libraryPath defaultLinkType="0">
+ <libraryPathEntry kind="4" path="">
+ <excludedEntries>
+ <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flex.swc" useDefaultLinkType="false"/>
+ </excludedEntries>
+ </libraryPathEntry>
+ </libraryPath>
+ <sourceAttachmentPath/>
+ </compiler>
+ <applications>
+ <application path="async-gif-decoder.as"/>
+ </applications>
+ <modules/>
+ <buildCSSFiles/>
+</actionScriptProperties>
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<flexLibProperties includeAllClasses="true" version="3">
+ <includeClasses>
+ <classEntry path="com.jx.gif.GIF"/>
+ <classEntry path="com.jx.gif.Decoder"/>
+ <classEntry path="com.jx.gif.GIFFrame"/>
+ <classEntry path="com.jx.gif.FunctionSequenceError"/>
+ </includeClasses>
+ <includeResources/>
+ <namespaceManifests/>
+</flexLibProperties>
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>async-gif-decoder</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.adobe.flexbuilder.project.flexbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.adobe.flexbuilder.project.flexlibnature</nature>
+ <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,48 @@
+// -----------------------------------------------------------------------
+// async-gif-decoder
+// Copyright 2014 Jan Břečka. All Rights Reserved.
+//
+// This program is free software. You can redistribute and/or modify it
+// in accordance with the terms of the accompanying license agreement.
+// -----------------------------------------------------------------------
+
+package com.jx.gif
+{
+ import flash.events.EventDispatcher;
+ import flash.geom.Rectangle;
+ import flash.utils.ByteArray;
+
+ public class Decoder extends EventDispatcher
+ {
+
+ private var stream:ByteArray;
+
+ public function Decoder() { }
+
+ public function decode(stream:ByteArray):void
+ {
+ this.stream = stream;
+ }
+
+ public function dispose():void
+ {
+
+ }
+
+ public function get frames():Vector.<GIFFrame>
+ {
+ return null;
+ }
+
+ public function get loopCount():uint
+ {
+ return 0;
+ }
+
+ public function get size():Rectangle
+ {
+ return null;
+ }
+
+ }
+}
@@ -0,0 +1,20 @@
+// -----------------------------------------------------------------------
+// async-gif-decoder
+// Copyright 2014 Jan Břečka. All Rights Reserved.
+//
+// This program is free software. You can redistribute and/or modify it
+// in accordance with the terms of the accompanying license agreement.
+// -----------------------------------------------------------------------
+
+package com.jx.gif
+{
+ public class FunctionSequenceError extends Error
+ {
+
+ public function FunctionSequenceError()
+ {
+ super("Call load() method first.");
+ }
+
+ }
+}
@@ -0,0 +1,196 @@
+// -----------------------------------------------------------------------
+// async-gif-decoder
+// Copyright 2014 Jan Břečka. All Rights Reserved.
+//
+// This program is free software. You can redistribute and/or modify it
+// in accordance with the terms of the accompanying license agreement.
+// -----------------------------------------------------------------------
+
+package com.jx.gif
+{
+ import flash.display.MovieClip;
+ import flash.display.Scene;
+ import flash.errors.IllegalOperationError;
+ import flash.events.ErrorEvent;
+ import flash.events.Event;
+ import flash.events.IOErrorEvent;
+ import flash.events.SecurityErrorEvent;
+ import flash.net.URLLoader;
+ import flash.net.URLLoaderDataFormat;
+ import flash.net.URLRequest;
+ import flash.utils.ByteArray;
+
+ public class GIF extends MovieClip
+ {
+
+ private var _frames:Vector.<GIFFrame>;
+ private var _currentFrame:int = -1;
+ private var _isPlaying:Boolean;
+
+ public function GIF() { }
+
+ public function load(request:URLRequest):void
+ {
+ function complete(event:Event):void
+ {
+ dispatchEvent(event);
+ decode(loader.data);
+ destroy();
+ }
+
+ function error(event:Event):void
+ {
+ dispatchEvent(event);
+ destroy();
+ }
+
+ function destroy():void
+ {
+ try { loader.close(); } catch (error:Error) { }
+ loader.removeEventListener(Event.COMPLETE, complete);
+ loader.removeEventListener(IOErrorEvent.IO_ERROR, error);
+ loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
+ loader = null;
+ }
+
+ var loader:URLLoader = new URLLoader();
+ loader.dataFormat = URLLoaderDataFormat.BINARY;
+ loader.addEventListener(Event.COMPLETE, complete);
+ loader.addEventListener(IOErrorEvent.IO_ERROR, error);
+ loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
+ loader.load(request);
+ }
+
+ public function unload():void
+ {
+ resetFrames();
+ _currentFrame = -1;
+ }
+
+ override public function get currentFrame():int
+ {
+ hasBeenLoaded();
+ return _currentFrame;
+ }
+
+ override public function get currentFrameLabel():String
+ {
+ hasBeenLoaded();
+ return _currentFrame.toString();
+ }
+
+ override public function get currentScene():Scene
+ {
+ hasBeenLoaded();
+ return null;
+ }
+
+ override public function get framesLoaded():int
+ {
+ hasBeenLoaded();
+ return _frames.length;
+ }
+
+ override public function get totalFrames():int
+ {
+ hasBeenLoaded();
+ return _frames.length;
+ }
+
+ override public function get isPlaying():Boolean
+ {
+ hasBeenLoaded();
+ return _isPlaying;
+ }
+
+ override public function gotoAndPlay(frame:Object, scene:String=null):void
+ {
+ hasBeenLoaded();
+ }
+
+ override public function gotoAndStop(frame:Object, scene:String=null):void
+ {
+ hasBeenLoaded();
+ }
+
+ override public function nextFrame():void
+ {
+ hasBeenLoaded();
+ }
+
+ override public function prevFrame():void
+ {
+ hasBeenLoaded();
+ }
+
+ override public function play():void
+ {
+ hasBeenLoaded();
+ _isPlaying = true;
+ }
+
+ override public function stop():void
+ {
+ hasBeenLoaded();
+ _isPlaying = false;
+ }
+
+ override public function nextScene():void
+ {
+ throw new IllegalOperationError("Method is not implemented.");
+ }
+
+ override public function prevScene():void
+ {
+ throw new IllegalOperationError("Method is not implemented.");
+ }
+
+ private function hasBeenLoaded():void
+ {
+ if (_currentFrame == -1) {
+ throw new FunctionSequenceError();
+ }
+ }
+
+ private function decode(stream:ByteArray):void
+ {
+ function complete(event:Event):void
+ {
+ _frames = decoder.frames;
+ _currentFrame = 0;
+ _isPlaying = false;
+ dispatchEvent(event);
+ destroy();
+ }
+
+ function error(event:Event):void
+ {
+ dispatchEvent(event);
+ destroy();
+ }
+
+ function destroy():void
+ {
+ decoder.removeEventListener(Event.COMPLETE, complete);
+ decoder.removeEventListener(ErrorEvent.ERROR, error);
+ decoder.dispose();
+ decoder = null;
+ }
+
+ var decoder:Decoder = new Decoder();
+ decoder.addEventListener(Event.COMPLETE, complete);
+ decoder.addEventListener(ErrorEvent.ERROR, error);
+ decoder.decode(stream);
+ }
+
+ private function resetFrames():void
+ {
+ while (_frames && _frames.length > 0) {
+ _frames.pop();
+ }
+
+ _frames = null;
+ }
+
+ }
+}
@@ -0,0 +1,19 @@
+// -----------------------------------------------------------------------
+// async-gif-decoder
+// Copyright 2014 Jan Břečka. All Rights Reserved.
+//
+// This program is free software. You can redistribute and/or modify it
+// in accordance with the terms of the accompanying license agreement.
+// -----------------------------------------------------------------------
+
+package com.jx.gif
+{
+ public class GIFFrame
+ {
+
+ public function GIFFrame()
+ {
+ }
+
+ }
+}
Oops, something went wrong.

0 comments on commit 82cda91

Please sign in to comment.