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

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

Explorer ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

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

Views

1.3K

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi.

 

How are you calling the init method?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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
                  });

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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();

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

 

 

Votes

Translate

Translate

Report

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