Categories
Flex How to

How to dynamically add attributes and child nodes to an XML element in Flex

This is how I copied all the attributes of an XML node (srcXMLNode) to another XML node (dstXMLNode) in Flex, without knowing the names of those attributes:

for each(var attr:XML in srcXMLNode.attributes())
{
dstXMLNode.@[attr.name()] = attr;
}

And this is the way I added child nodes of an XML element to another:

for each(var elem:XML in srcXMLNode.elements())
{
dstXMLNode[elem.name()] = elem;
}

If you know a better way to do this, feel free to write a comment.

Categories
ActionScript Flex

1144: Interface method set data in namespace is implemented with an incompatible signature in class .

Full error message: 1144: Interface method set data in namespace is implemented with an incompatible signature in class.

<package:class><mypackage:myclass></mypackage:myclass></package:class>

This error appears in Flex Builder / Eclipse on the Problems Tab.This error refers to the fact that an extended class named <package.class> with an over ridable function has a correspondent override in <mypackage:myclass> that doesn’t match the overrided function. To be more specific i’ll give you an example:
Let’s say we want to create a custom data grid header renderer and in order to do this we will create a class VerticalHeaderRenderer that will extend DataGridItemRenderer. In the class VerticalHeaderRenderer we will override the setter function for the data property like this:

override public function set data(value:Object):void{
local_var = value.toString();
}

This is the correct version and it will not give the error mentioned in the title but if we have a function that has a parameter of a different type then Object or a different return type we will receive the error.

Basically this error tells us that we are trying to override a function with different parameters or different return value type. So to escape this error you must ensure that the override is made correctly.

Hope this helps.

Good luck.