Search code examples
actionscript-3flash-cc

How can I remove class completely?


I have a class file that has some netstreams and connections and I'm trying to remove the class completely. Here's my code:

function onTestProcessed(e:CustomEvent2):void {
    // Remove
    rtmp_test.removeEventListener(CustomEvent2.PASS_PARAMS, onTestProcessed);
    e.currentTarget.parent.removeChild(e.currentTarget);

    // Validation comparison
    if (e.boo == false) {
        trace("event.boo = ", e.boo);
    } else {
        trace("event.boo = ", e.boo);
    }
}

This code removes the display of video but not its sound. Do I have to find each variable in the class and remove them one by one?


Solution

  • Seems like this solved the problem:

    function onTestProcessed(e:CustomEvent2):void {
        // Remove
        rtmp_test.removeEventListener(CustomEvent2.PASS_PARAMS, onTestProcessed);
        rtmp_test.netStreamObj.close();
        // rtmp_test.netStreamObj = null;
        rtmp_test.vid.clear();
        e.currentTarget.parent.removeChild(e.currentTarget);
    
        // Validation comparison
        if (e.boo == false) {
            trace("event.boo = ", e.boo);
        } else {
            trace("event.boo = ", e.boo);
        }
    }
    

    as3 - How to stop video and detach NetStream