# Need help with listeners!

**URL:** <https://forum.kirupa.com/t/need-help-with-listeners/261163>\
**Category:** Uncategorized\
**Created:** [May 23, 2008, 5:45pm UTC](https://forum.kirupa.com/t/need-help-with-listeners/261163 "2008-05-23T17:45:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akalah](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@akalah](https://forum.kirupa.com/u/akalah)\
**Post date:** [May 23, 2008, 5:45pm UTC](https://forum.kirupa.com/t/need-help-with-listeners/261163/1 "2008-05-23T17:45:26Z")

</div>

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 😛

```auto
 
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!

---

<div class="post-metadata">

**Author:** ![sstalder](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@sstalder](https://forum.kirupa.com/u/sstalder)\
**Post date:** [May 24, 2008, 11:54pm UTC](https://forum.kirupa.com/t/need-help-with-listeners/261163/2 "2008-05-24T23:54:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [May 25, 2008, 7:12pm UTC](https://forum.kirupa.com/t/need-help-with-listeners/261163/3 "2008-05-25T19:12:33Z")

</div>

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 \*\*tween_Instance_.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  
};

---

<div class="post-metadata">

**Author:** ![JBPresents](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@JBPresents](https://forum.kirupa.com/u/JBPresents)\
**Post date:** [May 25, 2008, 7:17pm UTC](https://forum.kirupa.com/t/need-help-with-listeners/261163/4 "2008-05-25T19:17:15Z")

</div>

go sparkdemon go!!
