Need help with listeners!

I have a MC (icCost) whose _yscale is = to a dynamic number (icc) specified by a formula that uses input text. I set up a listener to see if the length increases or decreases but im not sure if I did it right since it doesn’t work :stuck_out_tongue:

 
import mx.transitions.Tween;
import mx.transitions.easing.*; 
var iccLstnr:Object = new Object();
 
iccLstnr.change = function (e:Object):Void{
     if(icc.length ++ || icc.length --){
          new Tween(icCost, "_yscale", Bounce.easeOut, 0, icc, 2, true);
     {
}
 
icCost.addEventListener("change", iccLstnr);

I have a feeling I need a variable that stores the previous number and compares it to the new number. I do not know how to do this though…

please if someone has any suggestions or knows an easier way or knows a thread I can look at it would be greatly appreciated! Thanks!

I doubt “if(icc.length ++ || icc.length --){” will return anything at all. What is icc, a string? number? because you are comparing .length as if it were a string yet in the tween you are entering “icc” which SHOULD be a number so you have contradicting variables going on.

Take out your if statement and just leave the tween in there or trace(icc); and let us know what that returns.

you cannot add alistener like that to any movieclip.

your item should be broadcastable.

use as broadcaster:

broadcaster = new Object();
listener = new Object();
listener.onsize = function() {
trace(“killed”);
};
AsBroadcaster.initialize(broadcaster);
broadcaster.addListener(listener);

// put this inside your function which is tweening or on **tweenInstance.onMotionChanged
broadcaster.broadcastMessage(“onsize”);

then this will fire every time the size changes.
so here : you handle the size change event

listener.onsize = function() {
// what to do with the size logic
};

go sparkdemon go!!