Thursday, July 20, 2006

Regular.easeOut the sound, please!

This might be the first concrete piece of code I've posted here. While finding myself writing a sound fade routine for the 100th time over again, I decided that I need to take action and finally add another class to the utils package. First I thought I'd go with the old setInterval thing and just stick it in there. But then I thought about the Tween class. And of implicit getters and setters. And if the getting/setting would work with the array access operator that Tween uses.
Well it works.
So without further due I give you the sound volume tween class:



import mx.events.*;
import mx.transitions.Tween;
import mx.transitions.easing.*;

class utils.sound.ExtendedSound extends Sound
{
public function addEventListener() {};
public function removeEventListener() {};
private function dispatchEvent() {};
private function dispatchQueue() {};

private var __sndVolume: Number;
private var sndTween: Tween;


public function get sndVolume(): Number
{
__sndVolume = getVolume();
return __sndVolume;
}

public function set sndVolume(inVol: Number): Void
{
__sndVolume = inVol;
setVolume(__sndVolume);
}

/*
* @usage: var snd = new ExtendedSound(someMovieClip); snd.fadeTo(25, 3);
*/
public function ExtendedSound(_args)
{
super(_args);
trace(toString()+'.NEW > ');
EventDispatcher.initialize(this);
}

public function toString(): String
{
return 'utils.sound.ExtendedSound';
}

public function onFadeFinished():Void
{
trace(toString()+'.onFadeFinished > ');
dispatchEvent({target: this, type:"onFadeFinished"});
}

public function fadeTo(inTargetVol: Number, inDuration: Number)
{
if(inTargetVol == sndVolume){
onFadeFinished();
return;
}
inTargetVol = (inTargetVol < intargetvol =" (inTargetVol"> 100) ? (100) : (inTargetVol);

sndTween = new Tween(this, "sndVolume", Regular.easeOut, sndVolume, inTargetVol, inDuration, true);
var _this = this;
sndTween.onMotionFinished = function(){
_this.onFadeFinished();
}
}
}

Tuesday, July 04, 2006

cow, milk thyself!

Just went trough a post on Sean Corfield's blog on the subject of Object Think. As a ColdFusion guru and Adobe Sr Computer Scientist he somehow finds all sort of interesting things to say about computer programming. Well I read the post but I won't even try to pretend that I got it all. Tough I would like to believe so. What I found interesting was the link "for everyone to understand". It's about the Midwest's hardships and how intelligent cows can ease them.
Gets me thinking about my previous post on bananas.
In truth, banana "is a" fruit.
But what will the monkey do after he/she reads about "Object Think"?
Will he/she starve waiting for the banana to peel itself?