Some questions about preloaders and video

In other time working with flash, we can get resources from swf by :

  1. load a swf
  2. var info:ApplicationDomain = loaderinfo.applicationDomain;
     var cls:Class = info.getDefinition("HUD") as Class; 

Can we use that in haxe/openfl now ? or its a diffrent way needed ?

The second question about preloaders :
if i use this directive

app main=“Main” file=“HTMLX” path=“bin” preloader=“com.CTMPreloader”/

its mean that using Assets.getBitmapData(“img/logo.png”); CTMPreloader will load this image on start ? Or CTMPreloader will load only scripts and html page ?

And last question : can we play FLV file on html target ? Do we have similar Video class as AS3 ?

Big thanks

OpenFL has it’s own asset system, which should be simple to use. It includes automatic preloading for you on HTML5, and we can embed assets in your SWF, we can also asynchronously load assets that you provide at compile-time, not preloading them but requesting them later.

The simplest case is visible in most of the OpenFL samples, such as “DisplayingABitmap”.

The project.xml has the following:

<asset path="Assets" rename="assets" />

…then in Haxe

var bitmapData = Assets.getBitmapData ("assets/openfl.png");

You can use openfl.utils.Assets for images, sound, fonts, text, bytes and even SWF-based MovieClip assets. By default, all your assets are preloaded on HTML5 (and no preloading is necessary on native), so you can get your assets immediately when you need them. There are also load methods (like Assets.loadBitmapData) which you can use for assets that were not preloaded

<asset path="Assets" rename="assets" embed="false" />
Assets.loadBitmapData ("assets/openfl.png").onComplete (function (bitmapData) {

We provide a default Preloader class (with a progress bar, colored based on your application background color) but you can provide a different Preloader class of your own to customize how this looks. We design this on Flash so that the preloader is embedded in the same SWF, which is convenient. If you want a custom preloader, you can try out the “CustomPreloader” sample

openfl create CustomPreloader
cd CustomPreloader
openfl test html5 -Dsimulate-preloader

(the simulate-preloader define triggers a fixed amount of time for preloading, which is useful to test how your preloader will look, you can also do -Dsimulate-preloader=5000 or other values to change the amount of time it will take)

Currently, we support HTML5 video on HTML5, and Flash Video on Flash, but there is no official support on native platforms yet without using another library