• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ActionScript 3 How to reset entire stage, or restart the code?

New Here ,
Jul 23, 2015 Jul 23, 2015

Copy link to clipboard

Copied

Hi everyone,

I've been trying to code quite a complex mobile game using Flash CS6 and AIR similar in style to the game "Dots" for Android and iOS.

I have all the game distributed in scenes, as an example, "Scene 1" has all the contents and animations for the menu. and "Scene 2" has the actual game itself.

The code inside "Scene 2" creates a bunch of objects at the beginning, and then runs the code for the game using those objects.

There is a button inside "Scene 2" that returns you to the menu located inside "Scene 1".

Here's the problem: If i attempt to return to the game located inside "Scene 2" everything brakes. The reason this happens is because the code was executed once already, the objects and variables were created, and if you try and erase the objects and get into the scene again, it will crash because it is expecting for the objects to be there.

The code runs once for every scene, what i would like to do is reset everything once i return to the menu, and be able to play the game when i return to "Scene 2".

Basically, i would like to reset the scene and run the ActionSctipt located within the scene once again. Something similar to resetting the entire SWF file.

TOPICS
ActionScript

Views

3.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2015 Jul 23, 2015

Copy link to clipboard

Copied

reload the game.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2015 Jul 23, 2015

Copy link to clipboard

Copied

What would the code be to reload the current frame?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 02, 2019 Jan 02, 2019

Copy link to clipboard

Copied

How do you code a button to restart the game?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

either:

1.  reset everything by hand

2.  reload the swf with the code you want to reset.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

Not helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2015 Jul 23, 2015

Copy link to clipboard

Copied

Another thing is, if i try to use frames instead of scenes to distribute the parts of the game and the levels, everything brakes down. buttons start moving to random locations, you can click them from far away, hit detection doesnt work anymore. I don't know if this is a common problem with Flash, but it has happened to me all the time, that's why i usually use Scenes with single frames to run all the game.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2015 Jul 23, 2015

Copy link to clipboard

Copied

reload your swf.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 04, 2019 Jan 04, 2019

Copy link to clipboard

Copied

LATEST

I had success by following another user’s suggestion. Simply have a menu or loading screen on frame 1, then have your game on frame 2, or 10 to help keep it spaced out. Then just have a gotoAndStop command on your game frame so it doesn’t leave the frame until you’re ready. I had the reset button jump to the first frame that said “loading level...”

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines