{"id":196,"date":"2010-11-04T18:54:16","date_gmt":"2010-11-04T18:54:16","guid":{"rendered":"http:\/\/www.eqsim.com\/blog\/?p=196"},"modified":"2010-11-04T15:34:44","modified_gmt":"2010-11-04T19:34:44","slug":"unexpected-re-use-of-file-object-in-flex-4","status":"publish","type":"post","link":"https:\/\/www.eqsim.com\/blog\/unexpected-re-use-of-file-object-in-flex-4\/","title":{"rendered":"Unexpected Re-use of File object in Flex 4"},"content":{"rendered":"<p>I started getting more into Flash Builder\/Flex 4 a few weeks ago, and all is going fine but I ran into what I believe is an odd situation: the File object being returned as the <code>event.target<\/code> from a &#8220;browseForOpen&#8221; invocation is the same over different calls.\u00a0 This was throwing me off because I assumed that each time I called browseForOpen and selected a file, I would get a new File object.\u00a0 It&#8217;s nice from a memory management point of view to know there is re-use, but this doesn&#8217;t seem to me to be what should be expected.<\/p>\n<p>Specifically, in my handler for the browseForOpen, I have the following line:<\/p>\n<p style=\"padding-left: 30px;\"><code>var f:File = (event.target as File);<\/code><\/p>\n<p>The first time this handler is executed (on, let&#8217;s say, FileA), I store the &#8220;f&#8221; variable for later use.\u00a0 The second time this handler is executed, say for FileB, I store it in another data structure.\u00a0 Turns out, when I look at the object I stored the first go around, it has turned into FileB.\u00a0 I really would have expected a new File object to be created each time.\u00a0 Maybe I&#8217;m missing something basic?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I started getting more into Flash Builder\/Flex 4 a few weeks ago, and all is going fine but I ran into what I believe is an odd situation: the File object being returned as the event.target from a &#8220;browseForOpen&#8221; invocation is the same over different calls.\u00a0 This was throwing me off because I assumed that\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.eqsim.com\/blog\/unexpected-re-use-of-file-object-in-flex-4\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts\/196"}],"collection":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":5,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eqsim.com\/blog\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}