A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: [RESOLVED] cellrenderer woes

  1. #1
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124

    resolved [RESOLVED] cellrenderer woes

    I'm using the cellrenderer to change text style when an object is click in one combo box.

    What I need to do is apply that same format to all combo boxes on the stage in that one item.

    Say I have cBox1, cBox2, and cBox3 with lists like: item1, item2, item3.

    I select item1 in cBox1, and then set that cell to disabled. When I do that, i want item one disabled in the other 2 comboboxes as well.

    Any ideas?

    Thanks.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Just do what I suggested to you in a different thread for all other comboboxes.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    I'm having no luck with that unfortunately. Could you show me an example with combo boxes or point me to one? Thanks.

  4. #4
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Found a work around - may not be the best way of doing it, but it worked.

    Thanks, this class was quite helpful.

  5. #5
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Okay that code I'm using but with one problem.

    How do I get it to only target 1 combobox instead of all. I need functionality for both options.

    Thanks.

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You set only style of the List for those comboboxes you want.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    well I have 10 boxes, and all have to be able to do this.

    say I click item 1 in box 1, and it's wrong, I need it to be only disabled in box 1. Then say I click item2 in box2, and it's correct, I need it to be disabled in every other box.

    is that possible?

    Could I get an example?

    Thanks.

  8. #8
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Shouldn't this work?

    Why wouldn't it?

    private var styleArray:Array = new Array;
    private var styleVar:Boolean = false;
    var newMyCellRenderer:MyCellRenderer;
    private function setStyles():void {
    for(var i:Number = 0; i<cArray.length; i++) {
    newMyCellRenderer = new MyCellRenderer;
    styleArray.push(newMyCellRenderer);
    this.holderMC[cArray[i]].dropdown.setStyle("cellRenderer",newMyCellRendere r);
    }
    }

  9. #9
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Trying to use that accompanied with this function:

    private function changeDea(evt:Object):void {

    var holdNum:int = evt.target.dropdown.selectedIndex;
    if(evt.target.getChildByName("varMC").isGreen == true && evt.target.getChildByName("varMC").isRed == false) {
    for(var i:Number = 0; i<cArray.length; i++) {
    //this.holderMC[cArray[i]].dropdown.setStyle("cellRenderer",MyCellRenderer);
    styleArray[i].selectIndex (holdNum);
    trace("green");
    evt.target.removeEventListener(Event.RENDER, changeDea);
    }

    } else if(evt.target.getChildByName("varMC").isRed == true && evt.target.getChildByName("varMC").isGreen == false) {
    styleArray[arrayNum].selectIndex (holdNum);
    trace("red");
    evt.target.removeEventListener(Event.RENDER, changeDea);

    } else {
    trace("default");
    evt.target.removeEventListener(Event.RENDER, changeDea);
    }
    }

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You need to create a separate cellrenderer class for each combobox. I have attached a working example. You need to add a combobox to the library.
    Attached Files Attached Files
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Is that the only way? Reason i ask is because this is a dynamic application that can create as many or as few combo boxes as the xml file specifies.

    Is there a way to import the class once and create numerous instances of it?

    thanks.

  12. #12
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You cannot use instances of the cellrenderer subclass, because to set a style for the combobox you need to use the class and not an instance of the class.
    - The right of the People to create Flash movies shall not be infringed. -

  13. #13
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    So is there a way to dynamically duplicate the class?

    Thanks.

  14. #14
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    I did the thing with numerous scripts but for some reason if I disable one in a list, the item 8 blocks after it disables itself. Any idea as to why?

  15. #15
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    For example this code:

    If you click on an item, that item disables but down the list a few down the next item disables. Any ideas? Thanks.


    import com.amatrol.util.cellrenderer.MyCellRenderer0;
    import fl.controls.*;
    var c1:ComboBox = new ComboBox();
    addChild(c1);
    c1.dropdown.setStyle("cellRenderer",MyCellRenderer 0);
    c1.addItem({label: "Item1"});
    c1.addItem({label: "Item2"});
    c1.addItem({label: "Item3"});
    c1.addItem({label: "Item4"});
    c1.addItem({label: "Item5"});
    c1.addItem({label: "Item6"});
    c1.addItem({label: "Item7"});
    c1.addItem({label: "Item8"});
    c1.addItem({label: "Item9"});
    c1.addItem({label: "Item10"});
    c1.addItem({label: "Item11"});
    c1.addItem({label: "Item12"});
    c1.addEventListener(Event.CHANGE, changeHandler);
    function changeHandler(evt:Object):void {
    MyCellRenderer0.selectIndex(evt.target.selectedInd ex);
    }

  16. #16
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Just noticed something.

    If I set the combobox rowcount to 12, or the total number of items rather, then i don't get this problem, but how do I go about remediation of it, if I only want a certain number of rows to show?

  17. #17
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I though you wanted to disable rows so the user cannot select any more. That was working well in the example I posted. If you delete rows the index will change.
    - The right of the People to create Flash movies shall not be infringed. -

  18. #18
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    It tends to deactivate the item that is the rowcount value + 1 items below the one clicked:

    I.E. -

    If the rowCount is 5 and I click item1, then item7 becomes disabled, 6 items down from where item1 is.

    Kinda peculiar because I don't see anything in the code to make it do something like that.

  19. #19
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Yeah that's right, but if I have a list of say 12 items I want a rocount of 5.

    For some reason If I click on item1, item7 and item1 become disabled.

    And i can't get the example to publish, I keep getting errors with it that say parameter must be non-null.

  20. #20
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    I don't want to delete any rows though. Just disable them.

    Also, correction, I got your example to work, just had to add a combobox to the library.

    Anyway, the weird problem now is with the rowcount issue where i click on one and the item a few later disables as well.
    Last edited by jweeks123; 07-11-2008 at 11:40 AM.

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