7 Replies Latest reply on Jun 1, 2009 11:17 PM by maestro91

    [Newbie Q] Error #1061 calling custom component function

    maestro91

      Hello, i'm trying to call a public function defined in a custom component from main application, obtaining 1061 error...

       

      Here is the relevant code

       

      /* generator.mxml */

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
          applicationComplete="_init();"
          xmlns:my="*"
          xmlns:mx="http://www.adobe.com/2006/mxml"
          layout="absolute"
          width="875"
          height="635">
      <mx:Script source="generator.as"/>
      ...........................
      ..........................
      <mx:VBox>
                      <mx:Panel width="658" height="185" layout="vertical" title="Banner" id="pnlBanner" horizontalAlign="center" verticalAlign="middle">
                      </mx:Panel>
                      <my:elementList />
                  </mx:VBox>
              </mx:HBox>              
          </mx:Canvas>
      </mx:Application>

       

      /* generator.as */

      ...........................
      ..........................
      private function imageHandler(event:Event):void {
          aImage = new Image();
          aImage.source=img._imgTmp.source;
          aImage.maintainAspectRatio = false;   
          aImage.id="0";
          aImage.x=0;
          aImage.y=0;
          aImage.width=img._imgTmp.width;
          aImage.height=img._imgTmp.height;
          pnlBanner.rawChildren.addChild(aImage);
          elementList.addElement('image', aImage);
      }
      ...........................
      ..........................

      /*elementList.mxml*/

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TileList xmlns:mx="http://www.adobe.com/2006/mxml"
           creationComplete="init();"
           click="clickElement(event);"
           dragComplete="dragElement(event);"
            allowMultipleSelection="false"
            dragMoveEnabled="true"
            dropEnabled="true"
            dataProvider="{cllElements}">
      <mx:Script source="_elementList.as"/>
      </mx:TileList>

      /*elementList.as*/

      // ActionScript file
      import flash.events.Event;
      import mx.collections.ArrayCollection;
      private var arrElements:Array= new Array();
      [Binding]
      private var cllElements:ArrayCollection= new ArrayCollection(arrElements);
      ................................
      ................................
      public function addElement(type:String, obj:Object): void {
          cllElements.addItem(obj);
      }
      ................................
      ................................

       

      I obtain a compile time error #1061 Severity and Description    Path    Resource    Location    Creation Time    Id
      1061: Chiamata a un metodo non definito addElement mediante un riferimento con tipo statico Class.    generator/src    generator.as    line 65    1243862469015    1900

      Sorry for the Italian, BTW the error is in the red line on generator.as file.

      Any idea would be really apperciated, because it's hours that i try to guess the reason....