Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

TypeError: Error #1006: myDCLS is not a function.

Explorer ,
May 07, 2020 May 07, 2020

I'm trying to access function located in DCLS class from my Pieces class.

Pieces:

  public class Piece extends Sprite
   {
      private var image:Bitmap; 
      private var obj:Object;
      private var gap:Number = 30;  
    
      public function Piece()
      {
         super();
      }
      
      public function init($obj:Object) : void
      {
        this.obj = $obj;
        //taking valuse from my DCLS class works fine
	totalPieces = this.obj.horizontalPieces * this.obj.verticalPieces;
	//here I'm getting error #1006
        this.obj.myDCLS(); 
        

myDCLS function located in DCLS class:

	  public function myDCLS(){
		  //var mycount:int = count;
		  //foundPiecesDCLS++;
		  trace("test");
	  }
TOPICS
ActionScript , Code , Error , How to
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2020 May 07, 2020

Hi.

 

How are you calling the init method?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 07, 2020 May 07, 2020

I do it like that:

pieceGuid = new Piece();
                  showGuidCon.addChild(pieceGuid);
                  pieceGuid.init({
                     "image":nowbitmap.bitmapData,
                     "i":i,
                     "j":j,
                     "tileObj":piecesArray[i][j],
                     "horizontalPieces":horizontalPieces,
                     "verticalPieces":verticalPieces,
					  "foundPiecesDCLS":foundPiecesDCLS,
                     "crop":{
                        "x":i * pieceWidth,
                        "y":j * pieceHeight,
                        "width":pieceWidth,
                        "height":pieceHeight
                     },
                     "x":i * pieceWidth + i,
                     "y":j * pieceHeight + j,
                     "width":pieceWidth,
                     "height":pieceHeight,
                     "draggable":false
                  });
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2020 May 07, 2020

Thanks.

 

You need to pass an instance of the DCLS class to the init method object you're using as an argument. Something like this:

pieceGuid.init({dLCSInstance:yourDLCSInstance});

// ...

this.obj.dLCSInstance.myDCLS();

 

Or if you don't want/need to instantiate the DCLS class, mark the myDCLS method as static. Like this:

public static function myDCLS():void
{
}

 

Then call the myDCLS method like this:

DCLS.myDCLS();

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 07, 2020 May 07, 2020

Static method does work, but now I'm getting undefined property or method errors (1180 and 1120 messages).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2020 May 08, 2020
LATEST

When I pass instance to the init method I get: mySwf.swf contains invalid data.
at DCLS()

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines