actionscript-3game-enginestarling-framework

How to stop Starling and re-initiate for a book reading app?


I have two classes named Startup.as & RacTest.as

Here Startup.as is the main class, where i initiated the starling.

this.starling = new Starling(RacTest, stage, new Rectangle(xOffset, yOffset, adjustedScreenWidth, adjustedScreenHeight));

RacTest.as serves as the engine for the app and reads a particular book for which i gave a specific path.

It works perfectly. Now i need to press back button to quit the engine and re-initiate the RacTest.as to read the another book.

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);

public function onKeyDown(event:KeyboardEvent):void
        {
            if(event.keyCode == Keyboard.BACK )
            {
                event.preventDefault();
                event.stopImmediatePropagation();
RacTest.gameInstance.removeChild(RacTestApp.gameInstance.imageContainer);
                RacTest.gameInstance.bgSoundChannel.stop();
                RacTest.gameInstance.sceneIntSoundChannel.stop();
                RacTest.gameInstance.sceneLoadSoundChannel.stop();
                Starling.current.stop() 
            }
        }

Thanks in advance..


Solution

  • Just use these following codes to dispose starling completely.

    this.starling.stop();
    this.starling.dispose();
    this.starling = null;