Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 696801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:06:08+00:00 2026-05-14T03:06:08+00:00

I am making a fighting game in Flash and while I have everything running,

  • 0

I am making a fighting game in Flash and while I have everything running, I am missing something: a victory/loss screen. Logically, I know how to do it:

if character.hp < 0
{
    character.dead = true;
    dispatchevent("death", event)
}

My problem is that I have no idea as to how to code it. I know I will use two classes and my two .fla files (unless I am wrong).

I have two .fla files that are in play here: the Menu.fla file and the Arena.fla file. Menu.fla contains the entire navigation of the game, options, character selection screens, etc. and when it is time for the player to engage in battle, it loads the Arena.fla file, which contains only the backgrounds (depending on the selected stage) and for now is set to a length of one frame only. For Arena.fla, the real action happens in my classes, but logically, I would only need HP.as and Character.as.

In Character.as, I have declared the following variable:

var isDead:Boolean = false;    //is character dead?

In HP.as, believe I should have the following:

if(currentHp<0)
{
    currentHp = 0;
    character.isDead = true;     //declared as var `character:Object;`
    EventDispatcher.dispatchEventListener("playerDead", playerDead);
}

And finally, in Arena.fla, I want to be able to detect the above-mentioned eventlistener and simply move on to a second frame which will display a message in the style of “PLAYER ONE HAS WON” or “PLAYER ONE HAS LOST” with a button that will allow me to go back to the character selection screen. This is the first part in which I am stuck: how do I detect the dispatched event listener in my main .fla file?

Secondly, if the player clicks on the “CONTINUE” button, which displays regardless if the player has won or lost, how can my Menu.fla (which loads the Arena.swf) detect this click event, unload the game, and go back to the character selection screen?

Thank you in advance for helping me out. I realize this is a lot of text but it’s the most descriptive I can be. If you have any questions or need any clarification concerning my question, feel free to speak up.

-Christopher

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:06:09+00:00Added an answer on May 14, 2026 at 3:06 am

    Thank you all for your help, but I have figured it out. Turns out my method was far too complicated for what I wanted to do, and for the time I had left. I will explain how I did it.

    Instead of using an EventDispatcher like I thought I would, I used a SharedObject, which simply made everything work like magic.

    A SharedObject can be accessed from anywhere in the application/game, as long as it is referred to it correctly. So I simply created a SharedObject called “winLossData” set to “NO WINNERS” in my character selection screen. This cookie is never saved nor written to the disk, so there’s no chance for the user to find it (generally speaking).

    I have decided to use the Movement.as class which contains all of my controls and wrote an event listener of type Event.ENTER_FRAME that checks constantly my characters’ health status. If one of them is below 100, my SharedObject immediately takes for value either “PLAYER ONE” or “PLAYER TWO”, depending on who won (i.e. whose health points are not under 100). Afterward, just for precaution, I reset the losing character’s health points to 100. Here’s the code:

        function whoWon(event:Event):void
        {
            if(playerSpriteBar.getPower() <= 0)
            {
                winner.data.winner = "Player Two";
                playerSpriteBar.update(100);
            }
            if(playerAIBar.getPower() <= 0)
            {
                winner.data.winner = "Player One";
                playerAIBar.update(100);
            }
        }
    

    In my Menu.fla, I have another event listener of type Event.ENTER_FRAME that waits for the cookie to change value. As soon as the cookie changes values, Menu.fla automatically unloads the external swf (in our case, Arena.swf) and displays the results, accordingly to the received SharedObject. The rest of the actions happen inside the Menu.fla file, so no need for any extra coding.

    Once again, thank you all for your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.