0
I Use This!
Inactive

Commits : Listings

Analyzed about 7 hours ago. based on code collected about 7 hours ago.
Nov 22, 2018 — Nov 22, 2019
Commit Message Contributor Files Modified Lines Added Lines Removed Code Location Date
new compiled swc
unknown
More... over 9 years ago
updated pure as3 example
unknown
More... over 9 years ago
Bug fixed.. and custom fade class changed # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch fixloader # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: PureAs3.swf # modified: pureas3/FadeImage.as # modified: pureas3/Main.as # modified: ../source/dynimage/AbstractAsset.as # modified: ../source/dynimage/Image.as # modified: ../source/dynimage/ImageLoader.as # diff --git a/examples/PureAs3.swf b/examples/PureAs3.swf index e682697..7d47749 100644 Binary files a/examples/PureAs3.swf and b/examples/PureAs3.swf differ diff --git a/examples/pureas3/FadeImage.as b/examples/pureas3/FadeImage.as index b89ff7a..5f1b8d4 100644 --- a/examples/pureas3/FadeImage.as +++ b/examples/pureas3/FadeImage.as @@ -3,7 +3,11 @@ package import dynimage.Image; import com.greensock.TweenLite; + import com.greensock.easing.Back; + import com.greensock.easing.Strong; import com.greensock.plugins.AutoAlphaPlugin; + import com.greensock.plugins.BlurFilterPlugin; + import com.greensock.plugins.ColorMatrixFilterPlugin; import com.greensock.plugins.TweenPlugin; import flash.display.DisplayObject; @@ -15,24 +19,26 @@ package { public function FadeImage(url : String, modifier : Function = null, modifierParams : Object = null, preloader : DisplayObject = null, autoStart : Boolean = true) { + TweenPlugin.activate([ColorMatrixFilterPlugin, AutoAlphaPlugin, BlurFilterPlugin]); super(url, modifier, modifierParams, preloader, autoStart); - TweenPlugin.activate([AutoAlphaPlugin]); } override protected function animatePreloaderIn(preloader : DisplayObject, onComplete : Function) : void { - TweenLite.to(preloader, 0.3, {autoAlpha: 1, onComplete: onComplete}); + TweenLite.to(preloader, 0, {y: preloader.y - 50, autoAlpha:1, blurFilter:{blurY:50, quality:3}}); + TweenLite.to(preloader, 0.5, {y: preloader.y + 50, blurFilter:{blurY:0, quality:3}, ease: Back.easeOut, onComplete: onComplete}); } override protected function animatePreloaderOut(preloader : DisplayObject, onComplete : Function) : void { - TweenLite.to(preloader, 0.3, {autoAlpha: 0, onComplete: onComplete}); + TweenLite.to(preloader, 0.3, {y: preloader.y + 50, delay: 0.5, autoAlpha: 0, ease: Back.easeIn, blurFilter:{blurY:50, quality:3}, onComplete: onComplete}); } override protected function animateAssetIn(asset : DisplayObject, onComplete : Function) : void { - TweenLite.to(asset, 0.3, {autoAlpha:1, onComplete: onComplete}); + TweenLite.to(asset, 0, {autoAlpha:1, colorMatrixFilter:{amount:3, contrast:3, brightness:3}, blurFilter:{blurX:50, blurY:50, quality:3}}); + TweenLite.to(asset, 1.5, {autoAlpha:1, colorMatrixFilter:{amount:1, contrast:1, brightness:1}, blurFilter:{blurX:0, blurY:0, quality:3}, onComplete: onComplete, ease:Strong.easeOut}); } } diff --git a/examples/pureas3/Main.as b/examples/pureas3/Main.as index ea137df..6dc0602 100644 --- a/examples/pureas3/Main.as +++ b/examples/pureas3/Main.as @@ -1,7 +1,8 @@ package { import dynimage.Image; - import dynimage.ImageAlign; + import flash.display.StageAlign; + import flash.display.StageScaleMode; import dynimage.ImageEvent; import dynimage.ImageModifiers; @@ -14,29 +15,30 @@ package { public function Main() { + stage.scaleMode = StageScaleMode.NO_SCALE; + stage.align = StageAlign.TOP_LEFT; - var img : Image = new FadeImage("mario.jpg", ImageModifiers.fill, {width: 500, height: 300, align: ImageAlign.CENTER}, new PreloaderAnimation()); - img.addEventListener(ImageEvent.COMPLETE, imgEvents); - img.addEventListener(ImageEvent.PROGRESS, imgEvents); - img.addEventListener(ImageEvent.ERROR, imgEvents); - img.addEventListener(ImageEvent.STARTED, imgEvents); - addChild(img); - - var img2 : Image = new FadeImage("mario.jpg", ImageModifiers.fill, {width: 500, height: 300, align: ImageAlign.CENTER}, new PreloaderAnimation()); - img2.y = 100; - img2.addEventListener(ImageEvent.COMPLETE, imgEvents); - img2.addEventListener(ImageEvent.PROGRESS, imgEvents); - img2.addEventListener(ImageEvent.ERROR, imgEvents); - img2.addEventListener(ImageEvent.STARTED, imgEvents); - addChild(img2); - + Image.LOADER_COUNT = 1; + var image : FadeImage; + var leni : uint = 2; + for (var i:uint = 0; i < leni*leni; ++i) + { + image = new FadeImage("mario.jpg", ImageModifiers.fill, {width: stage.stageWidth/leni, height:stage.stageHeight/leni}, new PreloaderAnimation()); + image.x = int(i % leni) * stage.stageWidth/leni; + image.y = int(i / leni) * stage.stageHeight/leni; + image.addEventListener(ImageEvent.STARTED, imageEvents); + image.addEventListener(ImageEvent.PROGRESS, imageEvents); + image.addEventListener(ImageEvent.ERROR, imageEvents); + image.addEventListener(ImageEvent.COMPLETE, imageEvents); + addChild(image); + } + } - - private function imgEvents(event : ImageEvent) : void + private function imageEvents(event : ImageEvent) : void { - trace(event); + trace( event ); } } } diff --git a/source/dynimage/AbstractAsset.as b/source/dynimage/AbstractAsset.as index 2a74dfc..622b7d0 100644 --- a/source/dynimage/AbstractAsset.as +++ b/source/dynimage/AbstractAsset.as @@ -1,5 +1,4 @@ -/* * DynImage for ActionScript 3.0 * Copyright © 2010 Inlet.nl * All rights reserved. * * http://github.com/inlet/dynimage * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * - Neither the name of the Log Meister nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * * DynImage is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DynImage is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with DynImage. If not, see <http://www.gnu.org/licenses/>. * * Version 1.0 * */ package dynimage { import flash.display.DisplayObject; import flash.display.Sprite; import flash.events.Event; internal class AbstractAsset extends Sprite { protected var _preloader : DisplayObject; protected var _asset : DisplayObject; private var _autoStart : Boolean; private var _url : String; /** * Abstract asset. * * @param url:String path to image * @param preloader:DisplayObject show a preloader while image is loading? * @param autoStart:Boolean (optional) directly start with loading? */ public function AbstractAsset(url : String, preloaderAsset : DisplayObject, autoStart : Boolean = true) { _url = url; _preloader = preloaderAsset; _autoStart = autoStart; placePreloader(); addEventListener(Event.REMOVED_FROM_STAGE, dispose); if (autoStart) { load(); } } /** * Load. Animate the preloader in. * Send onComplete function when preloader animation is finished. */ public function load() : void { animatePreloaderIn(_preloader, animatePreloaderInCompleted); } protected function placePreloader() : void { _preloader.visible = false; _preloader.alpha = 0; addChild(_preloader); } /** * Adds the image to loading queue. */ private function loadAsset() : void { ImageQueue.addEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.START, handleAssetLoaderEvents); ImageQueue.loadImage(_url, this.name); } /** * Handle queue events for this image. * @param event:ImageLoaderEvent */ private function handleAssetLoaderEvents(event : ImageLoaderEvent) : void { if (event.name != this.name) return; var evt:ImageEvent; switch (event.type) { case ImageLoaderEvent.START: evt = new ImageEvent(ImageEvent.STARTED); break; case ImageLoaderEvent.PROGRESS: evt = new ImageEvent(ImageEvent.PROGRESS); evt.bytesLoaded = event.loadedBytesCount; evt.bytesTotal = event.totalBytesCount; break; case ImageLoaderEvent.ERROR: evt = new ImageEvent(ImageEvent.ERROR); evt.errorMessage = event.error; break; } if (evt) dispatchEvent(evt); if (event.type == ImageLoaderEvent.COMPLETE) { assetLoaded(event.asset); } } /** * Image is completely loaded. * Add it on stage and send complete event. * * @param asset:DisplayObject */ private function assetLoaded(asset : DisplayObject) : void { _asset = getModifiedAsset(asset); _asset.visible = false; _asset.alpha = 0; addChild(_asset); animatePreloaderOut(_preloader, animatePreloaderOutCompleted); dispatchEvent(new ImageEvent(ImageEvent.COMPLETE)); } /** * Override this one to apply a specified modifier. * * @param asset:DisplayObject * @return DisplayObject */ protected function getModifiedAsset(asset : DisplayObject) : DisplayObject { return asset; } /** * Make sure the listener is weak to prevent orphans. * * @param type:String * @param listener:Function * @param useCapture:Boolean * @param priority:Boolean * @param useWeakReference:Boolean */ override public function addEventListener(type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = true) : void { super.addEventListener(type, listener, useCapture, priority, useWeakReference ); } /** * Dispose this asset. * Remove necessary listeners and remove it from loader queue. * * @param event:Event */ private function dispose(event:Event) : void { removeEventListener(Event.REMOVED_FROM_STAGE, dispose); ImageQueue.removeEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.imageLoader.removeAsset(this.name); } /** * ------------------------------------------------------ * ------------ ANIMATIONS TO OVERRIDE -------------- * ------------------------------------------------------ */ protected function animatePreloaderIn(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = true; preloader.alpha = 1; onComplete(); } private function animatePreloaderInCompleted() : void { if (_autoStart) loadAsset( ); } - protected function animatePreloaderOut(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = false; preloader.alpha = 0; onComplete(); } private function animatePreloaderOutCompleted() : void { animateAssetIn( _asset, function() : void {} ); +/* * DynImage for ActionScript 3.0 * Copyright © 2010 Inlet.nl * All rights reserved. * * http://github.com/inlet/dynimage * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * - Neither the name of the Log Meister nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * * DynImage is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DynImage is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with DynImage. If not, see <http://www.gnu.org/licenses/>. * * Version 1.0 * */ package dynimage { import flash.display.DisplayObject; import flash.display.Sprite; import flash.events.Event; internal class AbstractAsset extends Sprite { /** * Loading state */ public var loadingStatus : String; public var url : String; protected var _preloader : DisplayObject; protected var _asset : DisplayObject; private var _autoStart : Boolean; /** * Abstract asset. * * @param url:String path to image * @param preloader:DisplayObject show a preloader while image is loading? * @param autoStart:Boolean (optional) directly start with loading? */ public function AbstractAsset(url : String, preloaderAsset : DisplayObject, autoStart : Boolean = true) { this.url = url; _preloader = preloaderAsset; _autoStart = autoStart; if (_preloader) placePreloader(); addEventListener(Event.REMOVED_FROM_STAGE, dispose); if (autoStart) { load(); } } /** * Load. Animate the preloader in. * Send onComplete function when preloader animation is finished. */ public function load() : void { (_preloader) ? animatePreloaderIn(_preloader, animatePreloaderInCompleted) : animatePreloaderInCompleted(); } protected function placePreloader() : void { _preloader.visible = false; _preloader.alpha = 0; addChild(_preloader); } /** * Adds the image to loading queue. */ private function loadAsset() : void { if (loadingStatus) return; ImageQueue.addEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.START, handleAssetLoaderEvents); ImageQueue.loadImage(url, this.name); } /** * Handle queue events for this image. * @param event:ImageLoaderEvent */ private function handleAssetLoaderEvents(event : ImageLoaderEvent) : void { if (event.name != this.name) return; var evt : ImageEvent; switch (event.type) { case ImageLoaderEvent.START: evt = new ImageEvent(ImageEvent.STARTED); break; case ImageLoaderEvent.PROGRESS: evt = new ImageEvent(ImageEvent.PROGRESS); evt.bytesLoaded = event.loadedBytesCount; evt.bytesTotal = event.totalBytesCount; break; case ImageLoaderEvent.ERROR: evt = new ImageEvent(ImageEvent.ERROR); evt.errorMessage = event.error; break; } loadingStatus = event.type; if (evt) dispatchEvent(evt); if (event.type == ImageLoaderEvent.COMPLETE) { assetLoaded(event.asset); } } /** * Image is completely loaded. * Add it on stage and send complete event. * * @param asset:DisplayObject */ private function assetLoaded(asset : DisplayObject) : void { _asset = getModifiedAsset(asset); _asset.visible = false; _asset.alpha = 0; addChild(_asset); (_preloader) ? animatePreloaderOut(_preloader, animatePreloaderOutCompleted) : animatePreloaderOutCompleted(); dispatchEvent(new ImageEvent(ImageEvent.COMPLETE)); } /** * Override this one to apply a specified modifier. * * @param asset:DisplayObject * @return DisplayObject */ protected function getModifiedAsset(asset : DisplayObject) : DisplayObject { return asset; } /** * Make sure the listener is weak to prevent orphans. * * @param type:String * @param listener:Function * @param useCapture:Boolean * @param priority:Boolean * @param useWeakReference:Boolean */ override public function addEventListener(type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = true) : void { super.addEventListener(type, listener, useCapture, priority, useWeakReference); } /** * Dispose this asset. * Remove necessary listeners and remove it from loader queue. * * @param event:Event */ private function dispose(event : Event) : void { removeEventListener(Event.REMOVED_FROM_STAGE, dispose); ImageQueue.removeEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.imageLoader.removeAsset(this.name); } /** * ------------------------------------------------------ * ------------ ANIMATIONS TO OVERRIDE -------------- * ------------------------------------------------------ */ protected function animatePreloaderIn(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = true; preloader.alpha = 1; onComplete(); } private function animatePreloaderInCompleted() : void { if (_autoStart) loadAsset(); } + protected function animatePreloaderOut(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = false; preloader.alpha = 0; onComplete(); } private function animatePreloaderOutCompleted() : void { animateAssetIn(_asset, function() : void { }); } - protected function animateAssetIn(asset : DisplayObject, onComplete : Function) : void { asset.visible = true; asset.alpha = 1; onComplete(); } - } } \ No newline at end of file + protected function animateAssetIn(asset : DisplayObject, onComplete : Function) : void { asset.visible = true; asset.alpha = 1; onComplete(); } } } \ No newline at end of file diff --git a/source/dynimage/Image.as b/source/dynimage/Image.as index 9a71eb2..33b5067 100644 --- a/source/dynimage/Image.as +++ b/source/dynimage/Image.as @@ -41,7 +41,6 @@ package dynimage import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; - import flash.display.Sprite; [Event(name="ImageEvent.STARTED", type="dynimage.ImageEvent")] [Event(name="ImageEvent.PROGRESS", type="dynimage.ImageEvent")] @@ -50,12 +49,7 @@ package dynimage public class Image extends AbstractAsset { - /** - * Throttle setting. - * The amount of loaders to use. - */ - public static var LOADER_COUNT : int = 3; - + private var _modifier : Function; private var _modifierParams : Object; @@ -73,12 +67,6 @@ package dynimage { _modifier = modifier; _modifierParams = modifierParams; - - if (modifierParams == null) modifierParams = new Object( ); - if (modifierParams.width == null) modifierParams.width = 0; - if (modifierParams.height == null) modifierParams.height = 0; - - if (!preloader) preloader = new Sprite( ); super( url, preloader, autoStart ); } @@ -91,13 +79,11 @@ package dynimage { super.placePreloader( ); - if (_modifierParams != null) + if (_modifierParams) { - if (_modifierParams.width == 0 || _modifierParams.height == 0) return; - if (_modifierParams.originalWidth == 0 || _modifierParams.originalHeight == 0) return; - - _preloader.x = _modifierParams.width / 2; - _preloader.y = _modifierParams.height / 2; + if (!_modifierParams.hasOwnProperty("width") || !_modifierParams.hasOwnProperty("height")) return; + _preloader.x = _modifierParams['width'] / 2; + _preloader.y = _modifierParams['height'] / 2; } } @@ -109,7 +95,7 @@ package dynimage */ override protected function getModifiedAsset(asset : DisplayObject) : DisplayObject { - if (_modifier != null && _modifierParams != null) return _modifier( asset, _modifierParams ); + if (_modifier is Function && _modifierParams is Object) return _modifier( asset, _modifierParams ); return getCopyAsBitmap( asset ); } @@ -121,7 +107,10 @@ package dynimage override public function get width() : Number { if (_modifierParams) - if (_modifierParams.width > 0) return _modifierParams.width; + { + if (_modifierParams.hasOwnProperty("width")) + return _modifierParams['width']; + } return super.width; } @@ -134,7 +123,10 @@ package dynimage override public function get height() : Number { if (_modifierParams) - if (_modifierParams.height > 0) return _modifierParams.height; + { + if (_modifierParams.hasOwnProperty("height")) + return _modifierParams['height']; + } return super.height; } @@ -170,5 +162,19 @@ package dynimage return bmp; } + + /** + * Throttle setting. + * The amount of loaders to use. + */ + public static function set LOADER_COUNT(inLoaderCount : uint) : void + { + ImageLoader.loaderCount = inLoaderCount; + } + + public static function get LOADER_COUNT() : uint + { + return ImageLoader.loaderCount; + } } } diff --git a/source/dynimage/ImageLoader.as b/source/dynimage/ImageLoader.as index bf6d4da..27e2f01 100644 --- a/source/dynimage/ImageLoader.as +++ b/source/dynimage/ImageLoader.as @@ -55,20 +55,13 @@ package dynimage */ internal class ImageLoader extends EventDispatcher { - + private var _waitingStack : Array = new Array( ); private var _loadingStack : Array = new Array( ); - private var _loaderCount : uint; + internal static var loaderCount : uint = 3; - /** - * Set the loader count to Image.LOADER_COUNT. - * - * @param inLoaderCount:Number. - * @see Image.LOADER_COUNT - */ - public function ImageLoader(inLoaderCount : Number = Number.NaN) + public function ImageLoader() { - _loaderCount = isNaN( inLoaderCount ) ? Image.LOADER_COUNT : inLoaderCount; } /** @@ -134,9 +127,7 @@ package dynimage for each (var fd : ImageData in _waitingStack) { if (fd.name == inName) - { _waitingStack.splice( _waitingStack.indexOf( fd ), 1 ); - } } } @@ -174,10 +165,13 @@ package dynimage private function loadNext() : void { - if (_loadingStack.length == _loaderCount) return; - if (_waitingStack.length == 0 && _loadingStack.length == 0) + if (_loadingStack.length == loaderCount) return; + if (_waitingStack.length == 0) { - dispatchEvent( new ImageLoaderEvent( ImageLoaderEvent.ALL_LOADED ) ); + if (_loadingStack.length == 0) + { + dispatchEvent( new ImageLoaderEvent( ImageLoaderEvent.ALL_LOADED ) ); + } return; } @@ -280,10 +274,10 @@ package dynimage return null; } - + override public function toString() : String { - return getQualifiedClassName( this ) + " :: loaderCount[" + _loaderCount + "] loadingStack[" + _loadingStack .length + "] waitingStack[" + _waitingStack.length + "]"; + return getQualifiedClassName( this ) + " :: loaderCount[" + loaderCount + "] loadingStack[" + _loadingStack .length + "] waitingStack[" + _waitingStack.length + "]"; } } } @@ -308,4 +302,9 @@ internal class ImageData url = inURL; name = inName; } + + public function toString() : String + { + return "[ImageData : " + name + "]"; + } } \ No newline at end of file
unknown
More... over 9 years ago
initial setup for fixing imageloader
unknown
More... over 9 years ago
Added comments in source
unknown
More... over 9 years ago
tweenlite.swc added to example
unknown
More... over 9 years ago
README updated with event listeners
unknown
More... over 9 years ago
License added.. event bindings added # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: bin/dynimage.swc # modified: source/dynimage/AbstractAsset.as # modified: source/dynimage/Image.as # modified: source/dynimage/ImageAlign.as # modified: source/dynimage/ImageEvent.as # modified: source/dynimage/ImageLoader.as # modified: source/dynimage/ImageLoaderEvent.as # modified: source/dynimage/ImageModifiers.as # modified: source/dynimage/ImageQueue.as # diff --git a/bin/dynimage.swc b/bin/dynimage.swc index 0c2686c..e9d64e4 100644 Binary files a/bin/dynimage.swc and b/bin/dynimage.swc differ diff --git a/source/dynimage/AbstractAsset.as b/source/dynimage/AbstractAsset.as index 1896437..d38747f 100644 --- a/source/dynimage/AbstractAsset.as +++ b/source/dynimage/AbstractAsset.as @@ -1,4 +1,4 @@ -package dynimage { import flash.display.DisplayObject; import flash.display.Sprite; import flash.events.Event; internal class AbstractAsset extends Sprite { protected var _preloader : DisplayObject; protected var _asset : DisplayObject; private var _autoStart : Boolean; private var _url : String; public function AbstractAsset(url : String, preloaderAsset : DisplayObject, autoStart : Boolean = true) { _url = url; _preloader = preloaderAsset; _autoStart = autoStart; placePreloader(); addEventListener(Event.REMOVED_FROM_STAGE, dispose); if (autoStart) { load(); } } public function load() : void { animatePreloaderIn(_preloader, animatePreloaderInCompleted); } protected function placePreloader() : void { _preloader.visible = false; _preloader.alpha = 0; addChild(_preloader); } private function loadAsset() : void { ImageQueue.addEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.START, handleAssetLoaderEvents); ImageQueue.loadImage(_url, this.name); } private function handleAssetLoaderEvents(event : ImageLoaderEvent) : void { if (event.name != this.name) return; var evt:ImageEvent; switch (event.type) { case ImageLoaderEvent.START: evt = new ImageEvent(ImageEvent.STARTED); break; case ImageLoaderEvent.PROGRESS: evt = new ImageEvent(ImageEvent.PROGRESS); evt.bytesLoaded = event.loadedBytesCount; evt.bytesTotal = event.totalBytesCount; break; case ImageLoaderEvent.ERROR: evt = new ImageEvent(ImageEvent.ERROR); evt.errorMessage = event.error; break; } if (evt) dispatchEvent(evt); if (event.type == ImageLoaderEvent.COMPLETE) { assetLoaded(event.asset); } } private function assetLoaded(asset : DisplayObject) : void { _asset = getModifiedAsset(asset); _asset.visible = false; _asset.alpha = 0; addChild(_asset); animatePreloaderOut(_preloader, animatePreloaderOutCompleted); dispatchEvent(new ImageEvent(ImageEvent.COMPLETE)); } protected function getModifiedAsset(asset : DisplayObject) : DisplayObject { return asset; } override public function addEventListener(type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = true) : void { super.addEventListener(type, listener, useCapture, priority, useWeakReference ); } private function dispose(event:Event) : void { removeEventListener(Event.REMOVED_FROM_STAGE, dispose); ImageQueue.removeEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.imageLoader.removeAsset(this.name); } /** * ------------------------------------------------------ * ------------ ANIMATIONS TO OVERRIDE -------------- * ------------------------------------------------------ */ protected function animatePreloaderIn(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = true; preloader.alpha = 1; onComplete(); } private function animatePreloaderInCompleted() : void { if (_autoStart) loadAsset( ); } +/* * DynImage for ActionScript 3.0 * Copyright © 2010 Inlet.nl * All rights reserved. * * http://github.com/inlet/dynimage * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * - Neither the name of the Log Meister nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * * DynImage is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DynImage is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with DynImage. If not, see <http://www.gnu.org/licenses/>. * * Version 1.0 * */ package dynimage { import flash.display.DisplayObject; import flash.display.Sprite; import flash.events.Event; internal class AbstractAsset extends Sprite { protected var _preloader : DisplayObject; protected var _asset : DisplayObject; private var _autoStart : Boolean; private var _url : String; public function AbstractAsset(url : String, preloaderAsset : DisplayObject, autoStart : Boolean = true) { _url = url; _preloader = preloaderAsset; _autoStart = autoStart; placePreloader(); addEventListener(Event.REMOVED_FROM_STAGE, dispose); if (autoStart) { load(); } } public function load() : void { animatePreloaderIn(_preloader, animatePreloaderInCompleted); } protected function placePreloader() : void { _preloader.visible = false; _preloader.alpha = 0; addChild(_preloader); } private function loadAsset() : void { ImageQueue.addEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.addEventListener(ImageLoaderEvent.START, handleAssetLoaderEvents); ImageQueue.loadImage(_url, this.name); } private function handleAssetLoaderEvents(event : ImageLoaderEvent) : void { if (event.name != this.name) return; var evt:ImageEvent; switch (event.type) { case ImageLoaderEvent.START: evt = new ImageEvent(ImageEvent.STARTED); break; case ImageLoaderEvent.PROGRESS: evt = new ImageEvent(ImageEvent.PROGRESS); evt.bytesLoaded = event.loadedBytesCount; evt.bytesTotal = event.totalBytesCount; break; case ImageLoaderEvent.ERROR: evt = new ImageEvent(ImageEvent.ERROR); evt.errorMessage = event.error; break; } if (evt) dispatchEvent(evt); if (event.type == ImageLoaderEvent.COMPLETE) { assetLoaded(event.asset); } } private function assetLoaded(asset : DisplayObject) : void { _asset = getModifiedAsset(asset); _asset.visible = false; _asset.alpha = 0; addChild(_asset); animatePreloaderOut(_preloader, animatePreloaderOutCompleted); dispatchEvent(new ImageEvent(ImageEvent.COMPLETE)); } protected function getModifiedAsset(asset : DisplayObject) : DisplayObject { return asset; } override public function addEventListener(type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = true) : void { super.addEventListener(type, listener, useCapture, priority, useWeakReference ); } private function dispose(event:Event) : void { removeEventListener(Event.REMOVED_FROM_STAGE, dispose); ImageQueue.removeEventListener(ImageLoaderEvent.COMPLETE, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.PROGRESS, handleAssetLoaderEvents); ImageQueue.removeEventListener(ImageLoaderEvent.ERROR, handleAssetLoaderEvents); ImageQueue.imageLoader.removeAsset(this.name); } /** * ------------------------------------------------------ * ------------ ANIMATIONS TO OVERRIDE -------------- * ------------------------------------------------------ */ protected function animatePreloaderIn(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = true; preloader.alpha = 1; onComplete(); } private function animatePreloaderInCompleted() : void { if (_autoStart) loadAsset( ); } protected function animatePreloaderOut(preloader : DisplayObject, onComplete : Function) : void { preloader.visible = false; preloader.alpha = 0; onComplete(); } private function animatePreloaderOutCompleted() : void { animateAssetIn( _asset, function() : void {} ); } protected function animateAssetIn(asset : DisplayObject, onComplete : Function) : void { asset.visible = true; asset.alpha = 1; onComplete(); } diff --git a/source/dynimage/Image.as b/source/dynimage/Image.as index f5d5b1b..1c3a79a 100644 --- a/source/dynimage/Image.as +++ b/source/dynimage/Image.as @@ -1,3 +1,41 @@ +/* + * DynImage for ActionScript 3.0 + * Copyright © 2010 Inlet.nl + * All rights reserved. + * + * http://github.com/inlet/dynimage + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Log Meister nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * DynImage is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DynImage is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DynImage. If not, see <http://www.gnu.org/licenses/>. + * + * Version 1.0 + * + */ package dynimage { import flash.display.Bitmap; @@ -5,6 +43,11 @@ package dynimage import flash.display.DisplayObject; import flash.display.Sprite; + [Event(name="ImageEvent.STARTED", type="dynimage.ImageEvent")] + [Event(name="ImageEvent.PROGRESS", type="dynimage.ImageEvent")] + [Event(name="ImageEvent.ERROR", type="dynimage.ImageEvent")] + [Event(name="ImageEvent.COMPLETE", type="dynimage.ImageEvent")] + public class Image extends AbstractAsset { public static var LOADER_COUNT : int = 3; diff --git a/source/dynimage/ImageAlign.as b/source/dynimage/ImageAlign.as index af55779..528f6c6 100644 --- a/source/dynimage/ImageAlign.as +++ b/source/dynimage/ImageAlign.as @@ -1,3 +1,41 @@ +/* + * DynImage for ActionScript 3.0 + * Copyright © 2010 Inlet.nl + * All rights reserved. + * + * http://github.com/inlet/dynimage + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Log Meister nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * DynImage is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DynImage is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DynImage. If not, see <http://www.gnu.org/licenses/>. + * + * Version 1.0 + * + */ package dynimage { diff --git a/source/dynimage/ImageEvent.as b/source/dynimage/ImageEvent.as index b6227ca..1168d4d 100644 --- a/source/dynimage/ImageEvent.as +++ b/source/dynimage/ImageEvent.as @@ -1 +1 @@ -package dynimage { import flash.events.Event; public class ImageEvent extends Event { public static const STARTED : String = "AssetEvent.STARTED"; public static const PROGRESS : String = "AssetEvent.PROGRESS"; public static const ERROR : String = "AssetEvent.ERROR"; public static const COMPLETE : String = "AssetEvent.COMPLETE"; public var bytesLoaded : Number; public var bytesTotal : Number; public var errorMessage : String; public function ImageEvent(inType : String, inBytesLoaded : uint = 0, inBytesTotal : uint = 0) { super( inType, true ); bytesLoaded = inBytesLoaded; bytesTotal = inBytesTotal; } override public function clone() : Event { return new ImageEvent( type, bytesLoaded, bytesTotal ); } override public function toString() : String { return "SimpleImageEvent: type[" + type + "] bytesLoaded[" + bytesLoaded + "] bytesTotal[" + bytesTotal + "] errorMessage[" + errorMessage + "]"; } } } \ No newline at end of file +/* * DynImage for ActionScript 3.0 * Copyright © 2010 Inlet.nl * All rights reserved. * * http://github.com/inlet/dynimage * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * - Neither the name of the Log Meister nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * * DynImage is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DynImage is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with DynImage. If not, see <http://www.gnu.org/licenses/>. * * Version 1.0 * */ package dynimage { import flash.events.Event; public class ImageEvent extends Event { public static const STARTED : String = "ImageEvent.STARTED"; public static const PROGRESS : String = "ImageEvent.PROGRESS"; public static const ERROR : String = "ImageEvent.ERROR"; public static const COMPLETE : String = "ImageEvent.COMPLETE"; public var bytesLoaded : Number; public var bytesTotal : Number; public var errorMessage : String; public function ImageEvent(inType : String, inBytesLoaded : uint = 0, inBytesTotal : uint = 0) { super(inType, true); bytesLoaded = inBytesLoaded; bytesTotal = inBytesTotal; } override public function clone() : Event { return new ImageEvent(type, bytesLoaded, bytesTotal); } override public function toString() : String { return "ImageEvent: type[" + type + "] bytesLoaded[" + bytesLoaded + "] bytesTotal[" + bytesTotal + "] errorMessage[" + errorMessage + "]"; } } } \ No newline at end of file diff --git a/source/dynimage/ImageLoader.as b/source/dynimage/ImageLoader.as index 73547e4..e8ced25 100644 --- a/source/dynimage/ImageLoader.as +++ b/source/dynimage/ImageLoader.as @@ -1,3 +1,41 @@ +/* + * DynImage for ActionScript 3.0 + * Copyright © 2010 Inlet.nl + * All rights reserved. + * + * http://github.com/inlet/dynimage + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Log Meister nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * DynImage is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DynImage is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DynImage. If not, see <http://www.gnu.org/licenses/>. + * + * Version 1.0 + * + */ package dynimage { import flash.display.Loader; diff --git a/source/dynimage/ImageLoaderEvent.as b/source/dynimage/ImageLoaderEvent.as index 5af249f..e9b69c0 100644 --- a/source/dynimage/ImageLoaderEvent.as +++ b/source/dynimage/ImageLoaderEvent.as @@ -1,4 +1,42 @@ -package dynimage +/* + * DynImage for ActionScript 3.0 + * Copyright © 2010 Inlet.nl + * All rights reserved. + * + * http://github.com/inlet/dynimage + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Log Meister nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * DynImage is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DynImage is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DynImage. If not, see <http://www.gnu.org/licenses/>. + * + * Version 1.0 + * + */ +package dynimage { import flash.display.DisplayObject; import flash.display.Loader; diff --git a/source/dynimage/ImageModifiers.as b/source/dynimage/ImageModifiers.as index 100cff9..1a20067 100644 --- a/source/dynimage/ImageModifiers.as +++ b/source/dynimage/ImageModifiers.as @@ -1,3 +1,41 @@ +/* + * DynImage for ActionScript 3.0 + * Copyright © 2010 Inlet.nl + * All rights reserved. + * + * http://github.com/inlet/dynimage + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Log Meister nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * DynImage is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DynImage is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DynImage. If not, see <http://www.gnu.org/licenses/>. + * + * Version 1.0 + * + */ package dynimage { import flash.display.Bitmap; diff --git a/source/dynimage/ImageQueue.as b/source/dynimage/ImageQueue.as index 57553ff..5102241 100644 --- a/source/dynimage/ImageQueue.as +++ b/source/dynimage/ImageQueue.as @@ -1,3 +1,41 @@ +/* + * DynImage for ActionScript 3.0 + * Copyright © 2010 Inlet.nl + * All rights reserved. + * + * http://github.com/inlet/dynimage + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Log Meister nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * DynImage is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DynImage is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DynImage. If not, see <http://www.gnu.org/licenses/>. + * + * Version 1.0 + * + */ package dynimage { import flash.events.EventDispatcher;
unknown
More... over 9 years ago
New binairy (dynimage.swc) and README updated
unknown
More... over 9 years ago
README updated
unknown
More... over 9 years ago
README updated
unknown
More... over 9 years ago
README update
unknown
More... over 9 years ago
removed whitespace
unknown
More... over 9 years ago
Merge branch 'master' of github.com:inlet/dynimage
unknown
More... over 9 years ago
deleted the original README
unknown
More... over 9 years ago
README update
unknown
More... over 9 years ago
Merge branch 'master' of github.com:inlet/dynimage
unknown
More... over 9 years ago
Readme update
unknown
More... over 9 years ago
Readme update
unknown
More... over 9 years ago
Readme update
unknown
More... over 9 years ago
Cs4 example created
unknown
More... over 9 years ago
builder.xml > build to dynimage.swc
unknown
More... over 9 years ago
The following happened:
unknown
More... over 9 years ago
pure as3 fdt setup
unknown
More... over 9 years ago
externals deleted
unknown
More... over 9 years ago
First initial project setup
unknown
More... over 9 years ago