Archive for the ‘Flash’ Category

Smash Hits Badminton Beta

Thursday, October 20th, 2011

Yesterday I lauched my new badminton game, which is still in beta. It’s now available to the public with a couple of features already available, but with much more to come in the next months, including a much needed online multiplayer mode.

With already near 100 users and 200 games played in less than 48 hours, I hope this will be the game that fills the need of a complete badminton game on the web.

Feel free to come by and try it.

Play Smash Hits Badminton Online!

Flash – French Custom Character Embedding

Thursday, April 15th, 2010

These files contains character sets that you can embed in your dynamic textfields :

C:\Program Files\Adobe\Adobe Flash CS4\en\First Run\FontEmbedding\UnicodeTable.xml
C:\Users\{user}\AppData\Local\Adobe\Flash CS4\en\Configuration\FontEmbedding\UnicodeTable.xml

Add this set of unicode characters to add a French set of characters in the Character Embedding dialog :
(more…)

AS3 – Detect when mouse leaves stage

Thursday, March 4th, 2010

1
2
stage.addEventListener(Event.MOUSE_LEAVE, mouse_offstage);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouse_onstage);

AS3 – External Font Loading Class

Wednesday, February 10th, 2010

There is an easy way of loading external fonts embedded in swf files, using the etcs.ru.utils.FontLoader class. It loads the swf file, extract the font data directly at the bytes level, and register it to the Font class.

Here is a great tutorial for using the etcs.ru.utils.FontLoader class : http://www.thetechlabs.com/tutorials/flash/dynamically-loading-fonts-with-fontloader-and-applying-styles-with-css-stylesheet-in-as3/

I’ve put together a FontManager class that manages multiple swf files with this FontLoader class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package revoke.ca.fonts {
   
    import ru.etcs.utils.FontLoader;
    import flash.text.Font;
    import flash.events.EventDispatcher;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.events.IOErrorEvent;
    import flash.net.URLRequest;
   
    public class FontManager extends EventDispatcher {
       
        private var _font_loaders:Array;
        private var _data:Array;
        private var _cur_font:Number = -1;
       
        public function FontManager() {
            _font_loaders = [];
        }
       
        public function init(data:Array) {
            trace("FontManager::init");
            _data = data;
           
            for (var i:uint = 0; i < _data.length; i++) {
                var font_loader:FontLoader = new FontLoader();
                font_loader.addEventListener(ProgressEvent.PROGRESS, load_progress);
                font_loader.addEventListener(Event.COMPLETE, load_complete);
                font_loader.addEventListener(IOErrorEvent.IO_ERROR, load_error);
                _font_loaders.push(font_loader);
            }
            loadNext();
        }
       
        private function loadNext(){
            _cur_font++;
            if (_cur_font >= _data.length){
                trace("FontManager::total_load_complete");
                dispatchEvent(new Event(Event.COMPLETE));
                return;
            }
            _font_loaders[_cur_font].load(new URLRequest(_data[_cur_font]));
        }
       
        private function load_progress(event:ProgressEvent) {
            var ratio:Number = (event.bytesLoaded / event.bytesTotal + _cur_font) / _data.length;
            trace("FontManager:: PROGRESS : " + ratio);
        }
       
        private function load_error(event:IOErrorEvent) {
            trace("FontManager::load_error");
            dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR));
        }
       
        private function load_complete(event:Event) {
            trace("FontManager::load_complete");
            loadNext();
        }
       
        public function get_font_list():Array {
            var fonts:Array = [];
            for (var i:uint = 0; i < _font_loaders.length; i++){
                var cur_fonts:Array = _font_loaders[i].fonts;
                for each (var font:Font in fonts) {
                    Log.log("FontManager:: FONT LOADED : " + font.fontName);
                }
                fonts.splice(fonts.length, cur_fonts);
            }
            return fonts;
        }
    }
}

Usage :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.IOErrorEvent;

var font_data:Array = ["fonts/arial.swf", "fonts/helvetica.swf"];
var font_manager:FontManager = new FontManager();
font_manager.addEventListener(Event.COMPLETE, fonts_complete);
font_manager.addEventListener(ProgressEvent.PROGRESS, fonts_progress);
font_manager.addEventListener(IOErrorEvent.IO_ERROR, fonts_error);
font_manager.init(font_data);

function fonts_complete(event:Event):void {
    trace("Fonts Complete : " + font_manager.get_font_list());
}

function fonts_progress(event:ProgressEvent):void {
    trace("Fonts Progress : " + (event.bytesLoaded / event.bytesTotal));
}

function fonts_error(event:IOErrorEvent):void {
    trace("Fonts Error");
}

Flash AS3 Frameworks and Libraries

Thursday, November 26th, 2009

Here’s a list of 15 solid frameworks or libraries for Flash. There are a couple more in the comments below.

http://blog.activeden.net/resources/15-awesome-actionscript-3-frameworks-to-inspire-your-next-project/