Butterflycode
Butterflycode

Reputation: 809

AS3 android back button problems

I am trying to make the back button go to the first scene of the application...I am using this...

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_OptionsBackHandler);

function fl_OptionsBackHandler(event:KeyboardEvent):void
{
    event.preventDefault();
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_OptionsBackHandler);

    gotoAndPlay(1, "Scene 1");

    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_OptionsBackHandler);
}

This some what works. The problem is when it goes back to that frame and scene it doesn't execute the code that is there. I have say some graphics made by as3 but it doesn't draw them when it returns. I do delete them when it goes to the next scene. To get to the next scene I use a listener on a button and it basically goes to scene2 and deletes the children that I want deleted so they don't carry on over to the next scene.

The other issue is even when it goes back to scene 1 and I click the button to go to scene 2 some stuff from scene one is rendered in scene two....Not everything but something. Any idea what could be wrong?

Thanks.

Upvotes: 0

Views: 610

Answers (1)

Moorthy
Moorthy

Reputation: 754

I don't know how many frames you have in the scene1. But I am sure if your code is in the first frame of scene 1 you can't see that because you haven't stopped there rather you are playing it to what is next(gotoAndPlay). So, if you want to see the changes made dynamically you should stop there(where your code is).

The Other Issue. In AS3, If you do some dynamic actions in the stage like the following, then it won't get removed when you moving to another scene.

  1. add a movieclip,
  2. swap depth or changing child index,
  3. start drag and so on.

I hope there is only one stage for the whole application. So, the objects in the stage are always visible regardless of what scene we are in.

Upvotes: 1

Related Questions