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

I always have problems with classes :(, Attaching a Class? HElP!

Participant ,
Apr 29, 2013 Apr 29, 2013

I have a Main.as which is asigned as my DocumnetClass

This Class Creates a MovieClip Called Childlike this

var c:Child = new Child  ;

addChild(c);

I have a class also called Child.as

package  {

          import flash.display.MovieClip;

 

          public class Child extends MovieClip

          {

       

                    //This number will match the index of the details in the arrays which belong to that Child

                    var ChildNumber:Number;

                    public function Child() {

                              DeclareChildStats();

                    }

        private function DeclareChildStats()

                    {

                    }

          }

 

}

This class will set the stats for each indvidual child, But I can get it working when I run the swf I just get

TypeError: Error #1009: Cannot access a property or method of a null object reference.

Capture.JPG

Bacicly I am adding the child to the scene.

I want the child to use its class Child.as.

But It wont and I get errors. Why cant things be simple

TOPICS
ActionScript
506
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 , Apr 29, 2013 Apr 29, 2013

that should be

var c:Child=new Child();

and, what line of code is triggering the error (file>publish settings>swf>tick "permit debugging")?

Translate
Community Expert ,
Apr 29, 2013 Apr 29, 2013

that should be

var c:Child=new Child();

and, what line of code is triggering the error (file>publish settings>swf>tick "permit debugging")?

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
Participant ,
Apr 29, 2013 Apr 29, 2013

Ah Its working

I had a line under this function

private function DeclareChildStats()

                    {

                              ChildNumber = MovieClip(root).ChildIndex;

                    }

And when I removed it and put a trace there it works

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 ,
Apr 29, 2013 Apr 29, 2013
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