Welcome, Guest
  • Author Topic: SetFocus: Bad when using ComboBox Component  (Read 5489 times)

    sherman wellons

    • Jr. Programmer
    • **
    • Posts: 55
      • View Profile
      • Email
    Flash db folks.

    Okay...I have one that has me dazzed, confused, and aggrivated all at the same time.


    If you create a combo box and a text field. And if you attempt to set the focus of the text field to a specified index.....after the combo box closes. The index position of the text field jumps automatically to (0,0), instead of specified numbers. See for yourself: Drag a combo box onto the stage and give it an instance name of "theCombobox" (give the label a few values so you can select something when the combo box selection drops down) .  Just create an input text field and give it an instance name of "mytext". Add this line of code:

    form = new Object();
    form.close = function(){
     Selection.setFocus(mytext);
     Selection.setSelection(5,26);
    }
    theCombobox.addEventListener("close", form);

    Make sure that you add 26 characters or more to the  text field so that when you specify an index position, you are specifying a position that you can visually see highlited.

    The cursor initially jumps to the specified focus index postion (Selection.setSelection(5,26)), which is specified above then jumps to (0,0).  Is there a work around for this? Is there some property in the combobox  component which can be changed to fix this? Any suggestions would be greatful.

    Reason for correcting problem:

    I am attempting to build a simple text editor using flash. Using the combo box to select font sizes and font type, and maybe font color......depends upon if the pain is worth the effort. Thanks.

    --flashdumbass--

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:SetFocus: Bad when using ComboBox Component
    « Reply #1 on: 06/22/04, 10:30 »
    Yep, strange. Anyway, consider this: usually the user will select some text, then go to the combobox to change something. Suppose that you set to bold the Selection (that you need to capture whe the textfield lost focus)

    [script]
    form = new Object();
    form.change = function(){
     myBold = new TextFormat()
     myBold.bold = true
     mytext.setTextFormat(5, 26, myBold)
     
    }
    theCombobox.addEventListener("change", form);
    [/script]

    Also take a look at http://www.flash-db.com/Components/?swfID=28&sComType=Text%20Editor

    Jorge

    sherman wellons

    • Jr. Programmer
    • **
    • Posts: 55
      • View Profile
      • Email
    Re:SetFocus: Bad when using ComboBox Component
    « Reply #2 on: 06/22/04, 18:22 »
    Jorge.

    Thanks for the response. Strange indeed. I checkedout the text editor you refered me to. I reverted back to Flash MX Actionscript 1.0 and used a combo box in the same fashion. No drama.....must be a bug with Flash MX Professional components. Macromedia folks must of rushed to get the product out without hashing out the little bugs which can drive you insane. Thanks again....'



    ---flash dumbass--

    Larryson

    • Server what's that
    • *
    • Posts: 1
      • View Profile
      • Email
    Re: SetFocus: Bad when using ComboBox Component
    « Reply #3 on: 06/14/09, 23:35 »
                  I agree i incurred this error. Thanks for the information to fix using ComboBox component.


    ________________
    movie