A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Action script: How to display array's elements

  1. #1
    Junior Member
    Join Date
    Apr 2011

    Action script: How to display array's elements

    Hi everyone,
    In a fla file (flash8) I added an "Input-text" naming the var: "varInput",
    and selected "Numeral [0..9]" from "Character Embedding".
    I added another input object, this time of "Dynamic -text" text type
    naming the var: "varOutput". I also added a button naming its' instance name:
    In "actions" panel I wrote the following code:
    btnDisplay.onRelease = function() 
    var varInput:Number=0;
    var varOutput:String="";
    var myArr:Array=new Array("a","b","c");
    Running this code i get 2 errors (at least):
    1. The input text box (varInput) accepts non numeric fonts althoug i selected only numeric
    characters from the "Character Embedding"?
    2.When i select: control->test movie I get an error message that says:
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler

    Total ActionScript Errors: 1 Reported Errors: 1
    Can anyone explain why those 2 errors occur ?
    Attached is the fla file.
    Attached Files Attached Files

  2. #2
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    As for the first error, you'll need to restrict the values that the input text can take, in your case only numerals. Just selecting "numerals" in the font embedding area does not restrict alphabetic values from being entered. So something like this should clear that up,

    PHP Code:
    input.restrict "0-9"
    As for the second, try removing the code that's placed directly on the button. It's good practice to keep all the code off of objects and on it's own layer.

    Wile E. Coyote - "Clear as mud?"

  3. #3
    Junior Member
    Join Date
    Apr 2011

    Thanks a lot ! That helped me very much !

    Now everything is working properly.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center