AllFlashWebsite Template, CASA Release [AS2] · Apr 3, 11:24 PM
Based on the original AFW Template. This version uses CASA to accomplish the same thing, only better. Here is the original description:
This template attempts to be a complete solution you can use for any Flash website that needs features going beyond the trivial Flash animation doohickey. Don’t judge the template by the unattractiveness of the demo (it’s pretty ugly). It isn’t meant to offer you any visual styling help, whatsoever. That’s all up to you. Hopefully you’re a Flash developer who creates original, interactive sites that actually use Flash to push the boundaries of the browser beyond HTML. This template allows you the flexibility to create whatever kind of site you want, but offers a framework which will help you work more efficiently and create a site that is highly compatible in many different ways. Some of the benefits include cross-browser compatibility, CMS, effortless SEO, mixing flash and non-flash content, XML in Flash, RSS in Flash, Printing from Flash…
See the demo here (this is the demo of the non-CASA version)
For additional information, please read about the first version of the AFW Template.
In this new release, the Textpattern stuff has not changed. However, the Flash side is significantly different. The code is more straightforward, and more robust.
Download AllFlashWebsite Template, CASA Release
Download AllFlashWebsite Template, CASA Release
After you download and unzip the archive, copy all the files and folders inside the www folder to your website’s root directory (this can be any folder on your web server that you chose). Now read the original AFWTemplate installation instructions which will explain how to setup Textpattern.
Where to Start
You should treat most of the .fla files included with the template (except main.fla) as crude examples of implementing different features. If developing a project from the beginning, main.fla can be your starting point. main.fla is the only file that has been adopted from the original template to use the CASA Framework. The rest of the flash files are mostly unchanged from the original template.
Whether you use CASA in the rest of your project is up to you. If you prefer to use a different Framework, you might (optionally) want to port main.fla. If you don’t currently use a framework in your project, I highly recommend using CASA as it will improve your coding speed and efficiency.
To learn more about CASA, start by reading the Quick Tips and Articles at the CASA Wiki. The CASA documentation is also filled with examples.
main.fla Overview
main.fla handles all the movie loading and integration with SWFAddress. Depending on project requirements, it might make sense to store the locations of various media files as XML documents on the server. (For this purpose, you can manage the XML via the Textpattern CMS in a similar way that the AFW Template flash movies read XML stored in Textpattern Articles.) The template takes a simpler approach by embedding the filenames in main.fla.
main.fla stores a preloader animation and the navigation components in it’s library. Both the preloader animation and navigation components are controlled via the ActionScript in the actions layer (frame 2) of the main timeline.

main.fla ActionScript (frame 2)
The first bit of code loads dependencies used by main.fla.
import org.casaframework.load.media.MediaLoad;import org.casaframework.time.Chain;import org.casaframework.time.Sequence;import org.casaframework.time.EnterFrame;import org.casaframework.time.FrameDelay;import org.casaframework.util.MovieClipUtil;import org.casaframework.layout.DistributionCollection;import mx.utils.Delegate;import org.casaframework.math.geom.Rectangle;- Download this code: /files/code-tcasa-1.1.txt
MediaLoad replaces Flash’s builtin loadMovie() function.
Chain manages events allowing a queue of tasks to execute in order, one at a time.
Sequence “Creates a sequence of methods calls at defined times”.
EnterFrame replaces Flash’s builtin onEnterFrame
FrameDelay “Helps prevent race conditions by allowing recently created MovieClips, Classed, etc… a frame to initialize before proceeding”
MovieClipUtil replaces Flash’s builtin attachMovie() function.
DistributionCollection and Rectangle are used to layout movie clips loaded into main.fla.
The next snippet defines the function required by SWFAddress. Any time a change takes place in the Flash application that requires the address bar to change, handleChange() should be invoked. You will want to modify this function to suite your project requirements.
// SWFAddress calls this function when the address changes// (2 Ways: The Browser's address bar , or SWFAddress.setValue())function handleChange(event:SWFAddressEvent) {trace("handleChange");var path_arr = extractPaths(event.path);var movie_name = (path_arr[0] == "" or path_arr[0] == undefined) ? "index" : path_arr[0] ;trace("movie_name: "+movie_name);if (movie_name == "index") {doLoadMovie("index.swf", movie_name, new Array("xml", "index"));} else if (movie_name == "gallery") {doLoadMovie("AFWGallery.swf", movie_name, path_arr);} else {doLoadMovie("article.swf", movie_name, path_arr);}// Set the title bar textvar flink = (path[0] eq '') ? '' : ': ' + path.join(" / ") + '';SWFAddress.setTitle('AFW' + flink);}SWFAddress.addEventListener(SWFAddressEvent.CHANGE, Delegate.create(this,handleChange));- Download this code: /files/code-tcasa-1.2.txt
The handleChange() function calls doLoadMovie() which handles all of the loading using CASA’s MediaLoad, Sequence, Chain, and DistributionCollection. When doLoadMovie() loads a movie, it waits 1 frame to allow the movie to initialize, then calls the movie’s setPath() function and passes a single argument, an array that represents the current URL path. Therefore, every movie loaded by main.fla should define a setPath() function which allows that movie to change state as the URL path changes.
function doLoadMovie(url, movie_name, path_arr) {trace("path_arr: "+path_arr);if (this.curr_movie != movie_name) {// If a movie is already loading, abort before loading the new oneif (this.mediaLoad.isLoading()){this.mediaLoad.stop();this.mediaLoad.destroy();this[curr_movie].removeMovieClip();curr_movie = last_movie;}last_movie = curr_movie;curr_movie = movie_name;// create an empty mc for the movie we're loadingvar mc = this.createEmptyMovieClip(movie_name, this.getNextHighestDepth());// add the new movie to the distribution, which will handle positioningthis.distribution.removeItem(this[last_movie]);this.distribution.addItem(mc,1);this.distribution.positionItems();this.mediaLoad = new MediaLoad(mc, url,true);// Add an event observer to display load progressthis.mediaLoad.addEventObserver(this, MediaLoad.EVENT_LOAD_PROGRESS, "onMediaLoadProgress");// prepare call to setPath()var seq:Sequence = new Sequence(false);seq.addTask( new FrameDelay(mc, "setPath", 0, path_arr) , "start", 0);// The chain will start the MediaLoad, then wait for an onEnterFrame event before calling this.loadMediaComplete()// We wait a frame because Flash is wierd like that// (See org.casaframework.time.FrameDelay Help for additional information)var chain:Chain = new Chain(false);// loads the filechain.addTask(this.mediaLoad, "start", MediaLoad.EVENT_LOAD_INIT);// waits 1 framechain.addTask(this.pulseInstance, "start", EnterFrame.EVENT_ENTER_FRAME);// calls mc.setPath()chain.addTask(seq, "start", Sequence.EVENT_COMPLETE);// transitionchain.addEventObserver(this, Chain.EVENT_COMPLETE, "loadMediaComplete");chain.start();} else {// Since this movie is the curr_movie, just call setPaththis[movie_name].setPath(path_arr);}}- Download this code: /files/code-tcasa-1.3.txt
— Pickle
Comment
Adding Bam! to AFW Template [AS2] How CASA for AS2 is similar to AS3
