{"id":192,"date":"2008-03-09T19:04:58","date_gmt":"2008-03-10T03:04:58","guid":{"rendered":"http:\/\/www.ericfeminella.com\/blog\/2008\/03\/09\/localpersistence-map\/"},"modified":"2012-03-04T23:32:11","modified_gmt":"2012-03-05T04:32:11","slug":"localpersistence-map","status":"publish","type":"post","link":"https:\/\/www.ericfeminella.com\/blog\/2008\/03\/09\/localpersistence-map\/","title":{"rendered":"LocalPersistenceMap"},"content":{"rendered":"<p>When developing browser based Flex applications, <code><a href=\"http:\/\/livedocs.adobe.com\/flex\/2\/langref\/index.html\" target=\"_blank\">SharedObject<\/a><\/code> provides just about everything one needs to facilitate local persistence of application data. While being somewhat restricted by certain rules governed by the Flash Player Security Model, in general, it provides a rather simple solution for most needs.<\/p>\n<p>The data property of a SharedObject provides read\/write access to the underlying data which is persisted to the SharedObject. Personally, I prefer to have a consistent API available when working with dynamic objects, thus I developed the <code><a href=\"http:\/\/code.ericfeminella.com\/classes\/as3\/IMap.as.html\" target=\"_blank\">IMap<\/a><\/code> interface. <\/p>\n<p><code><a href=\"http:\/\/code.ericfeminella.com\/classes\/as3\/LocalPersistenceMap.as.html\" target=\"_blank\">LocalPersistenceMap<\/a><\/code> provides an IMap implementation into the data property of a SharedObject instance. It allows clients to work with the underlying data of a SharedObject just as one would with a <code><a href=\"http:\/\/code.ericfeminella.com\/classes\/as3\/HashMap.as.html\" target=\"_blank\">HashMap<\/a><\/code>, <code><a href=\"http:\/\/code.ericfeminella.com\/classes\/as3\/ResourceMap.as.html\" target=\"_blank\">ResourceMap<\/a><\/code>, etc.<\/p>\n<p>Below is a basic example which demonstrates how LocalPersistenceMap can be utilized to provide an IMap implementation into a SharedObject:<\/p>\n<pre lang=\"actionscript\">\r\n\r\nvar map:IMap = new LocalPersistenceMap(\"test\", \"\/\");\r\nmap.put(\"username\", \"efeminella\");\r\nmap.put(\"password\", \"43kj5k4nr43r934hcr34hr8h3\");\r\nmap.put(\"admin\", true);<\/pre>\n<p>The LocalPersistenceMap constructor creates a reference to a local SharedObject based on the specified identifier and optional local path. A reference to the underlying SharedObject can also be retrieved via the <code><a href=\"http:\/\/code.ericfeminella.com\/asdocs\/CollectionsAPI\/com\/ericfeminella\/collections\/LocalPersistenceMap.html#sharedObjectInstance\" target=\"_blank\">sharedObjectInstance<\/a><\/code> accessor. <\/p>\n<p>In addition to the new LocalPersistenceMap, I have also packaged the Collections API which can be downloaded <a href=\"http:\/\/code.ericfeminella.com\/downloads\/Collections.zip\">here<\/a>. Complete documentation and code examples for the Collections API are also available <a href=\"http:\/\/code.ericfeminella.com\/asdocs\/CollectionsAPI\/com\/ericfeminella\/collections\/package-detail.html\" target=\"_blank\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When developing browser based Flex applications, SharedObject provides just about everything one needs to facilitate local persistence of application data. While being somewhat restricted by certain rules governed by the Flash Player Security Model, in general, it provides a rather simple solution for most needs. The data property of a SharedObject provides read\/write access to the underlying data which is&#8230; <a class=\"read-more\" href=\"https:\/\/www.ericfeminella.com\/blog\/2008\/03\/09\/localpersistence-map\/\">Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[9],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-news"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":0,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}