Search code examples
actionscript-2flash-cs3

How to attach a number to a movie clip


This is what I am trying to achieve but I do not remember the syntax in AS2 if someone could please help.

public function highlightCan() {
    var glowId = String(this);
    var newId = glowId.substring(47);
    trace ("newId : " + newId); 
    new Tween(_parent._glow["newId"], "_alpha",    
    mx.transitions.easing.None.easeNone, _parent._glow0._alpha, 100, 2, false);
}

The newId, is what I am trying to attach to _glow.

If I hard code this value i.e. _glow0 or _glow1, this works but this value needs to be dynamic, in order to get the rollover state working. per highlightCan();

Thanks


Solution

  • public function highlightCan(id:Number) {

     var glowId = String(this);
        var newId = glowId.substring(47);
        trace ("newId : " + newId); 
        new Tween(_parent._glow["newId"], "_alpha",    
        mx.transitions.easing.None.easeNone,
    

    eval("_parent._glow"+id)._alpha, 100, 2, false); }

    when you call the highlightCan() you must send the ID number e.g.: highlightCan(2) will make transition on _parent._glow2._alpha