Giter Site home page Giter Site logo

joshtynjala / starling-preloader Goto Github PK

View Code? Open in Web Editor NEW
24.0 8.0 11.0 154 KB

An example preloader for Starling Framework running in Adobe Flash Player in a web browser

ActionScript 100.00%
actionscript starling-framework adobe-flash-player flash adobe-flash starling feathers-ui as3 adobe-air

starling-preloader's Introduction

Preloader for Starling

SWFs running in a web browser should have preloaders. A preloader allows you to quickly display graphics and animation so that visitors to your webpage have something to look at while the rest of the SWF file loads.

How do you create a preloader for a Starling app? It's not really any different than creating a preloader for any other SWF. Here's a summary of how I do it. Be sure to look at the included source code for complete details.

  1. Extend flash.display.MovieClip when creating the startup class. Call stop() in the constructor.

  2. Use the following command line argument to compile your Starling root class on frame 2 instead of frame 1. It's the class that you will pass to the Starling constructor. It usually extends starling.display.Sprite.

    -frame two,com.example.StarlingRoot
    
  3. Wait for the SWF to be completely loaded. Listen for Event.COMPLETE on the loaderInfo object.

  4. In the Event.COMPLETE listener, call gotoAndStop(2) to switch to frame 2.

  5. Get a reference to the Starling root class by calling getDefinitionByName(). Do not import this class. If you import it, it will be compiled on frame 1 instead of frame 2, and then the preloader won't work.

    var RootType:Class = getDefinitionByName("com.example.StarlingRoot") as Class;
  6. Call getDefinitionByName() again to get a reference to starling.core.Starling. Again, do not import this class.

  7. Initialize Starling using the classes returned by getDefinitionByName().

Please see the comments in the example code for more detailed explanations.

This project is not designed to create a preloader with Flash Professional. It is meant as an example for Flash Builder or any other development environment that uses the command line compiler.

starling-preloader's People

Contributors

joshtynjala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starling-preloader's Issues

tiny problem

The "=" sign in Readme is forgotten in this line:

Use this compiler argument to put a class on frame 2.
-frame two,com.example.Main

(i.e. frame=2)

Was a problem when I copy pasted from there, no biggie but would help noobies out a bit :)

Mention that classes have to be in two separated packages

It could be nice if you mention somewhere that is really important to have both classes in two separated packages.

I say that because I got stock a moment because of this ;)

getDefinitionByName is not working for a class in the same package without using 'dummy' variable and if you create a 'dummy' variable, you include all the stuff you don't want.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.