0

Maybe in performance.
I'm constantly using MovieClip(getChildByName("x")).stop();
Is it better than (getChildByName("x") as MovieClip).stop(); ?

1 Answers1

-2

results: (ui.getChildAt(0) as SpectrumAnalyzer) = 174 ms SpectrumAnalyzer(ui.getChildAt(0)) = 200 ms

For the programmer it's the same - but i don't know if the code is doing the same thing in two different ways. Anyways the difference is 26 ms for 1 mio iterations.

var sa:SpectrumAnalyzer = new SpectrumAnalyzer()
    var ui:UIComponent = new UIComponent()
    ui.addChild(sa)
    addElement(ui)

    var start:Number = new Date().getTime()

    for(var i:int=0; i<1000000; i++){
        (ui.getChildAt(0) as SpectrumAnalyzer)
    }

    var end:Number = new Date().getTime()

    trace(end-start)

    start = new Date().getTime()

    for(var i:int=0; i<1000000; i++){
        SpectrumAnalyzer(ui.getChildAt(0))
    }

    end = new Date().getTime()

    trace(end-start)
  • 1
    "For the programmer it's the same" - **absolutely** not true! There is a huge difference depending on how you want to handle the errors. Speed here should not be considered as a plus, as they do totally different things. And you also iterate 1 million times (facepalm). – Andrey Popov Aug 30 '15 at 18:59