Author Topic: Preloaders! Retro, and Flixel 1 loader.  (Read 4562 times)

Deviantgeek

  • Member
  • **
  • Posts: 63
  • Karma: +0/-0
  • Youngest flixel dev ever. Srsly.
    • View Profile
    • Devianix
Preloaders! Retro, and Flixel 1 loader.
« on: Tue, Mar 29, 2011 »
This is my collection of preloaders. To install one, place in the org.flixel.system folder of flixel, and use them the same way as the original loader, just replacing the FlxPreloader with FlxFactory, or FlxPreloaderAlt

Both preloaders under MIT license. Just don't claim them as your own.


Flixel 1 preloader. Requires these graphics:
loading_bar
loading_bit
use 'right click/save page as' to save them

Code: [Select]



package org.flixel.system
{
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.display.Sprite;

import org.flixel.FlxG;

public class FlxFactory extends FlxPreloader
{
[Embed(source='../data/loading_bar.png')]private var ImgBar:Class;
[Embed(source='../data/loading_bit.png')]private var ImgBit:Class;

protected var tmp:Bitmap;
/**
* @private
*/
protected var _bits:Array;

public function FlxFactory()
{
super();
}

override protected function create():void
{
_min = 0;
if(!FlxG.debug)
_min = minDisplayTime * 1000;

//create buffer
_buffer = new Sprite();
_buffer.scaleX = 2;
_buffer.scaleY = 2;
addChild(_buffer);

//create bmpBar
_bmpBar = new ImgBar();
_bmpBar.x = (stage.stageWidth/_buffer.scaleX-_bmpBar.width)/2;
_bmpBar.y = (stage.stageHeight/_buffer.scaleY-_bmpBar.height)/2;
_buffer.addChild(_bmpBar);

//create bits
_bits = new Array();
for(var i:uint = 0; i < 9; i++)
{
tmp = new ImgBit();
tmp.visible = false;
tmp.x = _bmpBar.x+2+i*3;
tmp.y = _bmpBar.y+2;
_bits.push(tmp);
_buffer.addChild(tmp);
}
}

override protected function update(Percent:Number):void
{
var i:int
var limit:uint = Percent*10;
for (i = 0; i < limit && (i < _bits.length); i++ )
_bits[i].visible = true;
}

override protected function destroy():void
{
super.destroy();
tmp = null;
_bits = null;
}
}
}

I also made a retro preloader which has all the features of the original loader too.

Code: [Select]
package org.flixel.system
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;

import org.flixel.FlxG;

public class FlxPreloaderAlt extends FlxPreloader
{
/**
* @private
*/
protected var _logoText:TextField;

public function FlxPreloaderAlt()
{
super();
}

override protected function create():void
{
_min = 0;
if(!FlxG.debug)
_min = minDisplayTime*1000;
_buffer = new Sprite();
_buffer.scaleX = 2;
_buffer.scaleY = 2;
addChild(_buffer);
_width = stage.stageWidth/_buffer.scaleX;
_height = stage.stageHeight/_buffer.scaleY;
_buffer.addChild(new Bitmap(new BitmapData(_width, _height, false, 0x313210)));
_bmpBar = new Bitmap(new BitmapData(7,1,false,0xD4D943));
_bmpBar.x = _width / 2 + 20;
_bmpBar.y = _height;
_buffer.addChild(_bmpBar);
_logoText = new TextField();
_logoText.defaultTextFormat = new TextFormat("system", 8, 0xD4D943);
_logoText.embedFonts = true;
_logoText.selectable = false;
_logoText.multiline = false;
_logoText.x = 0;
_logoText.y = _height - 15;
_logoText.width = 100;
_buffer.addChild(_logoText);
_logo = new ImgLogo();
_logo.scaleX = _logo.scaleY = 2;
_logo.x = 60;
_logo.y = _logoText.y;
_buffer.addChild(_logo);
_text = new TextField();
_text.defaultTextFormat = new TextFormat("system",8,0xD4D943);
_text.embedFonts = true;
_text.selectable = false;
_text.multiline = false;
_text.x = _bmpBar.x - 80;
_text.y = _height;
_text.width = 80;
_buffer.addChild(_text);
var bitmap:Bitmap = new Bitmap(new BitmapData(_width, _height, false, 0xffffff));
var i:uint = 0;
var j:uint = 0;
while(i < _height)
{
j = 0;
while(j < _width)
bitmap.bitmapData.setPixel(j++,i,0);
i+=2;
}
bitmap.x = (_width - bitmap.width) / 2;
bitmap.smoothing = true;
bitmap.blendMode = "overlay";
bitmap.alpha = 0.25;
_buffer.addChild(bitmap);
}

override protected function update(Percent:Number):void
{
_bmpBar.scaleY = -Percent * _height;
_text.y = _bmpBar.scaleY + _height;
_text.text = "Loading: "+Math.floor(Percent*100)+"%";
_text.setTextFormat(_text.defaultTextFormat);
_logoText.text = "Powered by   lixel";
_logoText.setTextFormat(_logoText.defaultTextFormat);
}

override protected function destroy():void
{
super.destroy();
_logoText = null;
}
}
}
« Last Edit: Thu, Sep 29, 2011 by Deviantgeek »

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Flixel 1 Preloader
« Reply #1 on: Wed, Mar 30, 2011 »
Nice work. Thank you.

Customising the preloader is actually a bit of a tricky thing, so thanks for this.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

Geti

  • Active Member
  • ***
  • Posts: 143
  • Karma: +0/-0
    • View Profile
    • 1 Bar Design
Re: Flixel 1 Preloader
« Reply #2 on: Wed, Mar 30, 2011 »
I've been wanting this for a while. I'll have a look soon, cheers

Deviantgeek

  • Member
  • **
  • Posts: 63
  • Karma: +0/-0
  • Youngest flixel dev ever. Srsly.
    • View Profile
    • Devianix
Re: Flixel 1 Preloader
« Reply #3 on: Thu, Mar 31, 2011 »
It is really just a copy-paste of the flixel 1 preloader. It is all plain AS3 code, it only needed the graphics, and a change from FlxFactory, to FlxPreloader

Geti

  • Active Member
  • ***
  • Posts: 143
  • Karma: +0/-0
    • View Profile
    • 1 Bar Design
Re: Flixel 1 Preloader
« Reply #4 on: Thu, Mar 31, 2011 »
I expected as much, I just never fished around in the old source :P

Deviantgeek

  • Member
  • **
  • Posts: 63
  • Karma: +0/-0
  • Youngest flixel dev ever. Srsly.
    • View Profile
    • Devianix
Re: Flixel 1 Preloader
« Reply #5 on: Sun, Apr 10, 2011 »
This still works with flixel 2.50. You just need to add one ../ to the image embeds, and stick it in org.flixel.system (or wherever the preloader is currently in now.)

Cadwallader

  • Member
  • **
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Flixel 1 Preloader
« Reply #6 on: Fri, Apr 15, 2011 »
I think site locking is bugged in this, though.

Deviantgeek

  • Member
  • **
  • Posts: 63
  • Karma: +0/-0
  • Youngest flixel dev ever. Srsly.
    • View Profile
    • Devianix
Re: Flixel 1 Preloader
« Reply #7 on: Mon, Apr 25, 2011 »
I think site locking is bugged in this, though.

I'm going to get that fixed soon. Should be up in the main post in an hour or so. I'm not posting a 2.43 version though, because it is easy to port it to there.

EDIT: nope, wont be easy to make the Flixel 1 loader work with all the flixel 2.5 functions.
« Last Edit: Mon, Apr 25, 2011 by Deviantgeek »

Deviantgeek

  • Member
  • **
  • Posts: 63
  • Karma: +0/-0
  • Youngest flixel dev ever. Srsly.
    • View Profile
    • Devianix
Re: Preloaders! Retro, and Flixel 1 loader.
« Reply #8 on: Mon, Apr 25, 2011 »
Ok, somehow got the flixel 1 loader working how I wanted it to.
All the preloaders are for 2.50, but can be altered for earlier versions.

Deviantgeek

  • Member
  • **
  • Posts: 63
  • Karma: +0/-0
  • Youngest flixel dev ever. Srsly.
    • View Profile
    • Devianix
Re: Preloaders! Retro, and Flixel 1 loader.
« Reply #9 on: Thu, Sep 29, 2011 »
I felt like bumping this even though it is an old topic, because custom preloaders are pretty sparse.