Timer incrementation not happening
what wrong here? results consistent alpha value not increment or decrement. missing something, or should cake?
-= -0.1
does same as:
+= 0.1
1 - (-0.1) == 1 + (0.1)
so if sprite or whatever starts @ alpha 1 stay @
alpha 1.
hth,
manno
miquael wrote:
> wrong here? results consistent alpha value
> not increment or decrement. missing something, or should cake?
>
>
>
>
> public function fade(fademode:string):void {
>
> var fadetimer:timer = new timer(5, 10);
>
> if (fademode == "out") {
> fadetimer.addeventlistener(timerevent.timer, fadeout);
> }
> if (fademode == "in") {
> fadetimer.addeventlistener(timerevent.timer, fadein);
> }
> fadetimer.start();
> }
> private function fadeout (e:timerevent):void {
> trace (this.alpha);
> this.alpha -= -0.1;
> }
> private function fadein (e:timerevent):void {
> trace (this.alpha);
> this.alpha += 0.1;
> }
>
> // results constant "1" each iteration, no change. why "-="
> or "+=" not appear work?
>
does same as:
+= 0.1
1 - (-0.1) == 1 + (0.1)
so if sprite or whatever starts @ alpha 1 stay @
alpha 1.
hth,
manno
miquael wrote:
> wrong here? results consistent alpha value
> not increment or decrement. missing something, or should cake?
>
>
>
>
> public function fade(fademode:string):void {
>
> var fadetimer:timer = new timer(5, 10);
>
> if (fademode == "out") {
> fadetimer.addeventlistener(timerevent.timer, fadeout);
> }
> if (fademode == "in") {
> fadetimer.addeventlistener(timerevent.timer, fadein);
> }
> fadetimer.start();
> }
> private function fadeout (e:timerevent):void {
> trace (this.alpha);
> this.alpha -= -0.1;
> }
> private function fadein (e:timerevent):void {
> trace (this.alpha);
> this.alpha += 0.1;
> }
>
> // results constant "1" each iteration, no change. why "-="
> or "+=" not appear work?
>
More discussions in ActionScript 3
adobe
Comments
Post a Comment