ActionScript questions

Posted on 2006-06-06
Last Modified: 2010-04-03
Hey Everyone,
I am very new to ActionScript and I am struggling with capturing some feedback from a user. I have a file that has 3 games in it and I need to compare what the user clicks to the value in a textbox. Here is the code I have so far.

var numList;
var buttonName;

numList= new Array(

function displayNum (){
      var randomNum= Math.floor(Math.random()* numList.length);
function buttonPressed(){
      buttonName = counting_btn._name

Any help is appreciated.

Question by:Stratocaster
    1 Comment
    LVL 39

    Accepted Solution

    hi there, i'm not sure what you mean.
    are you trying to determine if the name of the button that is clicked is the same as the random number that is generated and displayed in the countNum_txt.text field?

    have a look here

    var numList;
    var buttonName;
    numList = new Array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Zero");
    function displayNum() {
          var randomNum = Math.floor(Math.random()*numList.length);
          countNum_txt.text = numList[randomNum];
    function buttonPressed(which) {
          if (which == countNum_txt.text) {
          } else {
    One.onRelease = function() {

    so here's a couple of things you need to consider.
    1. when are you swapping out the random number? you need to call it. in the example above I've called it just the one time.
    2. i've assigned a method to the One movieclip to call your buttonPressed clip. the only thing i've changed is for it to accept a parameter, so each button will parse it's own name (assuming you're naming your buttons according to your array) to the method which will check it against the random number.

    is that what you're trying to achieve?

    shout if you need more.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now