2 Replies Latest reply on Nov 19, 2010 10:51 AM by GordonSmith

    can we create static class in actionscript 3.0

    FlexPrashant Level 1

      Hi If yes please send me chunk of code .

       

       

      thanks

        • 1. Re: can we create static class in actionscript 3.0
          BhaskerChari Level 4

          Hi Prashanth,

           

          There is no specifically a Static class in Flex that you can declare it at the compile time. However you can have Static variables and methods in your class and you can call them using the class name itself without creating an instance of that class.

           

          Here is the chunk of code...

           

           

          package com.constants
          {
          [Bindable]
          public class ConsumerMessageConstants
          {
            public static const UNABLE_TO_ENROLL_PLANS_MESSAGE_ID:String = "10000";
            public static const MARITAL_STATUS_UPDATED_MESSAGE_ID:String = "10001";
            public static const ERROR_IN_EDITING_MARITALSTAUS_MESSAGE_ID:String = "10002";
            public static const SMOKER_STATUS_SAVED_SUCCESSFULLY_MESSAGE_ID:String = "10003";
            public static const PASSWORD_RESET_REQUIRED_MESSAGE_ID:String = "10004";
            public static const ADDRESS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10005";
            public static const UNABLE_TO_REMOVE_THIS_DEPENDENT_MESSAGE_ID:String = "10006";
            public static const EMPLOYEE_SALARY_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10007";
            public static const ERROR_IN_EDITING_SALARY_MESSAGE_ID:String = "10008";
            public static const PLEASE_SELECT_A_CONSIDER_PLAN_MESSAGE_ID:String = "10009";
            public static const YOU_MUST_CHOOSE_A_PLAN_COVERAGE_LEVEL_MESSAGE_ID:String = "10010";
            public static const PLEASE_SELECT_PLAN_TO_LOCK_PORTFOLIO_MESSAGE_ID:String = "10011";
            public static const DEEPDIVE_INFORMATION_SAVED_SUCCESSFULLY_MESSAGE_ID:String = "10012";
            public static const NO_DATA_TO_DISPLAY_MESSAGE_ID:String = "10013";
            public static const NO_PLANS_AVAILABLE_TO_ENROLL_MESSAGE_ID:String = "10014";
            public static const NO_PLANS_TO_BE_ENROLLED_MESSAGE_ID:String = "10015";
            public static const PASSWORD_CHANGED_SUCCESSFULLY_MESSAGE_ID:String = "10016";
            public static const NEW_PASSWORD_AND_CONFIRM_PASSWORD_SAME_MESSAGE_ID:String = "10017";
            public static const YOUR_DATA_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10018";
            public static const HEALTH_PLAN_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10019";
            public static const HEALTH_PLAN_IS_ADDED_SUCCESSFULLY_MESSAGE_ID:String = "10020";
            public static const MONEY_PLAN_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10021";
            public static const MONEY_PLAN_IS_ADDED_SUCCESSFULLY_MESSAGE_ID:String = "10022";
            public static const PROTECTION_PLAN_IS_UPDATED_SUCCESSFULLY_MESSAGE_ID:String = "10023";
            public static const PROTECTION_PLAN_IS_ADDED_SUCCESSFULLY_MESSAGE_ID:String = "10024";
            public static const UNABLE_TO_RETRIEVE_PATHS_MESSAGE_ID:String = "10025";
           

           

            public static function func1():Void
            {
               ////

            }

            public static function func2():Void
            {
               ////

            }
              
            public function ConsumerMessageConstants()
            {
            }
          }
          }

          • 2. Re: can we create static class in actionscript 3.0
            GordonSmith Level 4

            If you mean a static class inside another class, as in Java, no. But in ActionScript you can have a file structured like this:

             

            ----

             

            package

            {

                public class C

                {

                    ...

                }

            }

             

            class A

            {

                ...

            }

             

            class B

            {

                ...

            }

             

            ----

             

            and classes A and B are available can be used by class C (or by each other) but not by any classes in other files.

             

            Gordon Smith

            Adobe Flex SDK Team

            1 person found this helpful