Learn how to a build a cloud-first strategyRegister Now


ActionScript questions

Posted on 2006-06-06
Medium Priority
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

blue-genie earned 1000 total points
ID: 16851875
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.


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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. …
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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…
Suggested Courses

810 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