Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > ActionScript

Something's Different: Tips for Making a Painless Migration to ActionScript 3

  • Print
  • + Share This
Got a few problems with ActionScript 3? Author Kris Hadlock has solutions. He even supplies the code you need to put the solutions right to work. He's a full-service author, that Kris Hadlock.
From the author of

There are many necessary ActionScript tasks used to create common Flash functionality. With all of the updates and changes made to ActionScript, figuring out how to accomplish some of the most simple tasks can require digging through search results or even Flash Help. This article will help alleviate a little of that pain by providing useful tips to help make the migration. There aren’t any lengthy explanations here, just quick, painless solutions for a few of your more pressing ActionScript problems.

Accessing class methods

Problem: Sub-classes can no longer access their super classes’ private methods. This is because private is now truly private.

Solution: Use protected if you want to have access to an inherited class method.

Code: In the following example, class B can access getProtected, but not the getPrivate method. Commenting-out the getPrivate method produces successful results.

package
{
    import flash.display.*;
    
    public class A extends Sprite
    {
        public function A():void { }
        
        protected function getProtected():String
        {
            return "protected method"; 
        }
        
        private function getPrivate():String
        {
            return "private method";
        }
    }
}

package
{
    public class B extends A
    {
        public function B():void
        {
            super();
            trace(super.getProtected());
            trace(super.getPrivate());
        }
    }
}
  • + Share This
  • 🔖 Save To Your Account