Masking In CellRenderer
I have a data grid with a CellRenderer that loads some thumbnail images. In order to give the images nice rounded corners I am creating a rounded rectangle and applying as a mask to the Loader that contains the image. Everything works fine until the datagrid is scrolled. The Problem: The mask on the images that were scrolled out of view (and then back) doesn't seem to work anymore and I just see the colored rectangle. Can anyone give me some insight on this? Here's the code for the cell renderer:Code: package com.sectornine.utils { import fl.containers.UILoader; import fl.controls.listClasses.ICellRenderer; import fl.controls.listClasses.ListData; import fl.core.InvalidationType; import fl.data.DataProvider; import flash.events.Event; import flash.display.Graphics; import flash.display.Shape; public class LoaderCellRendererGallery extends UILoader implements ICellRenderer { protected var _data:Object; protected var _listData:ListData; protected var _selected:Boolean; private var size:uint = 63; private var bgColor:uint = 0x00FF00; private var borderColor:uint = 0x666666; private var borderSize:uint = 0; private var cornerRadius:uint = 15; public function LoaderCellRendererGallery():void { super(); } public function get data():Object { return _data; } public function set data(value:Object):void { _data = value; // create array, grab first image var _imageArray:Array = value.Images.split(","); var _imageDir:String = value.Directory; var _ti:String = "images/gallery/"+_imageDir+"/thumbs/" + _imageArray[0]; source = _ti; var masker:Shape = new Shape(); masker.graphics.beginFill(bgColor); masker.graphics.drawRoundRect(1, 5, size, size-14, cornerRadius); masker.graphics.endFill(); addChild(masker); this.mask = masker; } public function get listData():ListData { return _listData; } public function set listData(value:ListData):void { _listData = value; invalidate(InvalidationType.DATA); invalidate(InvalidationType.STATE); } public function get selected():Boolean { return _selected; } public function set selected(value:Boolean):void { _selected = value; invalidate(InvalidationType.STATE); } }}thanks!
Actionscript 3.0
Posted on: Wed Oct 08, 2008 5:37 pm
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
About Cellrenderer
Hello everybody
I´m working with components, and I want to customize them...
I've already read, some information that conduce me to use cellrenderer to achieve what I want to do, but I'll need more info, also examples...
Does anyone knows something else, it´ll really help me....
I'm working with Macromedia Flash MX 2004 Professional
AS3 And CellRenderer
Hello,
I hope someone has good experience with CellRenderer. I got a List component and want to handle the display of the label, plus icons etc. So I created a class extending CellRenderer. But I can't get rid of the default dynamic TextField displayin the label text. I'd like to display it my own way in my own location so I created my own TextField but the default one wll always appear.
I overrode "set data" and assign "" to the label, but it will work only when you click on an item, the first time, both labels will show, the default one and mine. I don't know where I can set this TextField to invisible or clear the text.
I know I could derive my cellRendered from Sprite or something else, but then all of the List skins are lost and I would like to have them.
Any idea?
Help With CellRenderer API
Hello guys,
In my work i have a little problem, i want to add a xml file to a dataGrid, but there i have some link to some pictures, and i want to render those pictures in my dataGrid, and i don't know how. I know how to render directly, but not when i take the link from xml. Could you help me with some tutorials (links) where i can learn/understand the cellRenderer API.
Thanks in advanced!
Almost There On CellRenderer
Last edited by iliad2b : 2005-07-23 at 00:18.
i think i am getting close on getting my cellRender to work.
for what ever reason, my column displays the last item placed in the array continuously.
here is what i have:
.fla (id and comments are declared as arrays)
Code:
function printme()
{
var titleBar:Array = new Array;
for (var i:Number = 0; i <= size - 1; i++)
{
l = i;
titleBar.addItemAt(i, {ID: id[i], Coments: comments[i]});
commentList_dg.dataProvider = titleBar;
commentList_dg.getColumnAt(0).width = 45;
commentList_dg.getColumnAt(0).textAlign = "center";
commentList_dg.setStyle("alternatingRowColors", Array(0xEAEFF2, 0xF8FAFB));
commentList_dg.hScrollPolicy = "auto";
commentList_dg.rowHeight = 80;
commentList_dg.getColumnAt(1).cellRenderer = "MultiLineCell";
}
}
.as (the code is exactly as in the livedocs)
Code:
function setValue(suggested:String, item:Object, selected:Boolean):Void
{
// Set the text property of the label
// You could also set the text property to a variable.
multiLineLabel.text = String (_root.comments[_root.l]);
}
can someone help me out here?
thx
Some CellRenderer Questions
Hi,
I've been pretty successful writing a custom CellRenderer for a Tree component. Looking at the source code for the included CheckCellRenderer was very helpful during this process, but I've still come across a few puzzling issues that I was hoping someone here might have some insight on:
The documentation for List.cellRenderer says that the value of this property "must be a class object reference, or a symbol linkage identifier". I can get the latter to work by creating an empty movie clip symbol and setting its AS2.0 class to be my custom cell renderer class. I cannot get the former to work. I've tried specifying the class name as well as a variable that's an instance of that class, quoted and unquoted, but I always end up with empty cells (no renderer). How do I use a cell renderer class without having to create and export an empty movie clip to wrap it in?Why is there no CellRenderer interface to implement? The "CellRenderer API" is documented as a set of methods that must be implemented, which is basically what an interface is, yet there's no actual definition of any such interface in the library. So my custom cell renderer class doesn't actually contain any code that formally identifies it as conforming to the CellRenderer API.The CheckCellRenderer class contains a createChildren(Void) : Void method that appears to get invoked when the cell is instantiated (and/or recycled?). I put my own initialization code for my custom class in a similar method and it seems to work fine. Yet I can't find any documentation at all for this method and it's not clear to me where this is getting called from. It doesn't appear to be something that I'm overriding from UIComponent (which my cell renderer extends). What's the story on createChildren?
I'd really be interested in any insight on these points.
Thanks
- rdo
CellRenderer Problem
Guys please help!
I've problem with CellRenderer API. When i place loader to listbox and try to load .jpg image i don't see image till i mouse over on it.
Trace shows me that all is going the way i need.
thanks a lot for you answers. if needed i can paste code here.
[MX04] Help With CellRenderer Please
can anyone tell me why my cell Renderer is messing up?
just look at it
basically the createChildren is going into an infinite loop
[edit] nm figured it out
How To Use CellRenderer In DataGrid?
I found some examples for using custom cellRenderer to format cells in DataGrid, but they're either for Flex or written in AS 2.
Can anyone point me to a tutorial or example for using cellRenderer in DataGrid component in AS 3 from Flash CS3 IDE?
thanks.
Datagrid CellRenderer
Hi,
I'm trying to get the text in a datagrid row to change color on mousing over the row. The below code is what I'm using but it only changes the text in a cell. Is there any kind of 'rowRenderer' ? or how is this best achieved. Thanks.
Robin.
dg.setStyle("cellRenderer", CustomCellRenderer);
then the cellRenderer:
package
{
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import flash.events.*;
public class CustomCellRenderer extends CellRenderer
{
public function CustomCellRenderer()
{
addEventListener(MouseEvent.MOUSE_OVER,overListene r);
addEventListener(MouseEvent.MOUSE_OUT,outListener) ;
}
private function overListener(e:Event):void
{
var format:TextFormat = new TextFormat();
format.color = 0xFF0000;
setStyle("textFormat", format);
}
private function outListener(e:Event):void
{
var format:TextFormat = new TextFormat();
format.color = 0x000000;
setStyle("textFormat", format);
}
}
}
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.
CellRenderer With Tree
I can use CellRenderer on a Tree component as a whole but I would like to be able to apply different styles to branches and leaves.
Can it be done? If yes, how?
Get Index In Cellrenderer
How does one get the index, rowindex or cellindex in a datagrid from a cellRenderer using a component or movieclip?
For example: If I use a button in a cellRenderer.. when it is clicked, what is the current index of this cell or row?
If I tell it to access the datagrid itself to retrieve the index.. it does not get the current index as the cell was not actuated before the button is. So if no cell (or row) has been selected yet.. the button would return -1.
It must be a simple way to get the index.. but I cannot seem to find the answer. Anyone?
Must be AS3!
Cellrenderer And Datagrid
Can anyone help me figure out how to use the CellRenderer code in AS3.0 so that it functions similarly to AS2.0? Lets take for example... putting a checkbox in a datagrid... or a custom movie clip (like a progress bar - which is what I want to do). I've been working on it and it doesn't seem to work. I can get a movie clip into a cell, but when I scroll the DataGrid everything gets screwed up.
Anyone have experience with this? I need to use AS3.0 for the functionality of its uploading/downloading (like receiving data onComplete or uploads).
thanks a ton.
[AS2] Checkbox CellRenderer Value
Hello all,
i am using a checkbox cellRenderer. But i m not getting its true/false value. What is the event by which i can get if a checkbox is selected or not?
Plz help ....................
Need Guidance On CellRenderer
Hi all,
I need to manipulate cellRenderer in a row-by-row basis order to display components based on 'type' in a dataProvider. e.g
ActionScript Code:
dataProvider = [ {label:"FName", type:"text", data:"John"}, {label:"Activated", type:"check", data:true} ]
here you would get 2 rows. The first a normal text cell for the data field, The second - a checked checkbox for the data field.
What I have so far is a cellRenderer class which creates both a text field AND a checkbox in the constructor and sets _visibility to hidden. In the method that paints the cell (setValue() ) I change the relevant one visible based on 'type' in the dataProvider.
Just wondering if anyone can suggest a better way to do this. The problem is that 'type' is not available in the constructor... only after initialization
From what I've seen, cellRenderers posts dont seem to get much help but here's hoping - Just after a bit of direction...
Many thanks.
DataGrid CellRenderer AS3
here is my flash code:
Code:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
var html_txt = '<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="14" COLOR="#CC0000"><B><U>Template Sample2</U></B></FONT><br><br><FONT FACE="Times New Roman" SIZE="14" COLOR="#006666">The chapters in this manual are organized into the following logical groups.</FONT></P>';
var nameCol:DataGridColumn = new DataGridColumn("name");
var valueCol:DataGridColumn = new DataGridColumn("value");
var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(nameCol);
myDataGrid.addColumn(valueCol);
nameCol.cellRenderer = MultiLineCell;
myDataGrid.addItem({name: html_txt, value:"Value 1"});
myDataGrid.width = 400;
myDataGrid.rowHeight = 70; //this should be auto
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
myDataGrid.editable = true;
addChild(myDataGrid);
here is my MultiLineCell.as:
Code:
package {
import fl.controls.listClasses.CellRenderer;
public class MultiLineCell extends CellRenderer
{
public function MultiLineCell()
{
textField.wordWrap = true;
textField.multiline = true;
textField.autoSize = "left";
}
override protected function drawLayout():void {
textField.width = this.width;
textField.htmlText = textField.text;
super.drawLayout();
}
}
}
1, the DataGrid cell should be auto height according to the length of the html text, or I can use sroll bar here. and when i click on the cell, it want to show html text with out html tags.
I think if i can use textAre here inside DataGrid it will be great!!
help me..........................
Filter CellRenderer
hello
i am trying to create a custom cellRenderer comboBox..
the principle is slightly simple..
i like when i select an item.. the combo be filtred, and when i open it another time.. the previously selcted item become invisible..
is it possible to do this and to recupreate the last combo selected item data..
in my script i only can force the combo to don't show an item witch is already choosen if it's clicked in the open event of the combo but.. my combo shows always all of the combo items.. just the show of the selected item can be controlled..
i know i can't express the problem well but i hope that is clear..
i ask if there is tutorials ou fla samples containing similar functions
thank you
DataGrid CellRenderer AS3
here is my flash code:
Code:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
var html_txt = '<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="14" COLOR="#CC0000"><B><U>Template Sample2</U></B></FONT><br><br><FONT FACE="Times New Roman" SIZE="14" COLOR="#006666">The chapters in this manual are organized into the following logical groups.</FONT></P>';
var nameCol:DataGridColumn = new DataGridColumn("name");
var valueCol:DataGridColumn = new DataGridColumn("value");
var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(nameCol);
myDataGrid.addColumn(valueCol);
nameCol.cellRenderer = MultiLineCell;
myDataGrid.addItem({name: html_txt, value:"Value 1"});
myDataGrid.width = 400;
myDataGrid.rowHeight = 70; //this should be auto
myDataGrid.rowCount = myDataGrid.length;
myDataGrid.move(10, 10);
myDataGrid.editable = true;
addChild(myDataGrid);
here is my MultiLineCell.as:
Code:
package {
import fl.controls.listClasses.CellRenderer;
public class MultiLineCell extends CellRenderer
{
public function MultiLineCell()
{
textField.wordWrap = true;
textField.multiline = true;
textField.autoSize = "left";
}
override protected function drawLayout():void {
textField.width = this.width;
textField.htmlText = textField.text;
super.drawLayout();
}
}
}
1, the DataGrid cell should be auto height according to the length of the html text, or I can use sroll bar here. and when i click on the cell, it want to show html text with out html tags.
I think if i can use textAre here inside DataGrid it will be great!!
help me..........................
How To Add A Button As Cellrenderer Of A Datagrid?
Sorry if this question is obsolete, but i'm going mad with this proble:
How can i use a button (the component from UI in mx2004) as the content of a cell in a datagrid?
I've to implement some interface, but i don't know how.
Coan you help me??
Cellrenderer, Scope, And Checkboxes...
Flash 8, ActionScript 2
I'm building a datagrid list with checkboxes, using the cellrenderer API. I'm able to load an array into the datagrid, but I'm unable to work with one of the class files.
CheckBoxCell.as is the file defining the checkboxes class. When the checkbox is checked, the following listener inside the class runs:
Code:
public function click()
{
listOwner.dataProvider.editField(getCellIndex().itemIndex, getDataLabel(), check.selected);
}
I need to dynamically know when the checkbox is checked, and to modify variables on the main timeline based on the checkbox. I also need to pass the index # to the main timeline. Eventually I'll populate the datagrid with data from an XML file, but for now I just need to understand how to get the listener to send data to the main timeline.
I've tried:
Code:
_root.variablename[1] = true;
but it has no effect on the main timeline variable. I am able to set variables like so inside the listener:
Code:
variable2 = "test text";
Any help would be appreciated!
John
CellRenderer Icon Loop
I'm using the DataGrid component and want to show an icon for certain cells and not for others. I have a cellrenderer which works fine when displaying the records in the datagrid but it seems to be looping twice through the array.
When showing the viewable records it behaves itself. But when I scroll down, I see an 'echo' of the icons even though the cell data is undefined.
I'm using the setValue to test the cell value and create a new icon thus;
public function setValue(suggestedValue:String, item:Object, selected:Boolean):Void
{ trace(" %%%%%%%%% suggestedValue "+suggestedValue);
if (suggestedValue == "academic"){
//trace(" %%%%%%%%% USE academic CLIP ");
check = createObject("academic_ico", "academic_ico", 1);
//this.setStyle("fontWeight", "bold");
}else if(suggestedValue == "social"){
//trace(" %%%%%%%%% USE SOCIAL CLIP ");
check = createObject("social_ico", "social_ico", 1);
}
}
Has anyone come across this before?
Help With CellRenderer Class For A ComboBox
I am trying to dynamically skin a ComboBox at runtime, based on color values I am reading from a database using amfphp. Everything is working great, except for one thing.
I am having problems extending the CellRenderer class.
I current have this:
Code:
var mySkin:CustomCellRenderer = new CustomCellRenderer(color1, color2, color3);
myCB.dropdown.setStyle("cellRenderer", mySkin);
Then in my custom cell renderer class I have:
Code:
package {
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import OverSkin;
import UpSkin;
import DownSkin;
public class CustomCellRenderer extends CellRenderer{
private var _rectangle:Shape;
private var _bgColor:uint;
private var ov:OverSkin;
private var dow:DownSkin;
private var up:UpSkin;
public function CustomCellRenderer (Color1:uint,Color2:uint, Color3:uint) {
ov = new OverSkin(Color1);
dow = new DownSkin(Color2);
up = new UpSkin(Color3);
setStyle("upSkin",up);
setStyle("downSkin",dow);
setStyle("overSkin",ov);
setStyle("selectedUpSkin",up);
setStyle("selectedDownSkin",dow);
setStyle("selectedOverSkin",ov);
}
}
}
This all seems to be working fine, but I am running into one problem.
I click the comboBox to pull up the drop down, and it displays fine, I select an item and the drop down closes. I then go back to click the combobox and I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at fl.controls::List/drawList()
at fl.controls::List/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::List/scrollToIndex()
at fl.controls::SelectableList/scrollToSelected()
at fl.controls::ComboBox/open()
at fl.controls::ComboBox/onToggleListVisibility()
Can anyone point me to a tutorial or some sample code of how to implement the cellRenderer for a comboBox? I have been searching everywhere but cannot seem to find any good examples.
Datagrid W/ComboBox CellRenderer
Ok, I've tried to convert some Actionscript 2.0 ComboboxCellReinder code to Actionscript 3.0. I'm just getting all kinds of problems. I fix one and another seems to pop up. Could someone help explain to me what I'm doing wrong with converting the code.
Code:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.events.DataGridEvent;
import fl.data.DataProvider;
import fl.controls.Label;
import fl.controls.NumericStepper;
import flash.events.Event;
import fl.controls.DataGrid;
import fl.controls.TextInput;
some code here!
var sizeCol:DataGridColumn = new DataGridColumn("size");
sizeCol.cellRenderer = "ComboBoxCellLoader"
sizeCol.headerText = "Size";
sizeCol.width = col2WidthLayout;
pList_dg.addColumn(sizeCol);
more code here!
Here is the cellrenderer class
Code:
package {
import fl.core.UIComponent;
import fl.controls.ComboBox;
import fl.controls.DataGrid;
import flash.display.MovieClip;
import flash.events.Event;
import fl.controls.listClasses.CellRenderer;
public class ComboBoxCellLoader extends UIComponent
{
private var combo : MovieClip;
private var owner;// The row that contains the cell.
private var listOwner : DataGrid;// The reference of the list type component that contains this cell.
private var getCellIndex : Function;// A function we receive from the parent list (in this case a DataGrid).
private var getDataLabel : Function;// A function we receive from the parent list (in this case a DataGrid).
/*private static var PREFERRED_HEIGHT_OFFSET = 4; */// The preferred offset height of the cell containing the ComboBox.
private static var PREFERRED_WIDTH = 75; // 100 The preferred width of the cell containing the Combobox.
private static var COMBOBOX_HEIGHT = 20;// The height of the ComboBox.
private static var COMBOBOX_WIDTH_OFFSET = 10; //10 Amount of space we will add between the ComboBox and its cell so it looks better.
private var startDepth:Number = 10;
// Array of label/data pairs that define the ComboBox data provider.
private static var COMBOBOX_DATA_PROVIDER : Array = [{label: "", data: 0},
{label: "Large", data: 1},
{label: "Small", data: 2}];
// Constructor: Should be empty.
public function ComboBoxCell()
{
}
//Creates a ComboBox object and sets listeners.
public function createChildren() : void
{
combo = createObject("ComboBox", "Combo", startDepth++);
// Assign the data provider.
combo.dataProvider = COMBOBOX_DATA_PROVIDER;
combo.addEventListener(ComboBoxEvent.change, changeEvent);
combo.addEventListener(ComboBoxEvent.open, openEvent);
}
public function size() : void
{
/* Set the size and location of the ComboBox.
Note: setSize() is already implemented by UIComponent
which this class extends. UI component in turn expects this class
to implement size(). */
combo.setSize(__width, COMBOBOX_HEIGHT);
combo.setStyle("fontSize",12);
combo.setStyle("fontFamily" , "Arial");
}
public function setValue(str:String, item:Object, sel:Boolean) : void
{
/* Sets the ComboBox to the correspoinding cell data from the list owner's data provider if the cell data matches
with any items available for the ComboBox. */
var drawCombo:Boolean = true;
if (item[getDataLabel()]!=undefined)
{
/* For each item's data in the ComboBox, verify if it matches
the assigned data for the cell this ComboBox is in.
Set the selectedIndex of the ComboBox to what matches. */
for(var i:Number = 0; i < combo.length; i++)
{
if( combo.getItemAt(i).data == item[getDataLabel()] )
{
combo.selectedIndex = i;
break;
}
if ( i == combo.length - 1 )
{
// There was no matching data, the ComboBox should not be shown.
drawCombo = false;
}
}
}
else
{
drawCombo = false; // There was no data, hide the ComboBox.
}
combo._visible = drawCombo;
}
public function onLoad()
{
}
public function openEvent()
{
/* Handler for the open event sent by the ComboBox when
it has been clicked and opened to show its selectable items.
Tell the Datagrid that the cell containing the ComboBox
should be considered selected so that in turn the DataGrid
updates the entire row in a selected visual state. */
listOwner.selectedIndex = getCellIndex().itemIndex;
}
public function changeEvent()
{
// Handler for the ComboBox change event.
// Set the listOwner's data to the currently selected item's data of the combo box.
listOwner.dataProvider.editField(getCellIndex().itemIndex, getDataLabel(), combo.selectedItem.data);
}
public function getPreferredHeight(Void) : Number
{
/* The cell is given a property, "owner",
that references the row. It’s always preferred
that the cell take up most of the row's height. */
return owner.__height;
}
}
}
Thanks in advance for the help!
Monica
Cellrenderer, Icons In Combobox
I'm trying to load icons into a combobox, but the reference to the external jpg is loaded in from xml, and I'm not sure how to call that to load into the combo-box (since they're not library items with a Linkage)...
Any ideas??
TIA
Events From CellRenderer Class, How?
Hi,
I have my Problems with the CellRenderer. I try to send events from the CellRenderer Class to _root or other objects. Here is my code:
import mx.core.UIComponent
class NumericRenderer extends UIComponent{
private var listOwner : MovieClip;
private var getCellIndex : Function;
private var getDataLabel : Function;
private static var questions:Array = null;
private var question_txt:TextField = null;
private var answer_txt:TextField = null;
function NumericRenderer(){}
function createChildren(Void) : Void{}
function setValue(str:String, item:Object, sel:Boolean) : Void{
//...
}
}
How can I implement events in this class?
Thanks in advance!
Regards,
Mirza
Help With CellRenderer Class For Combobox
I am trying to dynamically skin a ComboBox at runtime, based on color values I am reading from a database using amfphp. Everything is working great, except for one thing.
I am having problems extending the CellRenderer class.
I current have this:
Code:
var mySkin:CustomCellRenderer = new CustomCellRenderer(color1, color2, color3);
myCB.dropdown.setStyle("cellRenderer", mySkin);
Then in my custom cell renderer class I have:
Code:
package {
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import OverSkin;
import UpSkin;
import DownSkin;
public class CustomCellRenderer extends CellRenderer{
private var _rectangle:Shape;
private var _bgColor:uint;
private var ov:OverSkin;
private var dow:DownSkin;
private var up:UpSkin;
public function CustomCellRenderer (Color1:uint,Color2:uint, Color3:uint) {
ov = new OverSkin(Color1);
dow = new DownSkin(Color2);
up = new UpSkin(Color3);
setStyle("upSkin",up);
setStyle("downSkin",dow);
setStyle("overSkin",ov);
setStyle("selectedUpSkin",up);
setStyle("selectedDownSkin",dow);
setStyle("selectedOverSkin",ov);
}
}
}
This all seems to be working fine, but I am running into one problem.
I click the comboBox to pull up the drop down, and it displays fine, I select an item and the drop down closes. I then go back to click the combobox and I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at fl.controls::List/drawList()
at fl.controls::List/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::List/scrollToIndex()
at fl.controls::SelectableList/scrollToSelected()
at fl.controls::ComboBox/open()
at fl.controls::ComboBox/onToggleListVisibility()
Can anyone point me to a tutorial or some sample code of how to implement the cellRenderer for a comboBox? I have been searching everywhere but cannot seem to find any good examples.
Cellrenderer Selected State
I am trying to write a cellrender script to replaces the default action of the selected cell in a list component.
instead of changing the color of the entire cell, a movie clip would be used under the text.
I would need to disable the background color as well.
I have researched several cellrenderer examples but none seem to help or even suggest if this is possible. Any help pointing me in the right direction would be fabulous! Thanks
AS3 Datagrid CellRenderer Examples
I searched far and wide but failed to get an AS3 version of the CheckBox and ComboBox cell renderer class examples. What I actually want to do is add a button component inside a DataGrid cell. I looked at the AS3 examples on Adobe.com but it seems really complicated to take an existing example and change it to cater for a different component. Can anyone point me to a link with a tutorial or example of this?
Edited: 08/30/2007 at 06:34:41 AM by WebMinder
AS3 Datagrid HTML CellRenderer
Hello everyone, I'm trying to display some simple HTML inside a datagrid. Without avail this task is becoming very time consuming. I've scoured the docs and have done all the custom cellRenderer examples. I'm open to a any ideas or just which class I need to extend, CellRenderer? UIComponent? Arrrggg.. thx
CellRenderer With A Loader Component
I've sucessfully created a CellRender that will hold a Loader component and subsequently load an image. The problem is that once the image is loaded, everytime i roll over and off the image the setValue() function is called and the image is loaded again. I don't want to have to reload the image all over again. Is there any way to prevent this? I've attached my code below:
Attach Code
import mx.core.UIComponent;
import mx.controls.Loader
class ImageCell extends UIComponent {
var img:MovieClip;
var url:String;
var listOwner:MovieClip;
var getCellIndex:Function;
var getDataLabel:Function;
function ImageCell() {}
function createChildren(Void):Void {
img = createObject("Loader", "Img", 1, {styleName:this, owner:this});
img.addEventListener("complete", this);
//size();
}
function setValue(str:String, item:Object, sel:Boolean):Void {
//make it visible only if there is a value
img._visible = (item[getDataLabel()] != undefined);
if (item[getDataLabel()]!=undefined){
img.autoload = false;
img.load(item[getDataLabel()]);
img.scaleContent=false;
size();
}
}
function size(Void) : Void
{
img._y = 1
img._width= 32
img._height= 32
}
function complete(){
size();
img._visible = true;
}
}
Overwriting ComboBox CellRenderer?
I've successfully overwritten the cellrenderer for my DataGrids, but the same changes don't work when I apply them to a combobox.
Is there something special that needs to be done to the cellrenderer for it to apply to a combobox? It seems like a lot of people are having this problem.
Help With The CellRenderer Class For A ComboBox
I am trying to dynamically skin a ComboBox at runtime, based on color values I am reading from a database using amfphp. Everything is working great, except for one thing.
I am having problems extending the CellRenderer class.
I current have this:
Code:
var mySkin:CustomCellRenderer = new CustomCellRenderer(color1, color2, color3);
myCB.dropdown.setStyle("cellRenderer", mySkin);
Then in my custom cell renderer class I have:
Code:
package {
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import OverSkin;
import UpSkin;
import DownSkin;
public class CustomCellRenderer extends CellRenderer{
private var _rectangle:Shape;
private var _bgColor:uint;
private var ov:OverSkin;
private var dow:DownSkin;
private var up:UpSkin;
public function CustomCellRenderer (Color1:uint,Color2:uint, Color3:uint) {
ov = new OverSkin(Color1);
dow = new DownSkin(Color2);
up = new UpSkin(Color3);
setStyle("upSkin",up);
setStyle("downSkin",dow);
setStyle("overSkin",ov);
setStyle("selectedUpSkin",up);
setStyle("selectedDownSkin",dow);
setStyle("selectedOverSkin",ov);
}
}
}
This all seems to be working fine, but I am running into one problem.
I click the comboBox to pull up the drop down, and it displays fine, I select an item and the drop down closes. I then go back to click the combobox and I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at fl.controls::List/drawList()
at fl.controls::List/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::List/scrollToIndex()
at fl.controls::SelectableList/scrollToSelected()
at fl.controls::ComboBox/open()
at fl.controls::ComboBox/onToggleListVisibility()
Can anyone point me to a tutorial or some sample code of how to implement the cellRenderer for a comboBox? I have been searching everywhere but cannot seem to find any good examples.
Column Info In Cellrenderer
Hi, should be pretty easy for those who have done cell renderer more than one time
Is it possible to find out which column is your cellrenderer is used in? because that class will be used in more than one column of the datagrid. The content depends on which column it's in.
Thanks all!
CellRenderer Isolated Component
hi guys!
is there a way to communicate externally to a component inside a cell renderer?
the case is a checkbox inside of a dataGrid, lets suppose the instance of that the dataGrid is "grid". the checkbox is in column 2, which should keep marking an status depending the info received from the database "true or false" , is there a way to set the result from outside?
the code that set the cellrenderer in the dataGrid is next:
grid.getColumnAt(2).cellRenderer = "checkCellRender";
any help is appreciated since is something hard to find documentation on this...
thx!
[as2] Using The CellRenderer To Import Buttons
Hi,
is it possible to use the cellRenderer to replace the rows in a ListBox with a series of buttons?
I want to populate my List Box with a vertically aligned series of animated buttons that have their labels populated by an xml file...
So far I've managed to get the list populated by the xml file using the data binding feature, and I can replace these rows with a graphic using the cellRenderer, I just can't work out how to get something with various states in there, and then to get something meaningful (ie the labels reading correctly) to happen
List CellRenderer Question
I have a list that will include a line of text and possibly an icon or two on each line (some lines have an icon or two, some don't). What I am currently doing is loading the appropriate image (a jpg or gif on the hard drive) as needed in the cellrenderer's setValue() into a MC with loadMovie(), then pushing the text over to the end of the icon. My problem right now is that the icon reports a 0 for _width after I load it, so that it overwrites the text on it's first rendering. It shifts correctly if the mouse passes over it. Is there some reason why the MC doesn't know it's width and height the first time you use it? It does render correctly.
Is there some preferred way to do this, or a tutorial to look at?
Also, how would you change the background of the List, like to use a jpeg or png?
Thanks!
Does CellRenderer Support Multiline/wrapText?
Editing a menu that suddenly had some very large list items added to it, and they're clipped. Trying to find the path of least resistance to make those objects multi-line wrapped text.
Anyone know?
Cellrenderer Doesn't Refresh Upon Scroll
I'm finding that the only way I can refresh a datagrid containing jpegs, rendered with cellrenderer, is by setting a scroll event on the datagrid, then resizing the column to the same value inside this event's function.
Is this a known problem?
CellRenderer €“ Class Returns An Undefined Value
I’m trying to display 3 lines in a list box. I have the code to render the cell but I can’t make it work. Can someone please help me determine why this code is not returning the correct value?
Class Code:
import mx.core.UIComponent
class HtmlLabelCellRenderer extends UIComponent
{
var label : MovieClip;
function HtmlLabelCellRenderer() {}
function createChildren(Void) : Void {
label = createObject("Label", "label", 1, {styleName:this, owner:this});
label.html = true;
label.multiline = true;
label.wordWrap = true;
size();
}
function size(Void) : Void {
label.setSize(__width, __height);
label._x = 0;
label._y = 0;
}
function setValue(str:String, item:Object, sel:Boolean) : Void {
//label._visible = (item!=undefined);
label.text = item.label;
}
function getPreferredHeight(Void) : Number {
return 18;
}
function getPreferredWidth(Void) : Number {
return __width;
}
}
TextArea In CellRenderer Doesn't Initialize
I'm new to AS3 so I'm not sure if this is something I'm doing wrong or a bug in the component...
I have a List component and I'm using a movieclip as a custom cellRenderer - it's class extends MovieClip & implements ICellRenderer. In this movieclip I'm trying to add a TextArea component to display some scrolling text. When I do this the textarea initially displays with no background or border - only the text is visible. The text is also the width of the default textarea, not the width I've specified, it overflows the textarea with no scrollbars, and it uses Times as it's font. In other words it's clearly not performing the initial arrangement/layout of the component's UI.
If I click in the textarea and try to edit the text it suddenly snaps into the proper layout - background and border appear, the size is correct, the font changes and the scrollbars appear - so something in the act of editing is triggering the arrangement which doesn't get performed initially.
I've tried this both with the component placed on stage in layout and added programmatically in AS with the same results. If I add it to the root level of the stage it works properly, but as soon as I use it in any way in the cellRenderer movieclip I get this odd behavior. Is there something I need to implement (a call or event maybe) in the constructor for my cellRenderer in order to trigger the initial layout of textareas in it?
Get Index Of The Button Inside CellRenderer
I have created many buttons inside the datagrid. Now when the user clicks on any button how can I know the index of the corresponding button.
I can get the index of the button in my CellRenderer.as file with
trace("Button index is:"+button_index);
function setValue(str:String, item:Object, sel:Boolean) : Void
{
button_index=item.lov;
button._visible = (item != undefined);
}
I just want the index of the cell where button was pressed in the datagrid.
If 3rd button is pressed, how can I get this info?
Thanks
CellRenderer MultiLineCell - Vertical Alignment
FIRST POST!!
I have been working with Flash for a couple of weeks now in an attempt to convert an asp.net webapp into a flash app. Not sure if it will be a solid replacement but i'm learning a lot about flash along the way.
I have implemented the CellRenderer to allow for multiple lines of text on select columns in my datagrid. My question is this:
If the text in a multilinecell does not need to be wrapped, how do i align the text in the middle of the cell. I am looking for some kind of vertical-align: middle but i've had no luck.
Maybe i'm missing something simple....
Hope i've been clear enough...
Thanks!!!
Cellrenderer / Radio Buttons Example Found
I was struggling this as were some of you from what I saw on the forum. Here is a good working example. I will post mine too if I get it working.
http://datadev.blogspot.com/2006/09/...onents-in.html
CellRenderer Problem With TileList Component
hi guys,
i have a problem with TileList component. (Flash CS4-AS3) i created a MovieClip then assigned to a class.
public class MyCellRenderer extends MovieClip implements ICellRenderer
Than i used it as CellRenderer of a TileList. There is 4 button inside of the MovieClip 1 of them at left side of MC others are rigth, top and bottom.
The problem is, left and right ones are working fine but top and bottom. I guess when i used it without cellrenderer there was a padding at the bottom of the columns, that's cause of this problem. So how can i fix that problem, anyone got any idea?
There is a SS for more info. sry for my bad eng. xD
[img=http://img530.imageshack.us/img530/2470/72512739vg1.th.jpg]
Code:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import fl.controls.listClasses.ICellRenderer;
import fl.controls.listClasses.ListData;
public class MyCellRenderer extends MovieClip implements ICellRenderer {
private var _listData:ListData;
private var _data:Object;
private var _selected:Boolean;
public function MyCellRenderer() {
}
public function set data(d:Object):void {
_data = d;
}
public function get data():Object {
return _data;
}
public function set listData(ld:ListData):void {
_listData = ld;
}
public function get listData():ListData {
return _listData;
}
public function set selected(s:Boolean):void {
_selected = s;
}
public function get selected():Boolean {
return _selected;
}
public function setSize(width:Number, height:Number):void {
}
public function setStyle(style:String, value:Object):void {
}
public function setMouseState(state:String):void{
}
}
}
DataGrid And CellRenderer To Use WordWrap Question
SORRY FOR MULTIPLE THREADS IN DIFFERENT SUBSECTIONS OF FORUM.
CSSS ActionScript 2.0 format question?
1. i want to use CSSStyle to format a DataGrid cell to allow wordwrap on one of the columns.
2. can someone plz point me in the right direction with code?
i have read so many tutorials, but i am not getting the idea to clearly. Here is MM's Document example:
.fla file
Code:
MenuBar: Insert -> New Symbol
Name: MultiLineCell
Behavior: Movie clip
Idenifier: MultiLineCell
AS 2.0 Class: MultiLineCell
Linkage: Export for ActionScript
Export in first frame
.fla file
Code:
grid.getColumnAt(0).cellRenderer = "MultiLineCell";
// POSSIBLE SOLUTION HERE, SEE THE END OF THREAD
.as file
Code:
class MultiLineCell extends mx.core.UIComponent
{
var multiLineLabel;// the label to be used for text
var owner;// the row that contains this cell
var listOwner;// the List/grid/tree that contains this cell
// empty constructor
function MultiLineCell()
{
}
// UIObject expects you to fill in createChildren by instantiating
// all the movie clip assets you might need upon initialization.
// Here, it's just a label.
function createChildren():Void
{
// createLabel is a useful method of UIObject--all components use this
var c = multiLineLabel = createLabel("multiLineLabel", 10);
// links the style of the label to the style of the grid
c.styleName = listOwner;
c.selectable = false;
c.tabEnabled = false;
c.background = false;
c.border = false;
c.multiline = true;
c.wordWrap = true;
}
// By extending UIComponent, you get setSize for free;
// however, UIComponent expects you to implement size().
// Assume __width and __height are set for you now.
// You're going to expand the cell to fit the whole rowHeight.
function size():Void
{
// __width and __height are the underlying variables
// of the getter/setters .width and .height
var c = multiLineLabel;
c._width = __width;
c._height = __height;
}
function getPreferredHeight():Number
{
/* The cell is given a property, "owner",
that references the row. It’s always preferred
that the cell take up most of the row's height.
*/
return owner.__height - 4;
}
function setValue(suggested:String, item:Object, selected:Boolean):Void
{
// Set the text property of the label
// You could also set the text property to a variable.
multiLineLabel.text = "This text wraps to two lines!";
}
// function getPreferredWidth :: only necessary for menu
// function getCellIndex :: not used in this cell renderer
// function getDataLabel :: not used in this cell renderer
}
my problem is that it will not do the wordwrap. plz, feel free to remove any of the garbage that is not needed in this code. all i want is to be able to do wordwrap on my cells for a certain column.
POSSIBLE SOLUTION IS TO ADD THIS LINE TO YOUR FLA AS2.0 CODE
yourdatagridinstance_dg.rowHeight = 80;
BUT IS THIS REALLY A SOLUTION?
thanx
iliad2b
CellRenderer + DataGrid + RollOverItem Event
I have a custom cellRenderer which contains a customButton in a DataGrid. I would like for the DataGrid item to roll over when I roll over the customButton in that item's cell.
Can I sync the events? Can I trigger the list.rollOverItem event from withing the custom cellRenderer?
Thanks much for any input.
Jim
Cellrenderer Stuff Dont Hide
ok nevermind its the loadMovie() in the imageCellrenderer setValue function...i guess it needs to go in createchildren
Great Confusion Combining Tree Component W/cellRenderer...
My goal is to have a tree menu where the text for each item gets wrapped over two lines. I have done a lot of reading on cellRenderer and MM's MultiLineCell class, and have succeeded in adding multiline capability to a List box component -- but so far, getting it to work properly with the Tree component has brought me nothing but frustration.
After inserting the necessary code, I can verify that the methods of MultiLineCell are indeed being called (and its listOwner does point to the tree) but three very important (and presumably connected) things keep going wrong:
1) The constructor and setValue() methods keep being called over and over again in an unending loop. (Without the cellRenderer/MultiLineCell code, processor use is much less, so there doesn't appear to be any loop in the rest of my code that could be causing this.)
2) The string that is passed to setValue() is always empty. However, even if I hardcode some text to pass directly to multiLineLabel.text, that text never makes it into the tree's rows.
3) Finally, the tree's rows are all blank! (Though they are still clickable and function properly -- they just have no text. I should point out that if I remove all references to cellRenderer/MultiLineClass, the appropriate text is there.)
I have noted that it makes no difference whether I define the connection with the cellRenderer from the outset:
Code:
tSideNav = mainContainer.createClassObject(Tree, "tSideNav", 2,{rowHeight : 38, cellRenderer : "MultiLineCell" });
or after the tree has been fully instantiated:
Code:
_level0.mainGBL.tSideNav.cellRenderer = "MultiLineCell";
If anyone has any suggestions, please don't hold back!
Many thanks,
James
|