Call Us: +1-888-227-1645
AS3PV3D setup and implementation

AS3/PV3D Loading Data

Eric Meyer

2 min read

With actionscript3 comes alot of new changes. One of the most often used features of flash is importing/loading and dealing with external data. In actionscript2 you could use a movieClipLoader, or a simple load to achieve basically what you needed to do. With AS3, you have a little more control over the data that is being parsed, and what happens before, during, and after loading.

The first major change for AS3, is that you need to specify a request using AS3’s new URLRequest datatype and function. This is done by specifying a connection string something like this:

var request:URLRequest = new URLRequest("comp"+startI+".swf");

From this code, you can tell that some sort of dynamic, external swf data is being loaded in.

After your request is setup, the next thing to do is setup the actual loader. This is done like this:

var loader:Loader = new Loader();

Once your loader is setup, you can setup listeners for your loader. The listeners are the important part, as they can trigger different phases of your load progress. For this example, ill use a progress complete event, and a load-in-progress event.

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressHandler);

The really important thing here is that you NEED to define the progress events before you make the call to the load or else it will not run properly, and it will not recognize your events. The final line of the example is just to go ahead and call the load.

loader.load(request);

The two defined events can be setup as functions if you like, to determine percentage loaded, etc. An example percentage loaded function would look something like this-

function progressHandler(evt:ProgressEvent) {
var percentage  = (evt.bytesLoaded/evt.bytesTotal)*100;
}

There you have it, the actionscript3 way of loading external data. I use this method constantly for loading dynamic textures for papervision projects, or to simply parse XML, it all works the same way.

From the blog

Latest Articles

Let's build something amazing together

Give us a ring and let us know how we can help you reach your goals. Or if you'd like, start a chat. We're usually available 9-5 EST. We try to respond to every inquiry within one business day.

Phone number
+1-888-227-1645

Technologies and services we work with:

Laravel Laravel
WordPress WordPress
React ReactJS
EmberJS EmberJS
woocommerce WooCommerce
next.js NextJS
gatsby Gatsby
Shopify Shopify
VueJs VueJS
contentful Contentful
next.js JAMStack
gatsby Laravel Jigsaw
WPEngine WP Engine
Laravel Livewire Laravel Livewire
Netlify Netlify