Error sending object from ArrayCollection to instance of my custom class

I am using Flex 4 and for some reason I cannot get the following code to work that happens inside the ListEvent handler for dataGrid:

_tempRule = DataGrid(event.currentTarget).selectedItem as Rule;

A rule is a custom class, and the above code always returns null. The dataprovider for a datagrid is an ArrayCollection. If I try to wrap the above code, do the following:

DataGrid(event.currentTarget).selectedItem as Rule

I get this error:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@e15a971 to com.mycompany.arcc.business.Rule

Now I know that I did this before with native Flex classes such as Button, etc., but this is my case, this will not work.

Here is the rule class:

    package com.mycompaany.arcc.business
{
    import flash.utils.describeType;

    import mx.collections.ArrayCollection;

    [Bindable]
    public class Rule extends Object
    {
        public static const RANGE:String = "Range";
        public static const SINGLE:String = "Single";
        public static const LIST:String = "List";

        /*name of the rule*/
        private var _name:String;

        /*rule group, like a radio group, only 1 rule from a group can be selected*/
        private var _group:String;

        /*Description of the group for the rule*/
        private var _groupDescription:String;

        /*Description of the rule*/
        private var _description:String;

        /*arry of values for this rule, based on the control type*/
        private var _values:ArrayCollection;

        /*min num of values*/
        private var _numValues:int;

        /*type of control to build, if range, 2 inputs, single, 1 , list 1 or more*/
        private var _type:String;

        public function Rule(name:String=null, group:String=null, description:String=null, values:ArrayCollection=null, numValues:int=0, type:String=null)
        {
            super();
            _values = new ArrayCollection();

            this._name = name
            this._group = group;  
            this._description = description;
            if (values)
            {
                this._values = values;
            }
            this._numValues = numValues;  
            this._type = type;  
        }


    }
}

So what am I missing?

+3
source share
2 answers

, [RemoteClass] . - Adobe, liveocs.adobe.com/flex/3/html/.... , drag and drop . .

+2

errormessage . ,

Rule((event.currentTarget).selectedItem);

, , BR

+1

Source: https://habr.com/ru/post/1788386/


All Articles