Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

+ Reply to Thread
Results 1 to 6 of 6
  1. #1

    Default Please help with focus

    the focus is giving me this error:
    TypeError: Error #1010: A term is undefined and has no properties.
    at 1_fla::MainTimeline/frame1()



    import flash.events.KeyboardEvent;
    import fl.managers.FocusManager;
    import flash.display.InteractiveObject;
    import fl.managers.IFocusManagerComponent;
    import fl.managers.IFocusManager;

    stop();
    moreinfo_mc.visible = false;
    feedback_mc.visible = false;
    names_mc.displayred_btn.visible = false;
    names_mc.redbox_mc.visible = false;


    var num:Array = new Array(01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, //
    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, //
    35, 36, 37, 38, 39, 40);

    var textbox:Array = [names_mc.box1_txt, names_mc.box2_txt, names_mc.box3_txt, names_mc.box4_txt,names_mc.box5_txt, //
    names_mc.box6_txt,names_mc.box7_txt,names_mc.box8_ txt,names_mc.box9_txt,names_mc.box10_txt,names_mc. box11_txt,//
    names_mc.box12_txt,names_mc.box13_txt,names_mc.box 14_txt,names_mc.box15_txt,names_mc.box16_txt,names _mc.box17_txt, //
    names_mc.box18_txt,names_mc.box19_txt,names_mc.box 20_txt,names_mc.box21_txt,names_mc.box22_txt,names _mc.box23_txt, //
    names_mc.box24_txt,names_mc.box25_txt,names_mc.box 26_txt,names_mc.box27_txt,names_mc.box28_txt,names _mc.box29_txt, //
    names_mc.box30_txt,names_mc.box31_txt,names_mc.box 32_txt,names_mc.box33_txt,names_mc.box34_txt,names _mc.box35_txt, //
    names_mc.box36_txt,names_mc.box37_txt,names_mc.box 38_txt,names_mc.box39_txt,names_mc.box40_txt]; //

    //var targetarray:Array= new Array();
    //var n = 0;
    //var m=0;
    //var k:Number;
    //var j:Number;



    names_mc.displayred_btn.addEventListener(MouseEven t.CLICK, feedback_ftn);

    function feedback_ftn(e:MouseEvent):void{
    feedback_mc.visible = true;
    }

    feedback_mc.back_btn.addEventListener(MouseEvent.C LICK, back_ftn);

    function back_ftn(e:MouseEvent):void{
    feedback_mc.visible = false;
    }

    var fm:FocusManager=new FocusManager(this);


    function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
    var fx:InteractiveObject = fm.getNextFocusManagerComponent();
    fm.setFocus(fx);
    }
    }

    for(var i:int=0; i < textbox.length; i++) {
    //textbox[i].buttonMode = true;
    //box[i].addEventListener(MouseEvent.CLICK, myclick_ftn);
    //box[i].addEventListener(FocusEvent.FOCUS_IN,textInputHan dler);
    //box[i].addEventListener(FocusEvent.FOCUS_OUT,textInputHa ndlerOut);
    textbox[i].restrict = "0-9";
    textbox[i].addEventListener(KeyboardEvent.KEY_UP, k);
    textbox[i].tabIndex=i;
    }

    /*
    function myclick_ftn(e:MouseEvent):void {
    n = (box.indexOf(e.currentTarget));
    targetarray.push(n);
    if(textbox[n].text !== ""){
    names_mc.displayred_btn.visible = false;
    names_mc.redbox_mc.visible = false;
    }
    if(m == 0){
    m++;
    }
    }

    function textInputHandler(event:FocusEvent):void {
    stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler);
    }

    function textInputHandlerOut(event:FocusEvent):void {
    //stage.removeEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler);
    }

    function keyDownHandler( e:KeyboardEvent ):void{
    //tab
    var i=0;
    if(e.charCode == 13){
    stage.focus = textbox[i + 1];
    }
    if(e.charCode == 9){
    stage.focus = textbox[i + 1];
    }
    if(e.charCode == 40){
    stage.focus = textbox[i + 1];
    }
    }

    function comparestring_ftn(){
    var j=0;
    targetarray[j];
    /*if(n != 0){
    n=n-1;
    if(num[n] == textbox[n].text){
    names_mc.redbox_mc.visible = false;
    names_mc.displayred_btn.visible = false;
    }
    if(n >= 0) {
    names_mc.displayred_btn.x = box[n].x;
    names_mc.displayred_btn.y = box[n].y;
    names_mc.displayred_btn.x += 60;
    names_mc.redbox_mc.x = box[n].x;
    names_mc.redbox_mc.y = box[n].y;
    names_mc.redbox_mc.visible = true;
    names_mc.displayred_btn.visible = true;
    }
    //}
    }





    */

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    var textbox:Array =
    You never declare what textbox is.
    When you put :Array next to a variable name, that doesn't do anything. :Array is mostly for the programmer. You need to add "new Array" after the = sign.

  4. #3

    Default

    Thanks! One last question....How can I get the previous focus. Kinda in a time crunch and new to all this. I changed my code so I'll post it under here:


    How can I get the previous focus so I can compare what is in the textInput to what the user should have typed? I am wanting to check after the user types in their answer and clicks, tabs, or pushes enter to the next box.

    stop();
    import flash.events.KeyboardEvent;
    import fl.managers.FocusManager;
    import flash.display.InteractiveObject;
    import fl.managers.IFocusManagerComponent;
    import fl.managers.IFocusManager;

    next_btn.visible = false;
    moreinfo_mc.visible = false;
    feedback_mc.visible = false;
    names_mc.displayred_btn.visible = false;
    names_mc.redbox_mc.visible = false;

    var num:Array = new Array(01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, //
    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, //
    35, 36, 37, 38, 39, 40);

    var textbox:Array = new Array(names_mc.box1_txt, names_mc.box2_txt, names_mc.box3_txt, names_mc.box4_txt,names_mc.box5_txt, //
    names_mc.box6_txt,names_mc.box7_txt,names_mc.box8_ txt,names_mc.box9_txt,names_mc.box10_txt,names_mc. box11_txt,//
    names_mc.box12_txt,names_mc.box13_txt,names_mc.box 14_txt,names_mc.box15_txt,names_mc.box16_txt,names _mc.box17_txt, //
    names_mc.box18_txt,names_mc.box19_txt,names_mc.box 20_txt,names_mc.box21_txt,names_mc.box22_txt,names _mc.box23_txt, //
    names_mc.box24_txt,names_mc.box25_txt,names_mc.box 26_txt,names_mc.box27_txt,names_mc.box28_txt,names _mc.box29_txt, //
    names_mc.box30_txt,names_mc.box31_txt,names_mc.box 32_txt,names_mc.box33_txt,names_mc.box34_txt,names _mc.box35_txt, //
    names_mc.box36_txt,names_mc.box37_txt,names_mc.box 38_txt,names_mc.box39_txt,names_mc.box40_txt); //

    //var targetarray:Array= new Array();
    //var n = 0;
    //var m=0;
    //var k:Number;
    //var j:Number;



    names_mc.displayred_btn.addEventListener(MouseEven t.CLICK, feedback_ftn);

    function feedback_ftn(e:MouseEvent):void{
    feedback_mc.visible = true;
    }

    feedback_mc.back_btn.addEventListener(MouseEvent.C LICK, back_ftn);

    function back_ftn(e:MouseEvent):void{
    feedback_mc.visible = false;
    }

    var fm:FocusManager=new FocusManager(this);


    function k(e:KeyboardEvent):void {
    if(e.keyCode==Keyboard.ENTER) {
    var fx:InteractiveObject = fm.getNextFocusManagerComponent();
    if(fx) fm.setFocus(fx);

    }
    }

    for(var i:int=0; i < textbox.length; i++) {
    textbox[i].buttonMode = true;
    box[i].addEventListener(MouseEvent.CLICK, myclick_ftn);
    //box[i].addEventListener(FocusEvent.FOCUS_IN,textInputHan dler);
    textbox[i].restrict = "0-9";
    textbox[i].addEventListener(KeyboardEvent.KEY_UP, k);
    textbox[i].tabIndex= i;
    }

    function myclick_ftn(e:MouseEvent):void {
    n = (box.indexOf(e.currentTarget));
    targetarray.push(n);
    if(textbox[n].text !== ""){
    names_mc.displayred_btn.visible = false;
    names_mc.redbox_mc.visible = false;
    }
    if(m == 0){
    m++;
    }
    }

  5. #4
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    Sorry for the late reply.
    I read through the code, but I'm not really sure what you're trying to do, and what focus is.

  6. #5

    Default

    I need to be able to check and see if the user inputs the right input after the click, tab or enter. hopefully you can help

  7. #6
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    What I don't understand is, what is the user inputting, and where is he inputting? If you need to check user input, then just use the instance name of whatever textbox he typed in or whatever button he pressed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial