How about making a self contained clip:
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.filters.GlowFilter;
import mx.utils.Delegate;
class GlowClip extends MovieClip {
private var glowTween:Tween;
private var glowVal:Number = 5;
//
function GlowClip() {
var gf = new GlowFilter(0x356D83, 100, 5, 5, 5, 3, false, false);
this.filters = [gf];
this.glowTween = new Tween(this, "value", Elastic.easeOut, glowVal, glowVal,
1, true);
this.glowTween.onMotionChanged = Delegate.create(this, this.tweenChanged);
this.glowTween.stop();
}
//
function onRollOver() {
this.glowTween.continueTo(30, 2);
}
//
function onRollOut() {
this.glowTween.continueTo(5, 2);
}
//
private function tweenChanged(tw, newVal) {
var gf = new GlowFilter(0x356D83, 100, newVal, newVal, 5, 3, false, false);
this.filters = [gf];
}
}
Attach the class to a movieclip in the library and you can have as many
instances on stage as you like.
regards,
Muzak
----- Original Message -----
From: "Keith Reinfeld" <[EMAIL PROTECTED]>
To: "'Flashcoders mailing list'" <[email protected]>
Sent: Thursday, October 12, 2006 12:32 AM
Subject: RE: [Flashcoders] brain teaser: filter tweening code has a problem,can
you spot it?
> Steven,
>
> There *is* a purpose.
>
> Here is a slightly different version:
>
>
> import mx.transitions.Tween;
> import mx.transitions.easing.*;
> import flash.filters.GlowFilter;
>
> var gf:GlowFilter = new GlowFilter(0x356D83, 100, 5, 5, 5, 3, false, false);
>
> for (var i = 0; i < 5; ++i)
> {
> var mc:MovieClip = this["kText" + i];
> mc.filters = [gf];
>
> mc.gfBX = new Tween(gf, "blurX", Elastic.easeOut, 5, 5, 1, true);
> mc.gfBY = new Tween(gf, "blurY", Elastic.easeOut, 5, 5, 1, true);
>
> mc.onRollOver = function() {
> var _mc:MovieClip = this;
> this.gfBX.continueTo(30, 2);
> this.gfBX.onMotionChanged = function() {
> trace(this);// outputs [Tween]
> _mc.filters = [gf];
> };
>
> this.gfBY.continueTo(30, 2);
> this.gfBY.onMotionChanged = function() {
> trace(this);// outputs [Tween]
> _mc.filters = [gf];
> };
> };
>
> mc.onRollOut = function() {
> var _mc:MovieClip = this;
> this.gfBX.continueTo(5, 2);
> this.gfBX.onMotionChanged = function() {
> trace(this);// outputs [Tween]
> _mc.filters = [gf];
> };
>
> this.gfBY.continueTo(5, 2);
> this.gfBY.onMotionChanged = function() {
> trace(this);// outputs [Tween]
> _mc.filters = [gf];
> };
> };
> }
>
> Does that clear things up?
>
>
> -Keith
> http://home.mn.rr.com/keithreinfeld
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks
> | BLITZ
> Sent: Wednesday, October 11, 2006 4:55 PM
> To: Flashcoders mailing list
> Subject: RE: [Flashcoders] brain teaser: filter tweening code has a
> problem,can you spot it?
>
> Why are you creating a reference to this inside the onRollOver method?
>
> mc.onRollOver = function() {
> this.gfBX.continueTo(30, 2);
> };
>
> There's no purpose behind a temporary reference variable to this.
>
>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:flashcoders-
>> [EMAIL PROTECTED] On Behalf Of Keith Reinfeld
>> Sent: Wednesday, October 11, 2006 2:50 PM
>> To: 'Flashcoders mailing list'
>> Subject: RE: [Flashcoders] brain teaser: filter tweening code has a
>> problem,can you spot it?
>>
>> This works,
>>
>>
>> import mx.transitions.Tween;
>> import mx.transitions.easing.*;
>> import flash.filters.GlowFilter;
>>
>> var gf:GlowFilter = new GlowFilter(0x356D83, 100, 5, 5, 5, 3, false,
>> false);
>>
>> for (var i = 0; i < 5; ++i)
>> {
>> var mc:MovieClip = this["kText" + i];
>> mc.filters = [gf];
>>
>> mc.gfBX = new Tween(gf, "blurX", Elastic.easeOut, 5, 5, 1, true);
>> mc.gfBY = new Tween(gf, "blurY", Elastic.easeOut, 5, 5, 1, true);
>>
>> mc.onRollOver = function() {
>> var _mc:MovieClip = this;
>> _mc.gfBX.continueTo(30, 2);
>> _mc.gfBX.onMotionChanged = function() {
>> _mc.filters = [gf];
>> };
>>
>> _mc.gfBY.continueTo(30, 2);
>> _mc.gfBY.onMotionChanged = function() {
>> _mc.filters = [gf];
>> };
>> };
>>
>> mc.onRollOut = function() {
>> var _mc:MovieClip = this;
>> _mc.gfBX.continueTo(5, 2);
>> _mc.gfBX.onMotionChanged = function() {
>> _mc.filters = [gf];
>> };
>>
>> _mc.gfBY.continueTo(5, 2);
>> _mc.gfBY.onMotionChanged = function() {
>> _mc.filters = [gf];
>> };
>> };
>>
>> }
>>
>>
>> Did you have some other solution?
>>
>>
>> -Keith
>> http://home.mn.rr.com/keithreinfeld
>>
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Boon
> Chew
>> Sent: Wednesday, October 11, 2006 1:46 PM
>> To: Flashcoders mailing list
>> Subject: [Flashcoders] brain teaser: filter tweening code has a
>> problem,can
>> you spot it?
>>
>> Hi all,
>>
>> I downloaded a piece of filter tweening code, modified it (added loop
>> around
>> it) to tween mutiple clips on stage with the name (kText0, kText1,
> etc.)
>> and
>> for some reason it only tweens the last clip.
>>
>> After some debugging I found out where the problem lies. But when I
>> compiled the code in my head, everything seemed fine (probably have a
>> buggy
>> brain). Can you spot what the problem is from the code below? How
> would
>> you fix it?
>>
>> import mx.transitions.Tween;
>> import mx.transitions.easing.*;
>> import flash.filters.GlowFilter;
>>
>> for (var i = 0; i < 5; ++i)
>> {
>> var mc = this["kText" + i];
>> var gf:GlowFilter = new GlowFilter(0x356D83, 100, 5, 5, 5, 3,
> false,
>> false);
>> var gfBX:Tween = new Tween(gf, "blurX", Elastic.easeOut, 5, 5, 1,
>> true);
>> var gfBY:Tween = new Tween(gf, "blurY", Elastic.easeOut, 5, 5, 1,
>> true);
>> mc.onRollOver = function() {
>> gfBX.continueTo(30, 2);
>> gfBY.continueTo(30, 2);
>> };
>> mc.onRollOut = function() {
>> gfBX.continueTo(5, 2);
>> gfBY.continueTo(5, 2);
>> };
>>
>> gfBX.onMotionChanged = function() {
>> mc.filters = [gf];
>> };
>> }
>>
>>
>>
>> _______________________________________________
>> [email protected]
>> To change your subscription options or search the archive:
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> Brought to you by Fig Leaf Software
>> Premier Authorized Adobe Consulting and Training
>> http://www.figleaf.com
>> http://training.figleaf.com
>>
>> _______________________________________________
>> [email protected]
>> To change your subscription options or search the archive:
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> Brought to you by Fig Leaf Software
>> Premier Authorized Adobe Consulting and Training
>> http://www.figleaf.com
>> http://training.figleaf.com
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com