Showing posts with label Flash. Show all posts
Showing posts with label Flash. Show all posts

Tuesday, September 30, 2008

Externalize Font with font subset, font weight and font style at the same time

You have a flash / flex application where you want to allow users to customize the text formatting, font style / font weight for some text box. So you would provide a small set of fonts which would all get embedded into the swf.

If we working with external fonts in Actionscript 3.0, the external font must have a class definition for allowing the Font class and ApplicationDomain to detect and register it. We can produce class definition for the external font  with embed tag in Flex or Font symbol in Flash library. 

In Flash CS3 you can create a font symbol in the library, and export it for ActionScript. But with this way if you embed the font in the library then flash automatically embeds all available characters. So the compiled external font swf size will increased and bloated the load-time with unused fonts. This was the largest issues especially if we working with Asian fonts. You can find more informations about it in this nice article

With Flex 3.0 and mxmlc (Flex SDK 2-3) there’s the embed metatag where you can even define font character ranges which should be embedded for reducing compiled external font swf size:

  1. [Embed(source='font.ttf', fontName='Font Name', unicodeRange='U+0021-U+0021, ... , U+2122-U+2122')]

or with this tag :

  1. [Embed(source='font.ttf', fontName='Font Name', fontWeight='bold', fontStyle='italic')]

Another nice article here

Unfortunatelly if we combining subset tag (unicodeRange) with fontWeight / fontStyle tag will cause a Flex compile error. I hope in Flex 4 this issue fixed.

This article explain the same approach, but it need to add extra font family (Bold or Italic) at specific font but Flex will still treat them as separate fonts.

 

All the examples (both Flash CS3 or Flex 3.0) I’ve seen so far only address the loading of one font either in regular weight or bold, but not one (subset characters ranges) fonts with regular, weight, italic or bold-italic at the same time. And it seem very difficult for export one (subset characters ranges) font as external font, (ie loading the font from an external swf) and change font weight / font style at runtime in loader (main app) swf.

Luckily I was able make something worked, here what I did :

  1. Embed font in FLA file with instance textfield at the stage (Benefit: we can make subset of required glyphs only, and font style/weight). We need create four instances textfield (Regular, Bold, Italic and Bold-Italic texfield) and publish the swf for each font, (ie. Verdana_Style.swf for Verdana). In this step the published swf doesn’t contain class definition yet. So we can not import it at runtime.
  2. Transcoding the published swf (also give a class definition) with Flex 3.0 compiler with Embed metatag and publish to final external swf font (i.e Verdana.swf)
    package
    {
     import flash.display.Sprite;
     import flash.text.Font;                         

    public class Verdana extends Sprite
     {

    [Embed(source='library/fontstyle/Verdana_Style.swf', fontName='Verdana')]
       public static var regular:Class;

    [Embed(source='library/fontstyle/Verdana_Style.swf', fontName='Verdana', fontWeight='bold')]
       public static var bold:Class;

    [Embed(source='library/fontstyle/Verdana_Style.swf', fontName='Verdana', fontStyle='italic')]
       public static var italic:Class;

    [Embed(source='library/fontstyle/Verdana_Style.swf', fontName='Verdana', fontWeight='bold', fontStyle='italic')]
       public static var boldItalic:Class;

    public function Verdana()
       {
         super();

      Font.registerFont ( regular );
         Font.registerFont ( bold );
         Font.registerFont ( italic );
         Font.registerFont ( boldItalic );
       }

    }
    }
  3. Import the final external swf font at runtime to main application.
    Here the simple actionscript 3.0 with 
    Lithos Pro Regular font demo.

    package {
     import flash.display.Loader;
     import flash.display.Sprite;
     import flash.events.Event;
     import flash.net.URLRequest;
     import flash.text.*;    

    public class DemoExternalFontSimple extends Sprite
     {
       public static const FONT_NAME:String = 'Lithos Pro Regular';
       public static const FONT_LIB:String = "LithosProRegular.swf";

    public function DemoExternalFontSimple ()
       {
         loadFont ('fontlib/'+FONT_LIB);
       }

    private function loadFont ( url:String ) : void
       {
         var loader:Loader = new Loader ();
         loader.contentLoaderInfo.addEventListener ( Event.COMPLETE, fontLoaded );
         loader.load (new URLRequest ( url));
       }

    private function fontLoaded ( event:Event ) : void
       {
         drawText();
       }
     }
    }
       public function drawText () : void
       {
         var tf:TextField = new TextField ();
         tf.defaultTextFormat = new TextFormat (FONT_NAME, 16, 0);
         tf.embedFonts = true;
         tf.antiAliasType = AntiAliasType.ADVANCED;
         tf.autoSize = TextFieldAutoSize.LEFT;
         tf.text = FONT_NAME + " Regular was here...:;*&^% ";
         tf.selectable = false;
         tf.rotation = 1;
         tf.x = 10;
         tf.y = 10

    var tf2:TextField = new TextField ();
         tf2.defaultTextFormat = new TextFormat (FONT_NAME, 16, 0, true);
         tf2.embedFonts = true;
         tf2.antiAliasType = AntiAliasType.ADVANCED;
         tf2.autoSize = TextFieldAutoSize.LEFT;
         tf2.text = FONT_NAME + " Bold was here...:;*&^% ";
         tf2.selectable = false;
         tf2.rotation = 1
         tf2.x = 10;
         tf2.y = 50

    var tf3:TextField = new TextField ();
         tf3.defaultTextFormat = new TextFormat (FONT_NAME, 16, 0, false, true);
         tf3.embedFonts = true;
         tf3.antiAliasType = AntiAliasType.ADVANCED;
         tf3.autoSize = TextFieldAutoSize.LEFT;
         tf3.text = FONT_NAME + " Italic was here...:;*&^% ";
         tf3.selectable = false;
         tf3.x = 10;
         tf3.y = 100

    var tf4:TextField = new TextField ();
         tf4.defaultTextFormat = new TextFormat(FONT_NAME, 16, 0, true, true);
         tf4.embedFonts = true;
         tf4.antiAliasType = AntiAliasType.ADVANCED;
         tf4.autoSize = TextFieldAutoSize.LEFT;
         tf4.text = FONT_NAME + " Bold Italic was here...:;*&^% ";
         tf4.selectable = false;
         tf4.x = 10;
         tf4.y = 150;

    addChild(tf);
         addChild(tf2);
         addChild(tf3);
         addChild(tf4);
       }

Friday, August 15, 2008

In Flash Platform We Trust!

Perhaps ActionScript 3.0 is more proprietary than it was last week. It’s still extension of ECMAScript and still holds a lot of the core values, namespaces and package. Maybe EcmaScript 4.0 was stillborn, and maybe the harmony will change the future of language/ the standards committe.

I think our joint concerns are better served if we keep in mind that most valuable point is abc file , no matter which language it compiling from (actionscript 3.0, haXe or javascript). So let keep saying to yourself “In flash platform I trust..!”

Saturday, July 12, 2008

Nice Flash & AIR debugger

It's a simple AIR based debugger for flash & AIR apps.
Arthropod is really easy to use, the only thing you need to do is import the Debug class, write a log message with the log function, start Arthropod and publish your site / AIR application.

Nice application to try

Saturday, June 07, 2008

M3D, Mascot Capsule 3D porting to Actionscript 3.0, next candidates for 3DEngines

One day several years ago after Actionscript 3.0 released, I've been believed the time will coming someday if this 3D engines will be porting to Actionscript.

Mascot Capsule 3D and Mobile 3D Graphics has been used as technologies  for Mobile 3D programming for the Java™ Platform Micro Edition on Sony Ericsson feature phones.

This 3D Engine has been designed from the ground up for mobile devices,taking into account limited memory, performance and control interfaces.
It completely abstracts the underlying operating system and device hardware, allowing game developers to develop once on Windows and then deploy to multiple mobile platforms. Includes complete support for multi-channel audio, 2D and 3D graphics,
a powerful and fully configurable 3D scene graph, collision checking,
physics simulation, networking with both Bluetooth and IP based networks.

It will be strong candidate for competing againts with existed 3D Actionscript engine (PV3D or Away 3D or Sandy3D).

Yesterday one of showcase has been published. Look at ecodazoo.com, this site strongly suspected use M3D engine, similar with Mascot Capsule 3D.

It could be next step 3D Flash website interface just begin, and I think web people will follow.

Further info about M3D see www.touchtao.com
Mobile Capsule 3D see Mobile 3D

In my humble opinion, correct me if i'm wrong!

Blogged with the Flock Browser

Saturday, May 24, 2008

Merapi, bridge AIR platform to Java Environment

Definition of Merapi originally a volcano in Central Java, but there's a new term about Merapi :

"Merapi is a bridge between applications written in Java and those running in and created for Adobe AIR™ (Adobe Integrated Runtime™)."

Merapi has huge potential and we can looking forward discovering possibility when we can combine the power of Java with the richness and ubiquity of Adobe AIR.

Another project is Artemis active on Apollo (Adobe AIR beta) era but it was abandoned. Today the project rebirth under the name of Merapi.
Merapi use Java to connect AIR to the desktop. The project will be (unfortunately not yet) distributed as a freeware and then as an open source project on Google Code.

Using Merapi, Adobe AIR™ applications can "talk" to other software that the user has installed on their computer. In addition, Merapi allows AIR™ applications to serve as a user interface to just about anything that a Java™ application can do on a user's computer.

Tuesday, May 20, 2008

New protocol on Flash Player 10

I am very excited about this new protocol on Flash Player 10. The new RTMFP protocol in Flash Player 10 provides an alternative to RTMP allowing developer to develop real-time communication applications with an improved user experience.

Applications like chat and games are great examples from this technology. This new protocol has been designed for communication solutions, not massive content delivery.

Another great news is UDP protocol now available on Flash Player 10 beta. Adobe chose UDP because it’s an efficient protocol for low-latency streaming video conversations, voice conversations or other similar solutions. UDP combined with the high-fidelity of SPEEX audio, will allow Flash developer to build great voice and audio solutions targeting Flash Player 10. To enable RTMFP and the UDP transport, authorization from a future server-based technology such as Adobe Flash Media Server will be required.

Thursday, May 15, 2008

Looking at Flash Player 10 features

Nice news, Flash Player 10, code-named “Astro,” enables run applications and animation smoother and faster with expanded use of hardware acceleration. With capability to moving several visual processing tasks to the video card, and the CPU is free to do more.

In 3D features, lightweight and native built in 3D effects make easily transform and animate any display object through 3D space while retaining full interactivity.

More informations regarding prerelease of Flash Player 10, read here

Sunday, March 30, 2008

Perbandingan API Event pada beberapa Actionscript 3.0 3D engines

Dari 3 (tiga) 3D Engines Actionscript3.0 yang populer saat ini (PV3D, Away3D, Sandy3D), masing-masing punya kelebihan dan kekurangan masing-masing.

Tapi dari semua API yang mereka tawarkan, seperti API tool lainnya yang ku anggap point penting pertama kali adalah API yang mengurus event.

Papervision3D (sorry ya..) kuanggap terlambat untuk urusan Event ini. Sampai versi Beta RC1 saat ini, event yang ada cuma FileEvent, hari geneee.. cuman ngurusin dispatch loader saja?

Away3D dan Sandy3D sudah agak mendingan.

Event di Away 3D (versi 1.9.4) :

FaceEvent
MeshElementEvent
SegmentEvent
MouseEvent3D
Object3DEvent
LazyEventDispatcher


Event di Sandy3D (3.0.2) :

BubbleEvent, BubbleEventBroadcaster, EventBroadcaster
QueueEvent
SandyEvent
Shape3DEvent


Saat ini MouseVent3D dari Away3D yang suitable dalam project yang membutuhkan informasi koordinat x,y,z dari mouse-trigger di scene 3D swf kita.

Agak repot bila pakai Sandy3D atau PV3D. Papervision3D malah cuma menawarkan MouseEvent bawaan class Sprite di Object3Dnya, alhasil cuma koordinat 2D yang didapat, apalagi bila dirender dalam 1 container maka localX dan localY yang di-dispatch jadi statis belaka, capee deh!!

Monday, March 24, 2008

XFL

Sejak dari pertama, Flash IDE menyimpan sources document dalam format yang kita kenal sebagai .fla.
Format .fla nyaris tidak bisa dibuka di software third-party lainnya karena spesifikasinya tidak pernah dipublikasikan.

Pada versi mendatang dari Flash Ide, yaitu Flash CS4 memungkinkan untuk meng-export dan meng-import format source document Flash baru yang disebut XFL.
XFL berformat .zip yang berisi material-material yang diperlukan sebuah dokumen Flash.
Terdapat file XML yang menjelaskan struktur dokument, dan sebuah folder yang berisi asset-asset (graphic, sound, dan lainnya).

Penjelasan resmi dari detail format XML belum ada pemberitahuan. Tetapi Richard Galvan (authoring product-manager) memastikan bahwa Adobe akan mempublikasikannya, dan memperbolehkan took-tool Third-Party untuk meng-import dan meng-export XFL.

Mestinya nanti akan ada banyak Third Party lain yang menyediakan fasilitas export ke XFL, seperti PowerPoint, 3D tools, Photoshop dan lainnya.

Yang lebih menarik bila Adobe me-release compiler XFL ke SWF secara tersendiri, pasti tidak repot membuka Flash IDE untuk meng-compile XFL ke swf. Cukup seperti commandline tool saja, apalagi free, misal namanya XFL-to-SWF compiler.

Thursday, March 06, 2008

SWF 9 Decompiler

Beberapa decompiler untuk swf 9 / actionscript 3.0 sudah mulai bertebaran :

- Imperator Fla 4.0
- SoThink SWF Decompiler 4.0
- ASV 6.0

Tidak ada tempat yang benar-benar aman untuk coding..

Tuesday, November 13, 2007

Flash Lite 3.0 Security Sandbox

Terdapat perbedaan security sandbox pada Flash Lite 3.0 dibanding versi-versi Flash Lite terdahulu. Secara umum Flash Lite 3.0 mengikuti model dari Flash 8 security.
Ketemu masalah yang baru ku sadari ketika ingin membuat aplikasi Flash Lite 3.0 dengan menggunakan XMLSocket yang berhubungan dengan SocketServer lokal yang dibuat dengan Python di N95, (ide ini secara umum sudah diterapkan di Flyer Framework).
Terdapat kesulitan untuk koneksi, pertama kali aku menduga hal ini disebabkan perbedaan versi interpreter Python yang ku pakai (1.4.1) dengan os device.
Setelah berapa kali utak-atik, akhirnya ku coba dengan emulator Adobe Device Central CS3 di PC untuk koneksi dengan server socket sederhana di Python Desktop, ternyata berhasil terkoneksi.
Ketika dicoba di device tetap gagal, demikian pula ketika di coba diputar dengan Flash Player 9 terdapat dialog security window.
Setelah membaca Local file security ada beberapa penjelasan yang membantu penyelesaian masalah.

# Trust management is done by the host application in Flash Lite.

Flash Lite 3.0 standalone player sebagai host.

# No trust configuration files are required in Flash Lite.
Ini yang repot bila kita membuat local swf yang ingin akses ke network.
Dengan begitu mekanisme load 'cross-domain policy files' tidak akan membantu??

# SWF file developers, manufacturers, and carriers must make all security decisions in Flash Lite. There is no user-mediated trust, or Settings Manager. However, the host application may provide a mechanism by which users can make limited security decisions. For example, the host may allow users to designate a particular SWF file as trusted.

Beberapa aplikasi swf2sis seperti Janus, KuneriLite yang bertindak sebagai host mungkin dapat menangani hal ini di Flash Lite 1.x - 2.x, tapi belum ada pemberitahuan untuk FL3.

# Prohibited operations fail silently; no dialog box is displayed in Flash Lite.
Ini yang membuat pusing pada awalnya, tidak ada pesan kesalahan atau koneksi gagal yang disampaikan.

Mestinya untuk Flash Lite harus ada fasilitas On Device Debug seperti kepunyaannya SonyEricsson.

Sunday, November 04, 2007

I got my FlashLite 3.0

Setelah agak lama menunggu, akhirnya FlashLite 3.0 Developer Edition yang ku request 3 minggu lalu mampir juga di inbox. Sebuah email dari Richie Teo (Adobe System Incorporated) berisi attachment SIS langsung ku download.

FlashLite edisi developer ini merupakan standalone, jadi tidak terintegrasi dengan web browser built-in dari N95. Nokia sendiri telah mengumumkan dukungan FlashLite 3.0 pada device terbaru mereka dalam waktu dekat.

FlashLite 3.0 mempunyai perbedaan dengan FlashLite versi-versi sebelumnya seperti pada performance (rendering, scripting speed, dan code optimization) yang 25% - 30% lebih baik, manajemen memory yang lebih efisien, dukungan terhadap FLV, Emoticons in predefined color, External API for browser scripting.

Informasi tentang FlashLite 3.0 lebih lanjut dapat di lihat di FlashLite Features, FlashLite version comparison, FlashLite architecture, Nokia CreativePro.

Saat ini tidak ada link langsung untuk download FlashLite 3.0 dan aku tidak bisa membagikannya karena SIS-nya IMEI depending, bila anda tertarik bisa merequest via email, petunjuk lebih lanjut bisa dibaca disini.

Untuk eksperimen lebih lanjut terutama mobile video dengan FlashLite 3.0 belum bisa ku posting, karena masih diluar kota. Tapi sebagai persiapan ada baiknya anda download Flash Lite 3.0 Update for Flash CS3 Pro and Device Central CS3 dari MaD Developer Center.

Friday, October 12, 2007

Meski terasa sulit mengucapkannya, tetapi...

Meski terasa sulit mengucapkannya, tetapi tetaplah tulus kami menghaturkannya :



/**
* @langversion Actionscript 3.0
*
*/

function
selamatLebaranUntuk(penerima:Person):String{

var teks:String = "Assalamualaikum " + penerima.getNama() + "\n";
teks += "Kami sekeluarga mengucapkan : \n";
teks += "Minal Aidin Wal Faidzin\n";

var arrayKhilaf:Array = BukuKesalahanDanKhilaf.getKhilafTo(penerima);

for(var i:int = 0; i<= arrayKhilaf.length; i++){

var khilaf:Khilaf = arrayKhilaf[i] as Khilaf;
teks += "Mohon Maaf Lahir dan Batin,\n";
teks += "bila ada kesalahan berupa " + khilaf.detail + "\n";
teks += "sewaktu " + khilaf.getTime() + "\n";
teks += (khilaf.isSengaja) ?
"yang tersengaja \n" :
"yang tidak kami sadari\n\n" ;
}

teks += "\n\n";
teks += "Di Idul Fitri 1428 H ini, semoga tetap terjaga silaturahmi\n";
teks += "dan kebersamaan kita\n";
teks += "Wassalamualaikum Wr. Wb\n";
teks += "Deden Ramadhan sekeluarga.";

return teks;

}

trace(selamatLebaranUntuk(anda));