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

error 1180

New Here ,
Jul 16, 2011 Jul 16, 2011

the code below is trying to generate a raw object, duplicate it n times and, replace it in a different random position

so i made the code in this way:

var dustRaw:MovieClip;
var dust:MovieClip;

function dustRawGen() {
    dustRaw.graphics.beginFill(0xFF0000);
    dustRaw.graphics.drawEllipse(0,0,1,1);
    dustRaw.graphics.endFill();
}

function dustGen() {
    for (var i:int = dustArray.length; i<=dustCount-1; i++) {
        dust = new dustRaw();
        addChild(dust);
        dust.x = Math.random() * (rBound-lBound) + lBound;
        dust.y = Math.random() * (dBound-uBound) + uBound;
        dustArray.push(dust);
        tailArray = new Array();
    }
}

dustRawGen();

dustGen();

but when i test it, there is an error on the bolded line

1180: Call to a possibly undefined method dustRaw.

did anyone know why?

thanks for any help

TOPICS
ActionScript
1.1K
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

correct answers 1 Correct answer

Community Expert , Jul 17, 2011 Jul 17, 2011

if dustRaw is an ellipse creating class, you would use it from another class.  for example, if you want to use it from the dustGen class:


// dustRaw.as:

package{
     import flash.display.MovieClip;
          class dustRaw extends MovieClip {
              public function dustRaw(){
                   graphics.beginFill(0xFFFFFF);
                   graphics.drawEllipse(0,0,15,15);
                   graphics.endFill();
          }

     }

}

// dustGen.as:

package{

import dustRaw;

public class dustGen{

private v

...
Translate
Community Expert ,
Jul 16, 2011 Jul 16, 2011

you don't hav a dustRaw class in that scope.

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
New Here ,
Jul 17, 2011 Jul 17, 2011

oic, then i rewrite it so the code becomes:

class dustRaw extends MovieClip {
    graphics.beginFill(0xFFFFFF);
    graphics.drawEllipse(0,0,15,15);
    graphics.endFill();
}

function dustGen() {
    for (var i:int = dustArray.length; i<=dustCount-1; i++) {
        dust = new dustRaw();
        addChild(dust);
        dust.x = Math.random() * (rBound-lBound) + lBound;
        dust.y = Math.random() * (dBound-uBound) + uBound;
        dustArray.push(dust);
        tailArray = new Array();
    }
}

but why later it gives me error 1131 which says "Classes must not be nested."


i never nested classes above...

thanks for helping again

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 ,
Jul 17, 2011 Jul 17, 2011

that code must be a snippet because it makes no sense as written.

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
New Here ,
Jul 17, 2011 Jul 17, 2011

sorry but i dont understand because i am a beginner only...

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 ,
Jul 17, 2011 Jul 17, 2011

there are so many problems with that code there must be more to that class file.  the first error is in line 1, there's no package specified.

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
New Here ,
Jul 17, 2011 Jul 17, 2011

sorry can you demonstrate for me?

because i am learning as3 by CIB and "Programming actionsctipt 3.0" only

i took reference from CIB and converted the codes.

package{
     import flash.display.MovieClip;
          class dustRaw extends MovieClip {
              public function dustRaw(){
                   graphics.beginFill(0xFFFFFF);
                   graphics.drawEllipse(0,0,15,15);
                   graphics.endFill();
          }

     }

}

function dustGen() {
    for (var i:int = dustArray.length; i<=dustCount-1; i++) {
        dust = new dustRaw();
        addChild(dust);
        dust.x = Math.random() * (rBound-lBound) + lBound;
        dust.y = Math.random() * (dBound-uBound) + uBound;
        dustArray.push(dust);
        tailArray = new Array();
    }
}

then the compiler gave me such error:

Scene 1, Layer 'actions', Frame 1, Line 128    1083: Syntax error: package is unexpected.

thanks again and again...

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 ,
Jul 17, 2011 Jul 17, 2011

if dustRaw is an ellipse creating class, you would use it from another class.  for example, if you want to use it from the dustGen class:


// dustRaw.as:

package{
     import flash.display.MovieClip;
          class dustRaw extends MovieClip {
              public function dustRaw(){
                   graphics.beginFill(0xFFFFFF);
                   graphics.drawEllipse(0,0,15,15);
                   graphics.endFill();
          }

     }

}

// dustGen.as:

package{

import dustRaw;

public class dustGen{

private var dust:dustRaw

public function dustGen() {
    for (var i:int = dustArray.length; i<=dustCount-1; i++) {
        dust = new dustRaw();
        addChild(dust);
        dust.x = Math.random() * (rBound-lBound) + lBound;
        dust.y = Math.random() * (dBound-uBound) + uBound;
        dustArray.push(dust);
        tailArray = new Array();
    }
}

}

}


p.s.  you should use generally accepted coding standards:  your class names should start with an upper case letter, eg DustGen and DustRaw would be what coders expect to see.

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
New Here ,
Jul 19, 2011 Jul 19, 2011

ic, thanks.

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 ,
Jul 19, 2011 Jul 19, 2011
LATEST

you're welcome.

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