Skip to main content
Participant
February 21, 2016
Answered

Can we extend document class with custom class in flash as3?

  • February 21, 2016
  • 3 replies
  • 529 views

Hi,
Can we extend document class with custom class in flash as3?

Thanks,
Amisha

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

try:

amishap67776642 wrote:

package

{

     public class accessories extends ScreenBase

     {

          public function accessories()

          {

            super();

            addEventListener(Event.ADDED_TO_STAGE,onAddedTostageHandler)

          }

          private function onAddedTostageHandler(e:Event):void

          {

              super.init();

          }

     }

}

/* class ScreenBase*/

package

{

     public class ScreenBase extends MovieClip

     {

          public function ScreenBase ()

          {

            super();

          }

          public function init():void

          {

              MovieClip(this).tutorialBox_mc.visible = true;

          }

     }

}

3 replies

kglad
Community Expert
Community Expert
February 21, 2016

yes

Participant
February 22, 2016

package

{

     public class accessories extends ScreenBase

     {

          public function accessories()

          {

            super();

            addEventListener(Event.ADDED_TO_STAGE,onAddedTostageHandler)

          }

          private function onAddedTostageHandler(e:Event):void

          {

              super.init();

          }

     }

}

/* class ScreenBase*/

package

{

     public class ScreenBase extends MovieClip

     {

          public function ScreenBase ()

          {

            super();

          }

          public function init():void

          {

               tutorialBox_mc.visible = true;

          }

     }

}

Getting error that I can't access "tutorialBox_mc" in Base class.
tutorialBox_mc is the movieclip that I placed on stage and that fla link to document class "accessories"

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 22, 2016

try:

amishap67776642 wrote:

package

{

     public class accessories extends ScreenBase

     {

          public function accessories()

          {

            super();

            addEventListener(Event.ADDED_TO_STAGE,onAddedTostageHandler)

          }

          private function onAddedTostageHandler(e:Event):void

          {

              super.init();

          }

     }

}

/* class ScreenBase*/

package

{

     public class ScreenBase extends MovieClip

     {

          public function ScreenBase ()

          {

            super();

          }

          public function init():void

          {

              MovieClip(this).tutorialBox_mc.visible = true;

          }

     }

}