{"id":100,"date":"2020-02-23T02:28:24","date_gmt":"2020-02-23T02:28:24","guid":{"rendered":"https:\/\/flashspeaksactionscript.com\/?p=100"},"modified":"2020-02-23T02:28:44","modified_gmt":"2020-02-23T02:28:44","slug":"preloading-content-using-as3","status":"publish","type":"post","link":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/","title":{"rendered":"Preloading Content Using AS3"},"content":{"rendered":"\n

While most smaller Flash projects do not really need a preloader due to the today\u2019s Internet speed, it is still good practice to always include a preloader in all your Flash projects. In this brief tutorial, I will demonstrate how to preload your Flash assets using AS3.<\/p>\n\n\n\n

Preloading in AS3 is a more streamlined process due to the new & improved event handling structure that AS3 brings to the table. You have more control over what gets preloaded and when it gets preloaded.<\/p>\n\n\n\n

How to Preload with AS3<\/h2>\n\n\n\n

Like most things in Flash, there are many ways to preload your content into your Flash projects. How you create your preloading animation will be totally up to you. In this example, I will be dynamically resizing a preloader\u2019s fill based on the progress percentage of the content being loaded. It is a simple way to demonstrate a preloading action.<\/p>\n\n\n\n

Code used in example<\/h2>\n\n\n\n
\/\/Define a loader\nvar imageLoader:Loader;\n\nfunction loadThisImage(url:String):void {\n \/\/Show Preloader\n preloader.visible=true;\n imageLoader=new Loader();\n imageLoader.load(new URLRequest(url));\n \/\/Add a listener to update the preloader on the image's progress\n imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,imageLoading);\n \/\/Adding a listener that will update the preloader once the image has been loaded\n imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageLoaded);\n}\n\nfunction imageLoaded(evt:Event):void {\n \/\/ Load Image by adding it to the display list\n imageLoaderClip.addChild(imageLoader);\n \/\/ Hide Preloader\n preloader.visible=false;\n}\n\nfunction imageLoading(evt:ProgressEvent):void {\n \/\/ Get the current download progress\n var loaded:Number=evt.bytesLoaded\/evt.bytesTotal;\n \/\/ Send progress info to \"preloader\" movie clip\n updateProgress(loaded);\n}\n\nfunction updateProgress(value:Number) {\n preloader.progress.width=value*preloader.bar.width;\n}\n\n\/\/Loading the image defined in the parameter\nloadThisImage(\"image-loaded-large.jpg\");\n<\/pre>\n\n\n\n


As you noticed this example loads an image, but you can very well use it to load you main SWF content or even multiple images. By creating multiple loaders, you can then define the asset in which you choose to load.  This will allow you more control over your content being loaded.<\/p>\n\n\n\n

As you can see,  preloading content using AS3 is actually pretty easy.  Have fun migrating over into AS3!<\/p>\n\n\n\n

Download Source<\/h2>\n\n\n\n

I hope this helps in your migration over into  AS3.  If there is something in particular you want to add or see with the Moving From AS2 to AS3 series, feel free to contact me via the contact page<\/a>.<\/em><\/p>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

While most smaller Flash projects do not really need a preloader due to the today\u2019s Internet speed, it is still good practice to always include a preloader in all your Flash projects. In this brief tutorial, I will demonstrate how to preload your Flash assets using AS3. Preloading in AS3 is a more streamlined process […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"yoast_head":"\r\nPreloading Content Using AS3 - Flash & Action Script<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/\" \/>\r\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Preloading Content Using AS3 - Flash & Action Script\" \/>\r\n<meta property=\"og:description\" content=\"While most smaller Flash projects do not really need a preloader due to the today\u2019s Internet speed, it is still good practice to always include a preloader in all your Flash projects. In this brief tutorial, I will demonstrate how to preload your Flash assets using AS3. Preloading in AS3 is a more streamlined process […]\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Flash & Action Script\" \/>\r\n<meta property=\"article:published_time\" content=\"2020-02-23T02:28:24+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2020-02-23T02:28:44+00:00\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"romeo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/#organization\",\"name\":\"Flash Speaks Action Script\",\"url\":\"https:\/\/flashspeaksactionscript.com\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/#logo\",\"inLanguage\":\"fr-FR\",\"url\":\"https:\/\/flashspeaksactionscript.com\/wp-content\/uploads\/2020\/02\/fsa_header.gif\",\"contentUrl\":\"https:\/\/flashspeaksactionscript.com\/wp-content\/uploads\/2020\/02\/fsa_header.gif\",\"width\":384,\"height\":97,\"caption\":\"Flash Speaks Action Script\"},\"image\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/#website\",\"url\":\"https:\/\/flashspeaksactionscript.com\/\",\"name\":\"Flash Speaks Action Script\",\"description\":\"Flash Speaks Action Script\",\"publisher\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/flashspeaksactionscript.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#webpage\",\"url\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/\",\"name\":\"Preloading Content Using AS3 - Flash & Action Script\",\"isPartOf\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/#website\"},\"datePublished\":\"2020-02-23T02:28:24+00:00\",\"dateModified\":\"2020-02-23T02:28:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/flashspeaksactionscript.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Preloading Content Using AS3\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#webpage\"},\"author\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/#\/schema\/person\/12465390cabdbd540e13c94722ba8016\"},\"headline\":\"Preloading Content Using AS3\",\"datePublished\":\"2020-02-23T02:28:24+00:00\",\"dateModified\":\"2020-02-23T02:28:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#webpage\"},\"wordCount\":276,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/flashspeaksactionscript.com\/#organization\"},\"articleSection\":[\"Article\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/#\/schema\/person\/12465390cabdbd540e13c94722ba8016\",\"name\":\"romeo\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/flashspeaksactionscript.com\/#personlogo\",\"inLanguage\":\"fr-FR\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b71d1e1ea443ac779fd59a57093d12fc?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b71d1e1ea443ac779fd59a57093d12fc?s=96&d=identicon&r=g\",\"caption\":\"romeo\"},\"url\":\"https:\/\/flashspeaksactionscript.com\/author\/romeo\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Preloading Content Using AS3 - Flash & Action Script","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/","og_locale":"fr_FR","og_type":"article","og_title":"Preloading Content Using AS3 - Flash & Action Script","og_description":"While most smaller Flash projects do not really need a preloader due to the today\u2019s Internet speed, it is still good practice to always include a preloader in all your Flash projects. In this brief tutorial, I will demonstrate how to preload your Flash assets using AS3. Preloading in AS3 is a more streamlined process […]","og_url":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/","og_site_name":"Flash & Action Script","article_published_time":"2020-02-23T02:28:24+00:00","article_modified_time":"2020-02-23T02:28:44+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"romeo","Dur\u00e9e de lecture estim\u00e9e":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/flashspeaksactionscript.com\/#organization","name":"Flash Speaks Action Script","url":"https:\/\/flashspeaksactionscript.com\/","sameAs":[],"logo":{"@type":"ImageObject","@id":"https:\/\/flashspeaksactionscript.com\/#logo","inLanguage":"fr-FR","url":"https:\/\/flashspeaksactionscript.com\/wp-content\/uploads\/2020\/02\/fsa_header.gif","contentUrl":"https:\/\/flashspeaksactionscript.com\/wp-content\/uploads\/2020\/02\/fsa_header.gif","width":384,"height":97,"caption":"Flash Speaks Action Script"},"image":{"@id":"https:\/\/flashspeaksactionscript.com\/#logo"}},{"@type":"WebSite","@id":"https:\/\/flashspeaksactionscript.com\/#website","url":"https:\/\/flashspeaksactionscript.com\/","name":"Flash Speaks Action Script","description":"Flash Speaks Action Script","publisher":{"@id":"https:\/\/flashspeaksactionscript.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/flashspeaksactionscript.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"fr-FR"},{"@type":"WebPage","@id":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#webpage","url":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/","name":"Preloading Content Using AS3 - Flash & Action Script","isPartOf":{"@id":"https:\/\/flashspeaksactionscript.com\/#website"},"datePublished":"2020-02-23T02:28:24+00:00","dateModified":"2020-02-23T02:28:44+00:00","breadcrumb":{"@id":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/flashspeaksactionscript.com\/"},{"@type":"ListItem","position":2,"name":"Preloading Content Using AS3"}]},{"@type":"Article","@id":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#article","isPartOf":{"@id":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#webpage"},"author":{"@id":"https:\/\/flashspeaksactionscript.com\/#\/schema\/person\/12465390cabdbd540e13c94722ba8016"},"headline":"Preloading Content Using AS3","datePublished":"2020-02-23T02:28:24+00:00","dateModified":"2020-02-23T02:28:44+00:00","mainEntityOfPage":{"@id":"https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#webpage"},"wordCount":276,"commentCount":0,"publisher":{"@id":"https:\/\/flashspeaksactionscript.com\/#organization"},"articleSection":["Article"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/flashspeaksactionscript.com\/preloading-content-using-as3\/#respond"]}]},{"@type":"Person","@id":"https:\/\/flashspeaksactionscript.com\/#\/schema\/person\/12465390cabdbd540e13c94722ba8016","name":"romeo","image":{"@type":"ImageObject","@id":"https:\/\/flashspeaksactionscript.com\/#personlogo","inLanguage":"fr-FR","url":"https:\/\/secure.gravatar.com\/avatar\/b71d1e1ea443ac779fd59a57093d12fc?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b71d1e1ea443ac779fd59a57093d12fc?s=96&d=identicon&r=g","caption":"romeo"},"url":"https:\/\/flashspeaksactionscript.com\/author\/romeo\/"}]}},"_links":{"self":[{"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/posts\/100"}],"collection":[{"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":2,"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/posts\/100\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flashspeaksactionscript.com\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}