Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import mx.utils.ObjectUtil;
  4.     import ab.fl.utils.json.JSON;
  5.     import flash.display.Sprite;
  6.  
  7.     /**
  8.      * @author Omar Gonzalez // omar@almerblank.com
  9.      */
  10.     public class JsonTest extends Sprite
  11.     {
  12.         private var _json:JSON;
  13.         public function JsonTest()
  14.         {
  15.             _init();
  16.         }
  17.  
  18.         private function _init():void
  19.         {
  20.             var json:String = '{"menu": {"header": "SVG Viewer","items": [{"id": "Open"},{"id": "OpenNew", "label": "Open New"},null,{"id": "ZoomIn", "label": "Zoom In"},{"id": "ZoomOut", "label": "Zoom Out"},{"id": "OriginalView", "label": "Original View"},null,{"id": "Quality"},{"id": "Pause"},{"id": "Mute"},null,{"id": "Find", "label": "Find..."},{"id": "FindAgain", "label": "Find Again"},{"id": "Copy"},{"id": "CopyAgain", "label": "Copy Again"},{"id": "CopySVG", "label": "Copy SVG"},{"id": "ViewSVG", "label": "View SVG"},{"id": "ViewSource", "label": "View Source"},{"id": "SaveAs", "label": "Save As"},null,{"id": "Help"},{"id": "About", "label": "About Adobe CVG Viewer..."}]}}';
  21.             _json = new JSON(json);
  22.            
  23.             trace("_json.menu.items = " + _json.menu.items); // Output: [object Object], [object Object],...
  24.             var search:Array = _json.menu.items["(id == 'OpenNew')"]; // Searching for objects in items with id of OpenNew
  25.             trace("search[0].label = " + search[0].label); // Output: search[0].label = Open New
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement