MXML composite canvas component initialization error

Posted by mkorpela on Stack Overflow See other posts from Stack Overflow or by mkorpela
Published on 2010-04-16T19:17:11Z Indexed on 2010/04/16 19:43 UTC
Read the original article Hit count: 420

Filed under:
|

I'm getting an odd error from my composite canvas component:

 An ActionScript error has occurred:
  Error: null
at mx.core::Container/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Container.as:2560]
at -REMOVED THIS FOR STACK OVERFLOW-.view::EditableCanvas/initialize()[.../view/EditableCanvas
    ....

It seems to be related to the fact that my composite component has a child and I'm trying to add one in the place I'm using the component. So how can I do this correctly?

Component code looks like this (EditableCanvas.mxml):

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="{init()}">
<mx:Script>
    <![CDATA[
        private var _editable:Boolean;

        public function set editable(edit:Boolean):void {
            _editable = edit;
        }

        private function init():void {
            if(_editable){
                addEventListener(MouseEvent.MOUSE_OVER, showEdit);
                addEventListener(MouseEvent.MOUSE_OUT, hideEdit);
            }  
        }

        private function showEdit(event:Event):void {
            editTextImage.visible = true;
        }

        private function hideEdit(event:Event):void {
            editTextImage.visible = false;
        }
    ]]>
</mx:Script>
<mx:Image id="editTextImage"
            source="@Embed('/../assets/icons/small/process.png')"
            click="{dispatchEvent(EditPoiEvent.text())}"
            visible="false"/>
</mx:Canvas>

The code that is using the code looks like this:

<view:EditableCanvas
            width="290" 
            height="120" 
            backgroundColor="#FFFFFF" 
            horizontalScrollPolicy="off" 
            borderStyle="solid" 
            cornerRadius="3"
            editable="{_editable}">
            <mx:Text id="textContentBox" width="270" fontFamily="nautics" fontSize="12" text="{_text}"/>
</view:EditableCanvas>

© Stack Overflow or respective owner

Related posts about mxml

Related posts about flex