Pushing HydroSequence · May 6, 08:56 AM
I recently added my edits/fixes to HydroSequence.as (of HydroTween) in the google repository. I changed only a few lines of code which results in a much more powerful class. HydroSequence extends GoASAP’s SequenceCA class. You would think that this means you could use HydroSequence just like you had been able to use SequenceCA, with the additional features that HydroSequence adds. Well, this wasn’t the case, but now it is. Before, HydroSequence instantiated it’s own SequenceCA instance, now it just references itself.
The Demo
I put together a demo to showcase this new “feature”, but things didn’t turn out exactly as expected. Now I’m left wondering if these are shortcomings in my demo implementation, or in GoASAP itself.
The idea is that every time you click a button, that button’s 2-second sequence is added to the end of the currently playing sequence, like a queue. If there is no currently playing sequence, the button’s sequence becomes the current sequence. Each sequence consists of two tweens (HydroTweens).
Experiment 1
Try clicking on one of the buttons fast. The result is pretty much what you’d expect, except for one thing: the sequence stutters as long as you keep tapping the button. After you stop tapping, it proceeds as expected.
Experiment 2
Now try clicking different buttons fast. Again, similar to the first experiment.
Experiment 3
Click a button, wait a second until the sequence is in the second tween, now click a different button. Donk! Wtf?
package {import flash.display.*;import flash.events.*;import flash.filters.*;import flash.system.LoaderContext;import org.papervision3d.materials.MovieMaterial;import org.papervision3d.objects.primitives.Sphere;import org.papervision3d.view.BasicView;import org.papervision3d.view.layer.ViewportLayer;import com.adobe.webapis.flickr.*;import com.adobe.webapis.flickr.events.FlickrResultEvent;import flash.net.URLRequest;import flash.display.Loader;import thumbnail.UrlHelper;import org.goasap.PlayStates;import com.hydrotik.go.HydroSequence;import com.bumpslide.ui.GenericButton;public class Main extends MovieClip {private static const API_KEY:String = "9943f1cd0c02696b42b9c7d14c2b7794";private var view:BasicView;private var _flickrService:FlickrService;private var sphere:Sphere;private var sphereVpl:ViewportLayer;private var loader:Loader;private var seq:HydroSequence = new HydroSequence();public function Main() {addEventListener(Event.ADDED_TO_STAGE, addedToStage);}private function addedToStage(e:Event = null) : void {view = new BasicView(0,0, true);addChild(view);view.startRendering();photosSearch("", "New Orleans");}// search for flickr photos...public function photosSearch( user_id:String = "", query:String = "" ) : void {trace("photoSearch...");_flickrService = new FlickrService( API_KEY );_flickrService.addEventListener( FlickrResultEvent.PHOTOS_SEARCH, onResult_photosSearch );_flickrService.photos.search(user_id, "", "any", query, null, null, null, null,-1,"interestingness-desc" );}private function onResult_photosSearch(event:FlickrResultEvent):void {_flickrService.removeEventListener( FlickrResultEvent.PHOTOS_SEARCH, onResult_photosSearch );var url:String = UrlHelper.getFlickrUrl( (event.data.photos as PagedPhotoList).photos[int(Math.random()*10)] as Photo );trace("loading " + url);loader = new Loader();var loaderContext:LoaderContext = new LoaderContext();loaderContext.checkPolicyFile = true;loader.load(new URLRequest(url), loaderContext);loader.contentLoaderInfo.addEventListener(Event.INIT, loaderComplete);}private function loaderComplete(e:Event = null):void {loader.contentLoaderInfo.removeEventListener(Event.INIT, loaderComplete);// add loaded photo to sprite (sp)var sp:Sprite = new Sprite();sp.addChild(loader);loader = loader;loader.alpha = 1;// create a sphere with sp for materialsphere = new Sphere(new MovieMaterial(sp, true, true),200,16,12);sphereVpl = view.viewport.getChildLayer(sphere);sphereVpl.filters = [ new GlowFilter(0xffffff,1,26,26,0,3), new BlurFilter(0,0,3) ];view.scene.addChild(sphere);// create interfaceaddChild(new GenericButton(150, 20, 10, 10, "glow sequence", doGlow));addChild(new GenericButton(150, 20, 10, 30, "blur sequence", doBlur));addChild(new GenericButton(150, 20, 10, 50, "spin sequence", doSpin));addChild(new GenericButton(150, 20, 10, 70, "alpha sequence", doAlpha));addChild(new GenericButton(150, 20, 10, 100, "NEXT STEP", doSkipStep));}private function seqAddStep(s:HydroSequence):void {if (seq.currentStep && seq.currentStep.state == PlayStates.PLAYING) {trace(" ..addStep");seq.addStep( s );} else {seq = s;}seq.start();}private function doGlow(e:Event=null):void {seqAddStep(new HydroSequence({ target: sphereVpl, Glow_strength: 20, duration: 1 } ,{ target: sphereVpl, Glow_strength: 0, duration: 1 }));}private function doBlur(e:Event=null):void {seqAddStep(new HydroSequence({ target: sphereVpl, Blur_blurX: 20, Blur_blurY: 20, duration: 1 } ,{ target: sphereVpl, Blur_blurX: 0, Blur_blurY: 0, duration: 1 }));}private function doSpin(e:Event=null):void {seqAddStep(new HydroSequence({ target: sphere, rotationY: 360, duration: 1 } ,{ target: sphere, rotationY: 0, duration: 1 }));}private function doAlpha(e:Event=null):void {seqAddStep(new HydroSequence({ target: loader, alpha: 0.3, duration: 1 } ,{ target: loader, alpha: 1, duration: 1 }));}private function doSkipStep(e:Event = null):void {if (seq.playIndex < seq.length) {trace("Skipping... current index:"+seq.playIndex );seq.skipTo(seq.playIndex + 1);}}}}
Full Source Code (added 05.10.09)
From now on most of my experiments will be available here:
The repository is setup so that Flex 3 SDK is the only additional thing you might need to download in order to compile any demo.
— Pickle
Comment
Introducing Digizex: Open Source CMS for Flash and Flex [AS3] Digizex Video Tutorial: Installation and Basic Features

