{"id":196,"date":"2008-07-31T19:03:24","date_gmt":"2008-07-31T10:03:24","guid":{"rendered":"http:\/\/clockmaker.jp\/blog\/?p=196"},"modified":"2008-07-31T19:03:24","modified_gmt":"2008-07-31T10:03:24","slug":"flex_image_cache","status":"publish","type":"post","link":"https:\/\/clockmaker.jp\/blog\/2008\/07\/flex_image_cache\/","title":{"rendered":"Flex\u3067\u52d5\u7684\u753b\u50cf\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u3067\u304d\u308b"},"content":{"rendered":"<p class=\"photo\"><a href=\"http:\/\/clockmaker.jp\/labs\/080731_flex_cache\/FlexChache.swf\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2008\/07\/flex_cache-460x366.jpg\" alt=\"\" title=\"flex_cache\" width=\"460\" height=\"366\" class=\"alignnone size-medium wp-image-197\" \/><\/a><\/p>\n<p><a href=\"http:\/\/userflex.wordpress.com\/2008\/07\/28\/image-caching\/\">Flex\u3067\u753b\u50cf\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u65b9\u6cd5\u304c\u7d39\u4ecb<\/a>\u3055\u308c\u3066\u307e\u3057\u305f\u306e\u3067\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u30022\u5ea6\u76ee\u4ee5\u964d\u306e\u8aad\u307f\u8fbc\u307f\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u5229\u7528\u3055\u308c\u3001\u901a\u4fe1\u304c\u767a\u751f\u3057\u307e\u305b\u3093\u3002<a href=\"http:\/\/mozilla.jp\/firefox\/\">Firefox<\/a>\u306e\u30a2\u30c9\u30aa\u30f3\u3067\u3042\u308b<a href=\"https:\/\/addons.mozilla.org\/ja\/firefox\/addon\/1843\">Firebug<\/a>\u3084<a href=\"https:\/\/addons.mozilla.org\/ja\/firefox\/addon\/3829\">LiveHTTPHeaders<\/a>\u3092\u4f7f\u3046\u3053\u3068\u3067Flash\u5185\u304b\u3089\u4e8c\u5ea6\u76ee\u306e\u901a\u4fe1\u304c\u767a\u751f\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/clockmaker.jp\/labs\/080731_flex_cache\/FlexChache.swf\" target=\"_blank\">\u30c7\u30e2(\u8981Flash Player 9) <\/a><\/p>\n<p>\u4ed5\u69d8\u306b\u3064\u3044\u3066\u306f\u4e0b\u8a18\u306b\u307e\u3068\u3081\u3066\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h3>\u8003\u5bdf<\/h3>\n<p>\u539f\u7406\u306fBitmapData\u3092\u5185\u90e8\u306b\u4fdd\u5b58\u3055\u305b\u3001\uff12\u5ea6\u76ee\u4ee5\u964d\u306e\u8aad\u307f\u8fbc\u307f\u51e6\u7406\u6642\u306b\u306fBitmapData\u3092Bitmap\u5316\u3057\u3066\u8868\u793a\u3059\u308b\u3068\u3044\u3046\u306e\u3082\u306e\u3067\u3059\u3002\u82e5\u5e72\u30bd\u30fc\u30b9\u304c\u5197\u9577\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001\u5de5\u592b\u3059\u308c\u3070\u3082\u3046\u5c11\u3057\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u306a\u308b\u304b\u3082(Image\u3092\u7d99\u627f\u3057\u305f\u62e1\u5f35Image\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u3001\u9759\u7684\u5909\u6570\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u4f5c\u308c\u3070\u6c4e\u7528\u6027\u304c\u3067\u308b\u3067\u3057\u3087\u3046\u304b!?)\u3002\u3055\u3089\u306b\u3044\u3048\u3070\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3088\u308a\u3082Flash\u306b\u8fd1\u3044\u3068\u3053\u308d(\u3068\u3044\u3046\u304bswf\u5185)\u3092\u53c2\u7167\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3088\u308a\u3082\u5f53\u7136\u9ad8\u901f\u3067\u3059(\u4e00\u77ac\u3067\u3059)\u3002\u3053\u308c\u306fFlex\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6539\u5584\u3067\u304d\u305d\u3046\u3067\u3059\u306d\uff01<\/p>\n<h3>\u30c7\u30e2\u306e\u30bd\u30fc\u30b9<\/h3>\n<p>&lt;?xml version=&quot;1.0&quot;?&gt;<br \/>\n&lt;mx:Application<br \/>\n\txmlns:mx=&quot;http:\/\/www.adobe.com\/2006\/mxml&quot;<br \/>\n\tcreationComplete=&quot;init()&quot;&gt;<br \/>\n\t&lt;mx:Script&gt;<br \/>\n\t\t&lt;![CDATA[<\/p>\n<p>\t\timport mx.controls.Image;<br \/>\n\t\timport flash.utils.getTimer;<br \/>\n\t\timport flash.utils.Dictionary;<\/p>\n<p>\t\tstatic private const IMAGE_URL:String = &quot;sample.jpg&quot;;<br \/>\n\t\tstatic private const MESSAGE_DEFAULT:String = &quot;[image status]&quot;;<br \/>\n\t\tprivate var imageCache:Dictionary;<br \/>\n\t\tprivate var tmpTimer:Number;<\/p>\n<p>\t\t\/**<br \/>\n\t\t * \u521d\u671f\u5316<br \/>\n\t\t *\/<br \/>\n\t\tprivate function init():void<br \/>\n\t\t{<br \/>\n\t\t\t\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u306e\u521d\u671f\u5316<br \/>\n\t\t\timageCache = new Dictionary();<br \/>\n\t\t}<\/p>\n<p>\t\t\/**<br \/>\n\t\t * \u753b\u50cf\u306e\u8aad\u307f\u8fbc\u307f\u51e6\u7406<br \/>\n\t\t *\/<br \/>\n\t\tprivate function loadPhoto():void<br \/>\n\t\t{<br \/>\n\t\t\t\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u3068\u304d<br \/>\n\t\t\tif (imageCache[IMAGE_URL])<br \/>\n\t\t\t{<br \/>\n\t\t\t\t\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u306eBitmapData\u3092Bitmap\u5316<br \/>\n\t\t\t\tphoto01.source = new Bitmap(imageCache[IMAGE_URL]);<br \/>\n\t\t\t\tpanel.title = &quot;use cache&quot;;<br \/>\n\t\t\t}<br \/>\n\t\t\t\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u306a\u3044\u3068\u304d<br \/>\n\t\t\telse<br \/>\n\t\t\t{<br \/>\n\t\t\t\t\/\/ Image\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306bURL\u30d1\u30b9\u3092\u8a2d\u5b9a<br \/>\n\t\t\t\tphoto01.source = IMAGE_URL;<br \/>\n\t\t\t\tpanel.title = &quot;load from internet&quot;;<br \/>\n\t\t\t}<br \/>\n\t\t\t\/\/ \u8aad\u307f\u8fbc\u307f\u6642\u9593\u8a08\u6e2c\u7528<br \/>\n\t\t\ttmpTimer = getTimer();<br \/>\n\t\t}<\/p>\n<p>\t\t\/**<br \/>\n\t\t * \u753b\u50cf\u8aad\u307f\u8fbc\u307f\u5b8c\u4e86\u6642\u306e\u30cf\u30f3\u30c9\u30eb<br \/>\n\t\t * @param\tevent<br \/>\n\t\t *\/<br \/>\n\t\tprivate function onImageComplete(event:Event):void<br \/>\n\t\t{<br \/>\n\t\t\tvar img:Image = event.target as Image;<\/p>\n<p>\t\t\t\/\/ \u753b\u50cf\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u5c65\u6b74\u306b\u306a\u3051\u308c\u3070\u4fdd\u5b58\u3059\u308b<br \/>\n\t\t\tif (! imageCache[img.source])<br \/>\n\t\t\t{<br \/>\n\t\t\t\t\/\/ \u753b\u50cf\u3092BitmapData\u5316<br \/>\n\t\t\t\tvar bmpData:BitmapData = new BitmapData<br \/>\n\t\t\t\t\t(img.content.width, img.content.height, true);<br \/>\n\t\t\t\t\/\/\u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u306b\u4fdd\u5b58<br \/>\n\t\t\t\timageCache[img.source] = bmpData;<br \/>\n\t\t\t\tbmpData.draw(img.content);<br \/>\n\t\t\t}<br \/>\n\t\t\t\/\/ \u8aad\u307f\u8fbc\u307f\u6642\u9593\u306e\u8868\u793a<br \/>\n\t\t\tpanel.title += &quot; &#8211; &quot; + (getTimer() &#8211; tmpTimer) + &quot;msec&quot;;<br \/>\n\t\t}<\/p>\n<p>\t\t\/**<br \/>\n\t\t * \u753b\u50cf\u306e\u30ea\u30bb\u30c3\u30c8\u51e6\u7406<br \/>\n\t\t *\/<br \/>\n\t\tprivate function deletePhoto():void<br \/>\n\t\t{<br \/>\n\t\t\tphoto01.source = null;<br \/>\n\t\t\tpanel.title = MESSAGE_DEFAULT;<br \/>\n\t\t}<\/p>\n<p>\t]]&gt;<br \/>\n\t&lt;\/mx:Script&gt;<\/p>\n<p>\t&lt;!&#8211; \u30dc\u30bf\u30f3 &#8211;&gt;<br \/>\n\t&lt;mx:HBox&gt;<br \/>\n\t\t&lt;mx:Button label=&quot;load&quot; click=&quot;loadPhoto()&quot; \/&gt;<br \/>\n\t\t&lt;mx:Button label=&quot;delete&quot; click=&quot;deletePhoto()&quot; \/&gt;<br \/>\n\t&lt;\/mx:HBox&gt;<\/p>\n<p>\t&lt;!&#8211; \u753b\u50cf &#8211;&gt;<br \/>\n\t&lt;mx:Panel id=&quot;panel&quot; title=&quot;{MESSAGE_DEFAULT}&quot;&gt;<br \/>\n\t\t&lt;mx:Image<br \/>\n\t\t\tid=&quot;photo01&quot;<br \/>\n\t\t\tcomplete=&quot;onImageComplete(event)&quot;<br \/>\n\t\t\twidth=&quot;450&quot; height=&quot;300&quot; \/&gt;<br \/>\n\t&lt;\/mx:Panel&gt;<\/p>\n<p>&lt;\/mx:Application&gt;<\/p>\n<h3>\u53c2\u8003\u30ea\u30f3\u30af<\/h3>\n<ul>\n<li><a href=\"http:\/\/userflex.wordpress.com\/2008\/07\/28\/image-caching\/\">How to Cache Images in Your Flex\u00a0Application<\/a><\/li>\n<li><a href=\"http:\/\/d.hatena.ne.jp\/sato-shi\/20080729\/p2\">\u753b\u50cf\u30ad\u30e3\u30c3\u30b7\u30e5 &#8211; Flex Coder<\/a><\/li>\n<li><a href=\"http:\/\/www.flickr.com\/photos\/88403964@N00\/\">\u5199\u771f\u306eiPhone\u306f\u3053\u3061\u3089\u304b\u3089\u5229\u7528<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Flex\u3067\u753b\u50cf\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u65b9\u6cd5\u304c\u7d39\u4ecb\u3055\u308c\u3066\u307e\u3057\u305f\u306e\u3067\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u30022\u5ea6\u76ee\u4ee5\u964d\u306e\u8aad\u307f\u8fbc\u307f\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u5229\u7528\u3055\u308c\u3001\u901a\u4fe1\u304c\u767a\u751f\u3057\u307e\u305b\u3093\u3002Firefox\u306e\u30a2\u30c9\u30aa\u30f3\u3067\u3042\u308bFirebug\u3084LiveHTTPHeaders\u3092\u4f7f\u3046\u3053\u3068 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts\/196"}],"collection":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":0,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"wp:attachment":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}