Showing posts with label as3. Show all posts
Showing posts with label as3. Show all posts

Thursday, September 13, 2007

loading resource swf in AS3

if you want to put all the resource( movieclip, font,sound..) in external swf and
want to load it later and then extract the content at run time, you should check this
article from Wildwinter site

Saturday, September 8, 2007

move child from one parent to another - as3

saw it on Flashcoders,Greetz Erik reply "Copy and paste a movieClip?"
here is quote from him:

Yes in AS3 you can move DisplayObjects to other parents without problems.
One thing to note is that you need to remove it from the current display
list before you add it to the other.

Something like this:

parent1.removeChild(theClip);
parent2.addChild(theClip);

i didn't know it, i will give it a try

Friday, September 7, 2007

as3 Display List

if you want to port as2 to as3, take a look at this article wrote by Josh Tynjala

Monday, August 27, 2007

good AS3 xml e4x tutorial

Roger Braunstein wrote a good tutorial of using xml e4x in action script 3.0

go here and have a look

Saturday, August 4, 2007

AS3 Data Structures For Game Developers

source : http://lab.polygonal.de/ds/

svn: http://as3ds.googlecode.com/svn/trunk/ as3ds

Description

‘AS3 Data Structures For Game Developers’ is a package containing common data structures useful for flash game programming and application development. The project was started because I wanted a unified library which I could reuse in my games.
Design Decisions

I have tried to provide just the bare algorithms, coupled with a minimum set of methods I think are most useful to work with. Simplicity and performance were the key guidelines for the whole package. Therefore,

- all structures are untyped and can be fed with any kind of data. This makes usage more flexible and simple, since you don’t have to create special container classes which extend base classes and/or implement interfaces.

- I’m often not following strict design patterns and OOP-practices. For example, to access a classes’ property, I just define it as public instead of writing functions to read/write the property (which is also faster).

- all classes reside in a single package, simply because its hard to separate them - e.g. a linked list can bee seen as a tree, and a tree on the other side is a loose linked list.

- many structures use custom code rather that utilizing the data structure classes themselves - for example the graph structure could be implemented by using the linked list and queue classes, but a plain array works faster behind the scenes.
Collections

Almost all classes implement the Collection interface, which defines the following methods:

contains(obj:*), for checking if an item exists
clear(), for removing all items
getIterator(), for creating an iterator object to step through all items
size, the total number of items and
toArray(), which simply converts the structure into an array.
Using Iterators

Every class that implements the Collection interface is also able to create an iterator object using the getIterator() method. Once you have an iterator, you can walk through the data and read/write the values like so:

var myItr:Iterator = getIterator();
var value:*;

//read all values
while (myItr.hasNext())
{
value = myItr.next();
}

//write new value
myItr.start();
while (myItr.hasNext())
{
myItr.data = "newValue";
next();
}

//the same with a for loop
for (myItr.start(); myItr.hasNext(); myItr.next())
{
value = myItr.data;
}

Keep in mind that an iterator implies no order in which the items are processed. Some classes also support a more complex iterator like the linked list or the tree. This is necessary because you can iterate in more directions (forth, back, up, down..). You get those iterators by performing a downcast or simply calling a special method:

var listItr:ListIterator = myLinkedList.getIterator() as ListIterator;
var listItr:ListIterator = myLinkedList.getListIterator();

The Structures
Multi-Dimensional Arrays

The library contains a two-dimensional and three-dimensional array. They are both implemented by a single linear array rather than nested arrays. This is the fastest method in flash to simulate multi-dimensional arrays and outperforms the nested array method because multiple array lookups are slower compared to one lookup combined with a simple arithmetic expression (which you can also often precompute in the outer loop). The most obvious application would be a tilemap in 2d or a layered tilemap in 3d.
Queue

This is also called a FIFO structure (First In - First Out). The queue comes in two variations, which have the same methods, but differ in their implementations: There is the arrayed queue, which obviously uses an array internally, and the linked queue, which is build upon a linked list. They are both very similar, except that the arrayed version has a fixed size and is faster.
A common application would be a command queue - imagine you have a unit in a strategy game and apply many commands which the unit should follow. All commands are enqueued and afterwards dequeued and processed in order.
Stack

Also commonly know as a FILO structure (First In - Last Out). Like the queue, this comes in two flavors: arrayed and linked. A stack is often not used directly, but a very important concept in programming. Please note, that a queue and a stack are not real structures, because they just define how data is accessed rather then stored.
Tree

A node-based structure. Every tree starts from a single node, called the root node. The root node can contain any number of child nodes, and every child node can again contain children. A tree node with no children is called a leaf node. In fact if you draw the nodes of a tree it looking like a real tree with branches. The AS3 display architecture is also a tree structure, so you could use this to manage your display objects and update them by traversing through the tree. Also, this is useful for decision trees, BVHs, storing a plot line or storing data recursively by applying the composite pattern.
Binary Tree

This is just a specialized kind of tree where each node is only allowed to have up to two children, called the left and right node. Binary trees are very often used for parsing input data, for example arithmetic expressions or when building a scripting system.
Binary Search Tree (BST) and Hash Table

Both structures store data that can be retrieved quickly by using a key. The method however differers greatly: The BST uses a recursive approach to split up large amounts of data into smaller sets. A hash table stores sparse key-based data using a hash-key in a small amount of space.
Linked Lists

A linked list is similar to an array. The main difference is that in an array, each cell contains just the data and is accessed by an index. A linked list consists of several node objects, which in addition to storing the data, manage a reference to the next node (singly linked) or to the next and previous node (doubly linked) in the list. Think of it as a more natural approach to work with sequential data.
Other benefits are that you can insert and remove data quickly by just calling the appropriate method on the node itself - you don’t have to manage array indexes. Also in AS3 object access is faster than array access, so it competes very well in terms of performance when iterating over the list.
Heap and Priority Queue

A Heap is a special kind of binary tree in which every node is bigger than its child nodes. Whatever you throw into a heap, it’s automatically sorted so the item with the ‘most significant’ value (depending on the comparison function) is always the front item. A priority queue is build upon the heap structure, and can manage prioritized data - which can be used in limitless ways.
Graph

A graph is a loose node-based structure. Nodes are connected with arcs, and every node can point to any other node. They can also point to each other creating a bi-directional connection. It is essential for path finding, AI, soft-body dynamics with mass-springs systems and a lot more.
Bit Vector

A bit vector is some kind of array in which you can store boolean values (true/false - 1/0) as close as possible without wasting memory. I currently can’t think of a reasonable application, because usually you should have enough memory - but it’s nice to have because it shows basic bit masking operations.

as3 duplicateMovieClip Replacement

source : here

ActionScript 3 no longer has a duplicateMovieClip method for MovieClip instances (or any DisplayObject instances). Instead, it's suggested that you just create a new instance of the display object you wish to duplicate using its constructor. This, however, is not the same as duplicateMovieClip, and, really, is more like using AS1 and AS2's attachMovieClip. For a more accurate representation of duplicateMovieClip in AS3, consider the following function:

package com.senocular.display {

import flash.display.DisplayObject;
import flash.geom.Rectangle;

/**
* duplicateDisplayObject
* creates a duplicate of the DisplayObject passed.
* similar to duplicateMovieClip in AVM1
* @param target the display object to duplicate
* @param autoAdd if true, adds the duplicate to the display list
* in which target was located
* @return a duplicate instance of target
*/
public function duplicateDisplayObject(target:DisplayObject, autoAdd:Boolean = false):DisplayObject {
// create duplicate
var targetClass:Class = Object(target).constructor;
var duplicate:DisplayObject = new targetClass();

// duplicate properties
duplicate.transform = target.transform;
duplicate.filters = target.filters;
duplicate.cacheAsBitmap = target.cacheAsBitmap;
duplicate.opaqueBackground = target.opaqueBackground;
if (target.scale9Grid) {
var rect:Rectangle = target.scale9Grid;
// Flash 9 bug where returned scale9Grid is 20x larger than assigned
rect.x /= 20, rect.y /= 20, rect.width /= 20, rect.height /= 20;
duplicate.scale9Grid = rect;
}

// add to target parent's display list
// if autoAdd was provided as true
if (autoAdd && target.parent) {
target.parent.addChild(duplicate);
}
return duplicate;
}
}

usage:
import com.senocular.display.duplicateDisplayObject;

// create duplicate and assign to newInstance variable
// using true for autoAdd automatically adds the newInstance
// into the display list where myOldSprite is located
var newInstance:Sprite = duplicateDisplayObject(myOldSprite, true);
newInstance.x += 100; // shift to see duplicate


The only thing duplicateMovieClip does that this does not is copy dynamic drawing information. Currently, the graphics object in display objects cannot be duplicated so there is no way to obtain that information for duplicates in duplicateDisplayObject.

Thursday, August 2, 2007

[AS3] Full browser background with smoothing

source

This will load a image and scale it to the browsers scale.

Demo:
http://gfxcomplex.com/labs/full_browser_bg_as3.html

Background image by darkmotion:
http://www.deviantart.com/deviation/46131446/

AS3 source:
http://gfxcomplex.com/labs/full_browser_bg_as3.zip

:: Added two Events and two read only public methods for preloading.
Plus new fade image in Timer.

Methods————————
BrowserBackground.bytesLoaded; returns a :Number and is read only
BrowserBackground.bytesTotal; returns a :Number and is read only

Events————————–
BrowserBackground.BACKGROUND_LOADING dispatchis a events for progress of a Loader object, as well updates the BrowserBackground.bytesLoaded and BrowserBackground.bytesTotal.

BrowserBackground.BACKGROUND_LOADED dispatchis an event upon a full and complete load of the Load object.

Sample use code.

package {
import com.gfxcomplex.display.BrowserBackground;
import flash.display.Sprite;
import flash.events.Event;
public class MainDoc extends Sprite {
private var _bg:BrowserBackground;
public function MainDoc() {
_bg = new BrowserBackground(”http://gfxcomplex.com/images/Damn_utensils_by_darkmotiondotcom.jpg”);
addChild(_bg);
_bg.addEventListener(BrowserBackground.BACKGROUND_LOADING, loading);
_bg.addEventListener(BrowserBackground.BACKGROUND_LOADED, loaded);
}
private function loaded(e:Event):void {
_bg.removeEventListener(BrowserBackground.BACKGROUND_LOADING, loading);
_bg.removeEventListener(BrowserBackground.BACKGROUND_LOADED, loaded);
}
private function loading(e:Event):void {
var bL:Number = _bg.bytesLoaded;
var bT:Number = _bg.bytesTotal;
}
}
}

Source Code::

*////////////////////////////////////////////////////
//////////////////////////////////////////////////////
////
//// Full Browser background image
////
//// by Josh Chernoff ( GFX Complex )
//// Copy right ~ josh chernoff ~ 2007
//// All rights reserved
////
////
//// May be redistributed under The
//// GNU General Public License (GPL) Agreement
////
//////////////////////////////////////////////////////
*//////////////////////////////////////////////////////*
Class constructor requires only one argument
url:String for loading the background
public class BrowserBackground(url:String);
*/package com.gfxcomplex.display{import flash.display.Sprite;
import flash.system.LoaderContext;import flash.display.StageAlign;

import flash.display.StageScaleMode;

import flash.display.Bitmap;

import flash.display.Loader;

import flash.events.Event;

import flash.events.TimerEvent;

import flash.events.ProgressEvent;

import flash.net.URLRequest;

import flash.utils.Timer;

public class BrowserBackground extends Sprite{

public static const BACKGROUND_LOADED:String = “backgroundLoaded”;

public static const BACKGROUND_LOADING:String = “backgroundLoading”;

private var _bytesLoaded:Number;

private var _bytesTotal:Number;

private var _imageHolder:Sprite;

private var _bitmap:Bitmap;

private var _loader:Loader;

private var _timer:Timer;

public function get bytesTotal():Number{

return _bytesTotal;

}

public function get bytesLoaded():Number{

return _bytesLoaded;

}

function BrowserBackground(url:String) {

var context:LoaderContext = new LoaderContext();

context.checkPolicyFile = true;

_loader = new Loader();

_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);

_loader.load(new URLRequest(url), context);

}

private function completeHandler(event:Event):void {

var sW:Number = stage.stageWidth;

var sH:Number = stage.stageHeight;

_imageHolder = new Sprite();

_timer = new Timer(50, 44);

_bitmap = Bitmap(event.target.loader.content);

_bitmap.y -= _bitmap.height;

_bitmap.smoothing = true;

addChild(_imageHolder);

_imageHolder.addChild(_bitmap);

_imageHolder.width = sW;

_imageHolder.scaleY = _imageHolder.scaleX;

if (_imageHolder.height < sH) {

_imageHolder.height = sH;

_imageHolder.scaleX = _imageHolder.scaleY;

}

_imageHolder.y = sH ;

_imageHolder.alpha = 0;

_timer.addEventListener(TimerEvent.TIMER, timerListener);

_timer.start();

stage.scaleMode = StageScaleMode.NO_SCALE;

stage.stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, stageResized);

dispatchEvent(new Event(BrowserBackground.BACKGROUND_LOADED));

_loader = null;

}

private function progressHandler(event:ProgressEvent):void {

_bytesLoaded = event.bytesLoaded;

_bytesTotal = event.bytesTotal;

dispatchEvent(new Event(BrowserBackground.BACKGROUND_LOADING));

}

private function timerListener(e:TimerEvent){

_imageHolder.alpha += .025;

if(_imageHolder.alpha >= 1){

_imageHolder.alpha = 1;

_timer.stop();

_timer.removeEventListener(TimerEvent.TIMER, timerListener);

_timer = null;

}

e.updateAfterEvent();

}

private function stageResized(event:Event):void {

var sH:Number = stage.stageHeight;

_imageHolder.width = stage.stageWidth;

_imageHolder.scaleY = _imageHolder.scaleX;

if (_imageHolder.height < sH) {

_imageHolder.height = sH;

_imageHolder.scaleX = _imageHolder.scaleY;

}

_imageHolder.y = sH;

}

}
}

Event.bubbles, Event.cancelable, and Event.currentTarget

original author : Ruben Swieringa

source: Ruben Swieringa's blog

== some quote for mhis blog ==
Perhaps some of you may not know this, but event-bubbling in Actionscript3.0 is way cool and well worth your attention. So read on.

With event-bubbling you can let one Event subsequently call on every ancestor (containers of containers of etc.) of the DisplayObject that originally dispatched the Event, all the way up to the surface (read: Stage), hence the name ‘bubbling’.
Perhaps noteworthy is that bubbling for an Event instance is disabled by default, and can only be activated by setting the bubbling parameter in the Event constructor.

Although the documentation doesn’t seem to make it all too apparent, event-bubbling is actually the reason why the Event class has a currentTarget property (as well as a target property).
So what is the use of Event.currentTarget? While the target property will always have its value set to the DisplayObject that originally dispatched the Event, the currentTarget property always points to the DisplayObject that the event is currently processing (i.e. bubbling at).

Now, you will probably not always want your Event to bubble all the way up to the Stage of your movie. This is where the cancelable property comes into the picture.
Setting the cancelable property contructor-parameter to true allows you to call the stopPropagation() and stopImmediatePropagation() methods later on. Both methods basically abort the bubbling process.
The difference here is that the latter also aborts execution of other listeners for the same Event-type on the same currentTarget, whereas the former only aborts execution of listeners to subsequent targets.

The following example attempts to visualize the concept of event-bubbling in AS3. Click the big button in the middle to dispatch a bubbling Event, and tick the CheckBoxes to have that Event canceled at a specific parent of the Button. Right-click to view source.

=====
you can also find a great example on his blog.

Thursday, July 26, 2007

Actionscript 3 Resources

source: here
http://www.kirupa.com/forum/showthread.php?t=223798

http://www.were-here.com/homepage/default.asp

http://www.senocular.com/

how do i find the path to where a MC belongs

source 1:
http://www.kirupa.com/forum/showthread.php?p=1935107

Hello :)

in AS3 i don't find a native method ?

For the moment you can test :

package
{

import flash.display.* ;

public class test extends Sprite
{

/**
* Creates a new test instance.
*/
public function test()
{

var container:Sprite = new Sprite() ;

var container2:Sprite = new Sprite() ;
container2.graphics.beginFill(0xFF0000, 1) ;
container2.graphics.drawCircle(0, 0, 150) ;

addChild(container) ;
container.addChild(container2) ;

var target:String = getDisplayPathName(container2) ;

trace( target ) ;

}

static public function getDisplayPathName( display:DisplayObject
):String
{

var parents:Array = [] ;
var parent:* = display ;

while( true )
{
parents.push( parent.name ) ;
parent = parent.parent ;
if (parent.name == null)
{
break ;
}
}

parents.reverse() ;

return parents.join( "." ) ;

}

}

but it's not the better solution lol

eKA+ :)

alternative to mx classes

found in osflash mailing list


The AS3 version of the remoting class in VEGAS :

http://svn1.cvsdude.com/osflash/vegas/AS3/trunk/src/asgard/net/remoting/

With an example :

package
{

import asgard.events.ActionEvent ;
import asgard.events.RemotingEvent ;

import asgard.net.remoting.RemotingService;
import asgard.net.remoting.RemotingAuthentification;

import flash.display.Sprite ;

import test.User ;

public class TestAsgardRemoting extends Sprite
{

// ----o Constructor

public function TestAsgardRemoting()
{

// ----o Register your shared Class.

User.register() ;

// ----o Create Service

var service:RemotingService = new RemotingService() ;

service.addEventListener(RemotingEvent.ERROR, onError) ;
service.addEventListener(RemotingEvent.FAULT, onFault) ;
service.addEventListener(ActionEvent.FINISH, onFinish) ;
service.addEventListener(RemotingEvent.RESULT, onResult) ;
service.addEventListener(ActionEvent.START, onStart) ;
service.addEventListener(RemotingEvent.TIMEOUT, onTimeOut) ;

service.gatewayUrl = "http://localhost/work/vegas/php/gateway.php" ;
service.serviceName = "Test" ;
service.methodName = "getUser" ;
service.params = ["eka", 29, "http://www.ekameleon.net"] ;

// ----o Launch Service

service.trigger() ;

}

// ----o Public Methods

public function onError(e:RemotingEvent):void
{
trace("> " + e.type + " : " + e.code) ;
}

public function onFinish(e:ActionEvent):void
{
trace("> " + e.type) ;
}

public function onFault(e:RemotingEvent):void
{
trace("> " + e.type + " : " + e.getCode() + " :: " + e.getDescription()) ;
}

public function onProgress(e:ActionEvent):void
{
trace("> " + e.type ) ;
}

public function onResult( e:RemotingEvent ):void
{
trace("-----------") ;
trace("> result : " + e.result) ;
trace("-----------") ;
}

public function onStart(e:ActionEvent):void
{
trace("> " + e.type ) ;
}

public function onTimeOut(e:RemotingEvent):void
{
trace("> " + e.type ) ;
}


}
}
More information about this example in my blog in french about the
difference between the classmapping in AS3 and AS2 tutorial :

http://www.ekameleon.net/blog/index.php?2006/08/28/48--amf-class-mapping-difficile-en-as3

Tuesday, July 24, 2007

AS3 language 101 for C/C++ coders

source:
http://blogs.adobe.com/kiwi/2006/05/as3_language_101_for_cc_coders_1.html

Run time type checking

Since you can pass things around as anything using the wildcard type (void *), you need a way to check the type of the object at runtime. To do this, you can use the "is" directive:

public function doSomething() : void
{
var something:* = getData();

if (something is String)
{
// handle string logic
}
else
{
// do something else
}
}

This allows for runtime type checking which allows your application to perform different logic depending on what the given object is.

Typecasting

In AS3, think of typecasting like calling the constructor of the type. Functionally, this isn't what happens, but the syntax is what it appears to be doing.

In C: int i = (int)somefloat;
In AS3: var i:int = int(somefloat);

If you see what appears to be something calling the constructor of a class or type but it does not use "new", it's not calling a constructor. It's performing a typecast. For example:

var foo:SomeClass = SomeClass(someObject);
var bar:SomeClass = new SomeClass(someObject);

The first line is typecasting "someObject" into SomeClass. The second line is creating a new SomeClass object, passing "someObject" as a parameter to the constructor. This subtle difference can have wide ranging effects (new object vs. reusing an existing object, etc.). Depending on what the class constructor takes as a parameter, it is possible that both the typecast and the constructor would compile with no errors/warnings in all situations. So, be careful. The difference between a typecast and a new object is just the "new" keyword.

dynamic_cast

In AS3, you will find yourself dealing with interfaces. These are similar in concept to abstract base classes in C++. Objects that implement an interface will be passed around as instances of that interface. So, given an object of a specific interface, how do you get the object as an instance of its subclass? You use the "as" functionality. For example:

var someInterface:ISomeInterface = factory.getSomeInterface();
var someClass:SomeClass = (someInterface as SomeClass);

If "someInterface" is actually an instance of "SomeClass" or a derived class of "SomeClass", the variable "someClass" will be a reference to that object. If "someInterface" is an instance of some other class, the "someClass" variable will be null.

Comments

I just wanted to add one note about the as operator described above in the section titled "dynamic_cast":

The as operator, which is used to cast an object to a type at runtime, can be used not only to cast an instance of an interface (as in the example above) but also to upcast or downcast any type to a possibly related type (i.e. a subclass or superclass). So in the code below, either of the as statements would properly cast the instance:

public class ParentClass {}
public class ChildClass extends ParentClass {}
...
var child1:ChildClass = new ChildClass();
// note this is a ChildClass instance, upcast as ParentClass
var parent1:ParentClass = new ChildClass();
...
var parent2:ParentClass = (child1 as ParentClass);
var child2:ChildClass = (parent1 as ChildClass);

Of course, the second as statement only works because parent1 was declared as ParentClass but instantiated as a ChildClass instance.

For me personally I think of is and as as a pair of related operators; one tells you whether something is an instance of a type, the other one tells you and casts the object all in one operation.

(Sorry about the short note that turned into a long note. I'm sure you already know all of this anyway, but I thought it might not be precisely clear to everyone, based solely on the context of the article.)

In any case, thanks for the articles, and I'm excited to read more!

ActionScript 3.0 Readiness Kit

http://www.unic8.com/en/news/general/actionscript-3.0-readiness-kit.html

actionscriptcheatsheet

download from here

Actionscript 3: Inspecting classes

source:http://blog.3r1c.net/?cat=14

As you can see here, getQualifiedClassName returns the class name of an Actionscript object. According to livedocs (which put it better than I would have): Any ActionScript value may be passed to this method including all available ActionScript types, object instances, primitive types such as uint, and class objects.

Similarly, getQualifiedSuperclassName returns the base class of the value passed to the method, and adhered to the same rules as getQualifiedClassName.

If you want to go backwards and pass in an actual string representation of a class and get a Class object back, you would want to use getDefinitionByName as I used it above.

To me, the most useful of these methods was the last one 'describeType.' I used this primarily to see if classes implement a certain interface. To keep things abstract a lot of times i will have 'clients' of my components simply pass in Classes to be used as itemRenderers, and will then use Adobe's ClassFactory to create as many instances of this as need be. A lot of these times I will want these classes to be obligated to implement methods, so I will want them to implement a certain Interface. Now, using describeType I can very easily check this at runtime without actually instantiating and using the 'is' operator.

These are some great improvements to Actionscript and a sign that it's really starting to 'grow up.'

Embedded Asset Paths in ActionScript 3

source:http://www.brooksandrus.com/blog/2007/07/23/embedded-asset-paths-in-actionscript-3/

After banging my head against a brick wall for a bit, I finally realized that when embedding assets in ActionScript3 files the path to the embedded asset is relative to the location of the .as file in which the embed statement is placed and not relative to my MXML or AS application entry point. If you look at the image below you’ll note that the embed statement has to traverse up the package structure (3 levels) before pointing to the required graphical asset.

Thursday, July 19, 2007

varargs in AS3

ref:
http://weblog.mrinalwadhwa.com/2007/07/19/flex-tip-of-the-day-varargs-in-as3/

// Here’s a bare bone example:

private function
average(... args):Number{

var
sum:Number = 0;
for
(var i:int = 0; i<args.length;i++){

sum += args[i];
}

return
sum/args.length;
}


// Now all the below calls would work

var
a:Number = average(100,200);

a = average(100,200,300);
a = average(100,200,300,400);

a = average(100,200,300,400,500);

Tuesday, July 17, 2007

Sharing Fonts in ActionScript 3.0

http://www.communitymx.com/content/article.cfm?cid=67A61
import flash.display.Loader;

import
flash.display.LoaderInfo;
import
flash.net.URLRequest;

import
flash.events.Event;

var
fontLoader:Loader = new Loader();

var
fontLoaderInfo:LoaderInfo = fontLoader.contentLoaderInfo;

fontLoaderInfo.addEventListener(Event.COMPLETE, onFontLoaded);

fontLoader.load(new URLRequest("Verdana.swf"));

function
onFontLoaded (e:Event):void {

var
info:LoaderInfo = e.currentTarget as LoaderInfo;
var
loader:Loader = info.content as Loader;

var
embeddedFonts:Array = Font.enumerateFonts(false);
for
(var i:Number = 0; i < embeddedFonts.length; i++){

var
item:Font = embeddedFonts[i];
trace
("[" + i + "] name:" + item.fontName + ", style: " + item.fontStyle + ", type: " + item.fontType);
}
}