FLUGR
FLUGR Forums
Forums | Profile | Inbox | Members | Search | Login | RSS
New Topic Reply Subscription Options   Previous Page  Page: 1   Previous Page

Forums: ActionScript: public static const
Created on: 02/10/09 07:37 PM Views: 396 Replies: 1
public static const
Posted Tuesday, February 10, 2009 at 7:37 PM

Here's one for you......

inside a class i defined a couple of states using public static const.

like: public static const IDLE:String = "IDLE";

when using these in an if or switch statement inside the same class everything works fine, BUT, when i try to access these (in if or switch) from an other class an error occures.

1119: Access of possibly undefined property IDLE through a reference with static type Class.


As a workaround i've changed the public static const to a static getter. which works, but still... why the error.

RE: public static const
Posted Tuesday, February 10, 2009 at 8:01 PM

It all works fine here:

Test function:

import test.MyCLass;
      private function test() : void {
         
         switch(MyCLass.IDLE) {
            case "Idle":
             trace("Idle");
             break;
            case "Test":
             trace("Test");
             break;
         }
         
         var testje : String = "Idle";
         switch(testje) {
            case MyCLass.IDLE:
             trace("Idle");
             break;
            case MyCLass.TEST:
             trace("Test");
             break;
         }
         
      }

MyClass:

public class MyCLass
   {
      public static const IDLE : String = "Idle" ;
      public static const TEST: String = "Test";
      
My only guess would be that the visibility of either your variables or your class isn't public

Adobe Certified Instructor
Info Support B.V.

www

New Topic Reply Subscription Options   Previous Page  Page: 1   Previous Page
Subscription Options
Subscription options are available after you log in.

There are 3 active user sessions right now.