Senior Member
[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.
Senior Member
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. -
Senior Member
I'm having no luck with that unfortunately. Could you show me an example with combo boxes or point me to one? Thanks.
Senior Member
Found a work around - may not be the best way of doing it, but it worked.
Thanks, this class was quite helpful.
Senior Member
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.
Senior Member
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. -
Senior Member
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.
Senior Member
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);
}
}
Senior Member
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);
}
}
Senior Member
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
- The right of the People to create Flash movies shall not be infringed. -
Senior Member
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.
Senior Member
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. -
Senior Member
So is there a way to dynamically duplicate the class?
Thanks.
Senior Member
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?
Senior Member
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);
}
Senior Member
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?
Senior Member
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. -
Senior Member
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.
Senior Member
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.
Senior Member
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
Forum Rules
Click Here to Expand Forum to Full Width