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

  • Home
  • SEARCH
  • 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 8364385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:25:06+00:00 2026-06-09T12:25:06+00:00

Well to cut the chase, I believe that this function is causing my problem.

  • 0

Well to cut the chase, I believe that this function is causing my problem.

function getRandomLabel():String {
    var labels:Array = new Array(24,62,49,74,37);
    var index:Number = Math.floor(Math.random() * labels.length);
    return labels[index];
}
this.gotoAndPlay(getRandomLabel());

This function is used for randomization of the 5 digits above (24,62,49,74,37)
So that my moles (5 moles) will appear randomly.
Currently working on a whack-a-mole flash game

Current scene: 2 out of 3

Somehow, when I test play it it loops back to scene 1 frame 1.

One more thing, the problem started when I tried to put the “game proper” into scene 2 where the rest of my codes are in (menu, mechanics, etc.)

  • 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-06-09T12:25:07+00:00Added an answer on June 9, 2026 at 12:25 pm

    As Andrew said, you don’t have asked nothing. You just expose what you have but did not what is happening. Well, your function does not have problem. I’m pretty rusty with AS, but I would write it this way:

    function getRandomFrame( frameNumbers: Array ): int {
        return frameNumbers[Math.floor( Math.random() * frameNumbers.length )];
    }
    gotoAndPlay( getRandomFrame( [24, 62, 49, 74, 37] ) );
    

    You are getting frame numbers not labels, so I changed its name. Since you are calling gotoAndPlay, your movie “play head” will go to the selected frame and it will be played until it reaches the end of the timeline, and the movie, by default, will start over. If you need to stop the animation, you need to set an stop in the desired frame. Try your code with gotoAndStop instead of gotoAndPlay. The movie will go to the random frame and it will stop. If you need to get frame labels, create an array of Strings:

    function getRandomLabel( labels: Array ): String {
        return labels[Math.floor( Math.random() * labels.length )];
    }
    gotoAndPlay( getRandomLabel( ["car", "dog", "music"] ) );
    

    It seems that you are a Flash newbie, so you need to study more the tool that you are dealing with 😉 The ActionScript default version in Flash CS5 is the third.

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

Sidebar

Related Questions

I have this problem: Well, the words in the article are ClickableSpans that change
Well problem was that my original input is: x=[['1', '7', 'gg'], ['1.5', '8', 'as']...]
I want to cut only ALLS WELL THAT ENDS WELL until Florentine. That mean
well i have a configuration like this in the components part of my config
Well, I was trying to fix this program, and I keep getting the errors
I have a template function in C++ that basically writes values to an XML
I'm making a typing tutor program using javascript. Everything is going well except that
How do I properly make an array like this one to be unique ?
Well the problem I am facing right now is a size issue problem. I
It is well-known that STL classes do not use virtual methods anywhere (and STL

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.