Advertisement
Guest User

Untitled

a guest
Jul 1st, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Just add -inline to the asc2 arguments to see this break.
  2. //
  3.  
  4. // A decompiler explains what is going on:
  5. // public static function getNameByKey(value:int):string{ var _local2 = value; while (_local2._key === // (_local2 = StaticMember)) { return ("It works as expected"); }; return (("Broken: " + value)); }
  6.  
  7. package
  8. {
  9.     import flash.display.Sprite;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.  
  13.     public final class Application extends Sprite
  14.     {
  15.         public function Application()
  16.         {
  17.             const textField: TextField = new TextField();
  18.             textField.autoSize = TextFieldAutoSize.LEFT;
  19.             textField.text = IssuedClass.StaticMember.toString();
  20.             addChild( textField );
  21.         }
  22.     }
  23. }
  24.  
  25. package
  26. {
  27.     public final class IssuedClass
  28.     {
  29.         public static const StaticMember: IssuedClass = new IssuedClass( 1 );
  30.  
  31.         public static function getNameByKey( value: int ): String
  32.         {
  33.             // There are at least 2 workarounds.
  34.  
  35.             // A Comment in the next line
  36.             // StaticMember.key;
  37.  
  38.             // B access private member StaticMember._key directly in case statement
  39.  
  40.             switch( value )
  41.             {
  42.                 case StaticMember.key:
  43.                     return 'It works as expected';
  44.             }
  45.  
  46.             return 'Broken: ' + value; // this should never happen! Most of weirdness: value is one!
  47.         }
  48.  
  49.         private var _key: int;
  50.  
  51.         public function IssuedClass( key: int )
  52.         {
  53.             _key = key;
  54.         }
  55.  
  56.         public function get key(): int
  57.         {
  58.             return _key;
  59.         }
  60.  
  61.         public function toString(): String
  62.         {
  63.             return '[IssuedClass key: ' + getNameByKey( _key ) + ']';
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement