Class custom CellRenderer?

I tried to implement a cellrenderer class customized to my list in AS3 component in Flash CS3.

Here's what I have in the FLA.

import flash.display.MovieClip;
Import fl.controls.List;

Stop();

var cr:customRenderer = new customRenderer();

lstTest.setStyle ("cellRenderer", RC);

lstTest.addItem({label:"Jeff"});)

lstTest.addItem ({label: "Ben"})

Where lstTest if the instance of the component list on the stage.

Here's my customRenderer class.

package

{

Import fl.controls.listClasses.CellRenderer;

import flash.text.TextFormat;

public class customRenderer extends CellRenderer

{

public void customRenderer()

{

var newFormat:TextFormat = new TextFormat ("Arial", 12, 0x00FF00);

setStyle ("textFormat", newFormat);

}

}

}

When the custom converter is applied to the list item the single cell that is rendered with the new new font and color is the last one added to the component. The other is appear not at all. If I click on the cell showing that I get and error of the list item.

Can you see what I'm doing wrong with this custom cellrenderer class?

use:

Stop();

lstTest.setStyle ("cellRenderer", customRenderer);

lstTest.addItem({label:"Jeff"});)

lstTest.addItem ({label: "Ben"})

Tags: Adobe Animate

Similar Questions

  • Nasty problem with resizing a list and a class custom CellRenderer

    Create a list (_myList) in a class with a custom CellRenderer class. In the custom CellRenderer class, I draw a rectangle with a gradient in the data() function:

    override public function set data (value:Object) : void
    {
        super.data = value;
    
        var tab_color:Array = this.data.rowColor;
        ...
        _matrix.createGradientBox(this.width, this.height, 90/180*Math.PI);
    
        with (_sprTab.graphics)
        {
            clear();
            beginGradientFill(GradientType.LINEAR, [tab_color[0], tab_color[1], tab_color[2]], [alpha,alpha,alpha], [0,127,255], _matrix);
            drawRoundRectComplex(0, 0, this.width, this.height, 15, 0, 15, 0);
            endFill();
        }
        ...
    }
    

    When policy changes I want to resize the list. Therefore, in a function in the class in which the list is created, I resize the list:

    public function setListSize (w:Number, h:Number) : void
    {
        _myList.setSize(w, h);
    }
    

    And this function is called with the new dimensions on the change of orientation in the main class.

    However, this.width in the custom CellRenderer class does not get the new width of list a reason any.

    No idea why?

    You must refresh the visible items in the list. You can loop through the list and replaceItem (...) of the call and who should do it. You can check that it would work by scrolling through the list of invisible items and they should have picked up the new width.

  • Shared Object storage class custom?

    Hello all, forgive me if this is a really stupid question, but a SharedObject can be stored on an instance of a custom class, or it can store data types (for example, int, String, tables, etc.)? I thought it would be able to accept classes custom, but I now get some strange errors when you try to access the data stored in the custom on the SharedObject class... so it made me think twice.

    Essentially, what I'm trying to do is create a game, which can have up to 8 save files. To do this, I created a custom "GameSave" class that contains all relevant data and a class 'SaveManager' that keeps track of all 8 stops and stores them in a table on a SharedObject. When I run the game I can record the data, load again, etc., but when I close the game, then open I can't access the same data I have a few moments before... Very strange!

    Thanks in advance for any help with this one

    For complex data types, you must use the registerClassAlias() method. There are many examples on the Internet how to do this.

  • Creating instances of the class customized for XML nodes

    Hi guys,.

    I'm trying to load an external XML document in my application and create an instance of a custom class for each node in the XML file based on the value of some of their elements. Instances created later will end by in a DataGrid by the way. The problem I have is there seems to be several ways to make small parts of it and I have no idea how do them all gel. Initially, I use HTTPService to load the XML file, but I've seen people just use a XML object. Then, after that, I put the XML loaded to an ArrayCollection collection initially, but others used XMLList or XMLListCollection. I have no idea of what is the best way to do it.

    Finally, when I created all of these instances by looping through XML and their creation how I'll make them bindable to the DataGrid? I guess I'll have to group together them somehow...

    Any help would be greatly appreciated. Thank you

    Create a class customized for your 'point' of dataGrid dataProvider objects
    * Use HttpService to get the XML code.
    * use an e4x expression for the child nodes of the xml in an XMLList: myXML.children () or myXML.myNodes;
    * use a for loop on the XMLList
    * inside of the loop, create a new instance of the custom class
    * Of the [i] myXMLList, obtain all necessary attribute values and assign them to the appropriate properties in the instance of the custom class.
    * always inside the loop, use myArrayCollection.addItem (mycustomClass) to add the element to the collection of the dataProvider ArrayCollection.

    Tracy

  • TileList only keeping not with class data order custom CellRenderer

    Hi all

    I was hoping that you guys could help me with this, I did a search and nobody seems to know the same problem.  So first the installer: I have a TileList component set in place with a line in.  The TileList component using a custom class that extends the CellRenderer class to view its data. The problem is that if I scroll so the first element is not visible, in addition, its value is replaced by another item in my dataProvider.

    Here is my code for the CellRenderer class (where I am assuming that the problem):

       public class MyRenderer extends CellRenderer
        {
            private var renderer:MyDataDisplay = new MyDataDisplay();
            public function MyRenderer()
            {
                super();
            }
    
            override protected function onAdded():void{
                super.onAdded();
                addChild(renderer);
            }
    
            override protected function onRemoved():void{
                super.onRemoved();
                removeChild(renderer);
            }
    
            override protected function drawLabel():void{
                super.drawLabel();
                if(data){
                    renderer.title.text= data.name as String;
                    renderer.date.text = data.date as String;
                }
            }
    

    Help?

    Hey cyangreen,

    lists and cell renderers are the heels of achilie of the QNX API when it comes for them to find haha. and once you think u he descended, something unexpected happens and you have to change once again lol.

    I met problems here and there, and usually when you define the data and what not, I substitute the public data() setter. like this I get accurate results. the list and CellRenderer do things funky sometiems and get weird to read outs. so try to do this and see if it changes anything. So instead of override the drawLabel() method, replace the set data() accessor:

    override public function set data(data:Object):void
    {
        super.data = data;
    
        if (data.name && data.data)
        {
            renderer.title.text= data.name as String;
            renderer.date.text = data.date as String;
        }
    }
    

    Let me know how that turns out. If it doesn't work, let's try something else. Good luck!

  • Custom CellRenderer class

    I have a qnx.ui.listClasses.List with a custom made cell that contains a check box as in the example "Creating a custom list" here:

    http://docs.BlackBerry.com/en/developers/deliverables/23959/Creating_a_custom_list_1446778_11.jsp

    After setting the skin with:

    myList.setSkin(MyCustomCellRenderer);
    

    Is there anyway to access the checkbox to select or deselect without actually clicking on the check itself? When a control is clicked, it sends an event through specific cell renderer.

    The closest I found is List.firstVisibleItem and List.lastVisibleItem but these are not constant during execution.

    What I want to do is to loop over a list that contains boxes check after loading the xml data and select or deselect the item in the list.

    Any help would be greatly appreciated.

    Too bad. I thought about it. You can override the data function defined as follows.

    override public function set data(data:Object):void{    super.data = data;    check.selected = MyObject( data ).Selected;}
    
  • Skin class customized for the element of the ADF.

    Hi all

    I use jdev 11.1.1.5.0 version

    I create a skin (css) for my adf application.

    where I set my table adf column property.

    af|column::column-header-cell {
        background-image: url("../images/yellow_bg2_rep.jpg");
        background-position: center center;
        background-repeat: repeat-x;
        color: #C4112F;
        font-size: 12px;
        font-weight: bold;
        height: 25px;
        /*    line-height: 29px; */
        /*    padding: 5px 15px; */
    
    
        border-right: 1px inset #8C8E95;
        background-color: transparent;
    }
    
    

    and is applied to all components of adf table exist on request. but my question is I want to set a different style for different table not even for all the table.

    So how can I achieve this.

    any Suggestion?

    Thank you

    Manish

    Hello

    You can create named style classes and set the table accordingly styleClass property.

    Ex:
    .table1Style af | : column-to-head-cell {}

    }

    .table2Style af | : column-to-head-cell {}

    }

    and then set the table/column accordingly styleClass property.

    Arun-

  • SWF cannot find classes custom after edition...

    Hello world

    So it's probably an easy thing, I don't know, I hope.

    But when I publish my project and test it in a normal HTML tag, the swf file can find some classes, but not other reason any?

    How can I make sure that all the classes to get compiled into the Swf file?


    I got the main script, call the first class (CalypsoPlayer); and she finds this class find - located under the same path of class.

    But CalypsoPlayer can't find the class, he needs, even if it is in the class path as well as the class.

    I tested the project in Flash itself and everything works fine without any errors, so I don't know what is happening.  It's only when I test

    the published SWF that it cannot find all the classes it needs.

    I thank anyones help -Stan

    If your swf file is running when you test it in Flash so it should work when it is as well to other places.  All classes and the script are compiled into the swf.

    When you say that "it's only when I test the published SWF that it cannot find all the classes he needs."

    When you test it?

  • The class call Java Custom WCC?

    How to call a Java class customized WCC when a certain field of metadata is set on "On" and at the time of check-in?

    Thank you

    Randy

    Randy,

    You would control this logic within your code for FilterImplementor.

    Retrieve you the values of metadata fields and if they meet the criteria, continue with your custom logic. If not, go back and do nothing.

    Jonathan

    http://jonathanhult.com

  • Add a custom class to display the list

    Hello

    IM new in flex.

    In a mobile project from flex im tryin to add my class custom in my opinion:

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:fx s:View ' http://ns.Adobe.com/MXML/2009 "
    xmlns:s = "library://ns.adobe.com/flex/spark" title = "HomeView" creationComplete = "complete (event)" >
    < fx:Script >
    <! [CDATA]
    import of GridView;
    import the model;

    Import mx.events.FlexEvent;

    private var grid: GridView
    private var: model

    protected function complete(event:FlexEvent):void {}
    model = new modele()
    grid = new GridView (model)
    gr.contentGroup.addElement (grid)

    }

    []] >
    < / fx:Script >
    < fx:Declarations >
    <! - Place non-visual elements (e.g., services, items of value) here - >
    < / fx:Declarations >
    < s:BorderContainer id = "gr" >

    < / s:BorderContainer >

    < / s:View >

    but I get this error:

    1067: constraint implied a value of type: GridView to a type unrelated to mx.core:IVisualElement.

    is not possible to add a pure actionscript class?

    Thank you very much

    Probably your GridView class does not implement the IVisualElement interface. UIComponent implements this interface. I recommend you create a UIComponent, which add to the BorderContainer and then add your GridView to the UIComponent.

    In addition, do not add the UIComponent to contentGroup of the BorderContainer. Just add it directly to the BorderContainer.

    var uic:UIComponent = new UIComponent();

    gr.addElement (uic);

    uic.addChild (grid);

    Jason

  • A custom object to access class instance to the

    I created a few (TextInput, ComboBox, CheckBox) instances of the component (created as a public objects) in a Document class and added to the scene.

    Now, I created a class customized to a movieclip in the library and instantiated in the class of document (also a public proceeding).

    I need to access instances of the component in the custom class. How to do this?

    Also, it is advisable to use the ENTER_FRAME event frequently? because if I can't access the instances of components in the custom class above then I will remain no other choice than to use ENTER_FRAME event in the document class whenever I have to change a value in the components...

    So, is this a good practice?

    I think you're overloading the things why don't you just leave your document class adds a TextInput, and your button as his children? Then you can access both of them the class of document with ease.

  • Custom button class WordWrap

    Someone knows how to make text wrap to a custom button class? I tried everything (as you can see below)! I even tried the Flexlib CanvasButton class, but not really sure how to apply only to one class custom. BTW, these buttons are inside a TileList component if that makes a difference... I love Flex but sometimes its really simple things that you SHOULD be able to easily do that just drive me NUTS!

    Thanks in advance!

    -Mike

    package action.button
    {
    import flash.display. *;
    import flash.events. *;

    Import mx.controls.Button;
    Import mx.controls.listClasses.BaseListData;
    Import mx.controls.listClasses.ListData;
    Import action.button.NoTruncationUITextField;
    Import mx.core.UITextField;
    Import flexlib.controls.CanvasButton;

    SerializableAttribute public class ButtonCatSearch extends button
    {
    private var _baseListData:BaseListData;
    private var _listData:ListData;
    private var _label:String ="";

    public void ButtonCatSearch()
    {
    Super();
    the cursor always behave as if it were a button
    mouseChildren = false;
    buttonMode = true;
    useHandCursor = true;
    height = 150;
    width = 20;
    setStyle ("paddingLeft", 50);
    setStyle ("paddingRight", 50);
    setStyle ("paddingTop", 50);
    setStyle ("paddingBottom", 50);

    setStyle("horizontalGap",100);
    setStyle ("wordWrap", true);

    wordWrap = true;

    addEventListener (MouseEvent.MOUSE_DOWN, onButtonClick);

    }
    public void onButtonClick(e:Event):void
    {
    _label = e.target.label;

    }
    //----------------
    to return to the line
    for button
    override protected function createChildren() (): void
    {
    Create a UITextField to display the label.
    If (! textField)
    {
    textField = new UITextField();
    textField.styleName = this;
    addChild (DisplayObject (textField));
    }
    super.createChildren ();
    textField.multiline = true;
    textField.wordWrap = true;

    super.createChildren ();
    }
    //-----------------
    override public function get listData (): BaseListData
    {
    Return _baseListData;

    }

    /**
    * @private
    */
    override public function set listData(value:BaseListData):void
    {
    super.listData = value;
    _baseListData = value;
    _listData = _baseListData as ListData;
    }
    //-----------------
    override public function set data(value:Object):void
    {
    / * If {(_listData)
    If {(_listData.icon)
    this.setStyle ("icon", _listData.icon);
    }
    }
    */

    Super.Data = value;
    setStyle ("wordWrap", true);
    }
    //-------------------------
    override the updateDisplayList(unscaledWidth:Number,_unscaledHeight:Number):void function
    {
    super.updateDisplayList (unscaledWidth, unscaledHeight);


    this.textField.multiline = true;
    this.textField.wordWrap = true;

    Data.@price < = 0)? NEGATIVE_COLOR: POSITIVE_COLOR);
    }
    }
    }

    You need to replace [] Measure to get the correct behavior. By default, the button sets the width of the TextField child. What you want is for the width of the TextField to be limited by the width of the button and the button height to vary the height measured from the TextField object.

    I had a quick go at below, but it will probably need more work. I used the example of radio button Alex Harui multiline as a starting point:

    http://blogs.Adobe.com/aharui/2007/04/multiline_buttons.html

    ------------------------------------------------

    package
    {
    import flash.display.DisplayObject;
       
    Import mx.controls.Button;
    Import mx.core.IUITextField;

    SerializableAttribute public class WordWrapButton extends button
    {
    Protected Overrides function createChildren() (): void
    {
    If (! textField)
    {
    textField = IUITextField (createInFontContext (UITextFieldNoTruncation));
    textField.styleName = this;
    addChild (DisplayObject (textField));
    }
               
    super.createChildren ();
               
    textField.multiline = true;
    textField.wordWrap = true;
    }
           
    Override protected function [] Measure: void
    {
    If (isNaN (explicitWidth) is false)
    {
    textField.text = label;
                   
    textField.width =
    explicitWidth-
    Value ("paddingLeft")-
    Value ("paddingRight");
                       
    measuredHeight =
    textField.getExplicitOrMeasuredHeight () +.
    Value ("paddingTop") +.
    Value ("paddingBottom");
    }
    on the other
    {
    Super.Measure ();
    }
    }
           
    override protected function updateDisplayList)
    unscaledWidth: unscaledHeight, number: number): void
    {
    super.updateDisplayList (unscaledWidth, unscaledHeight);
               
    () textField.setActualSize
    textField.width,
    textField.getExplicitOrMeasuredHeight ());
               
    textField.move (textField.x, value ("paddingTop"));
    }
    }
    }

    ------------------------------

    package
    {
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
       
    Import mx.core.UITextField;

    SerializableAttribute public class UITextFieldNoTruncation extends UITextField
    {
    Public Overrides function truncateToFit (truncationIndicator: String = null): Boolean
    {
    Returns false;
    }
    }
    }

    ------------------------------


    <>
    "xmlns:MX ="http://www.adobe.com/2006/mxml"
    Layout = "vertical".
    "xmlns:local =" * ">
       
        <>
    Width = "50".
    label = "A very long label I want the button to encapsulate" / >

    <>
    Width = "100".
    label = "A very long label I want the button to encapsulate" / >

    <>
    Width = "200".
    label = "A very long label I want the button to encapsulate" / >

    <>
    Width = "300".
    label = "A very long label I want the button to encapsulate" / >

    <>
    Width = "400".
    label = "A very long label I want the button to encapsulate" / >

  • To access the event listeners in the custom class

    I am a construction and film using the classes customized for the first time. I built a custom class and bound a clip in my film for her so that the color of the text in the video will change when he is overthrown. I have 10 occurrences of this clip in the film, so it saves me a lot of code. Instead of writing 10 to ROLL_OVER event listeners and 10 more for ROLL_OUT (as I have done in the past), one for each instance of the clip on the scene, I wrote now event listeners and the corresponding functions in the custom class. So far, so good, everything works fine. When I ride above and outside on one of the 10 instances of the clip on the stage it changes color. See code attached.

    However, according to what is happening in the film, that I sometimes need to turn off the headphones of events on one or more video clips. So, I wrote the code in the movie itself to remove event listeners of the instance of the clip that I need to disable. See code attached.

    But, alas, it does not work.

    I get this error:
    ReferenceError: Error #1065: Variable turnWhite is not defined.

    I thought that by the 'public' method in the custom class, I would be able to call from the film, but I do not. Any help or advice would be greatly appreciated. Thank you very much.

    Ned, thanks for your help. I was able to understand. Your code has been helpful, and I've used something similar to what you suggested.

  • Custom component classes

    Hi all

    I learned flex a few months now and absolutely love it!
    But there is one thing that I can't get my head round. I use mostly for a Flash user, which is probably why I'm confused...
    I want to be able to make custom components that use a custom class.
    For example, I have the canvas custom components that are 'pages' that I'm loading dynamically if necessary. When they do, I want that they fade by using the fade effect. So far, I wrote the code to do this on each component, which is quite annoying because I have a lot of pages.
    I would like a custom class with the code in it for the bland, whose each component uses "page", so each will fade when loading.
    I have this could very easily using clips in flash, but flex looks different. Maybe I'm confused in what concerns paintings and MovieClips.

    Please can someone help me? :)

    You can do this one of two ways

    If your base class "custom components" is a canvas you can tell



    or you can just create a custom catalog as _funkyboy DESCRIBED, and then create instances of it as you normally would for other tags mx. Flex builder should be smart enough to put in all of the import statements if you don't understand how

    Hope this has helped

    -A

  • A loop in the properties of a custom class

    Hello

    I have a class with a number of properties that are of different types (String, Array, class custom, etc.). I want to be able to loop tthrough each of these properties. I tried the following code:

    var testObj:myClass = new myClass();
    for each {(element var testObj)
    trace (element);
    }

    I looked in the debugger, and it does not go inside the loop "foreach". I made a mistake, or is there another way to do it?

    Thank you very much in advance for any help

    Pierrot

    Who will work for the (associative) dynamic properties, but will not work
    for the properties of the class.

    For the properties of the class, you will need to use something like this:

    import flash.utils. *;
    function getObjectPropertyNames(o:*):Array
    {
    var result: Array = new Array();
    var t:XML = flash.utils.describeType (o);
    var l:XMLList;
    If (o is Class) {l = t.factory.accessor ;}
    else {t = t.accessor ;}
    var node: XML;
    for each (node in l)
    {
    result.push ([email protected] ())
    }
    return the result;
    }

    var testObj:myClass = new myClass();
    the accessories of the var: Array = getObjectPropertyNames (testObj);

    Dynamic properties
    for each {(element var testObj)
    trace (element, testObj [element]);
    }
    Properties of the class
    for (var i: int = 0; i
    trace (props , testObj [accessories]);
    }

Maybe you are looking for

  • Satellite 1800-400: How do I install the driver for graphics card

    Hello As I mentioned in the topic I downloaded a graphics card driverhttp://be.computers.Toshiba-Europe.comfor my Satelitte 1800-400. The problem is that the Once unzipped downloaded zip file does not contain a Readme with some information or an .exe

  • Problem with XControl and remote debugging

    Can you make a connection of remote debugging to an EXE or DLL that uses an XControl?  So far, my experiences would indicate the answer is no, but I find that surprising and have seen no earlier mention of it in bug reports or in the forums.  When tr

  • simultaneous editing with a shared parameter

    Hello I have two sets of data with the same X series such as (X, Y1) and (X, Y2). I have a model function y = f(x,a) with four parameters. What I'm trying to do, it is to adapt to these two sets of data for the model at the same time function for a s

  • Received a hoax call

    I just had a phone call form a woman saying she was from windows and I had a virus that she was going to look on and she asked me click on the letters on the key board so I started to do they were (event) or something like that but then I started to

  • No sound after installation

    Original title: sound I have windows 7 professional service pack 1, I recently installed. There is no audio drivers. How can I get them? My system is intel Pentium Dual - core E5200, 2.5 GHz.