Archive for the ‘AS3’ Category

Embedding fonts in an ActionScript Project

Thursday, June 18th, 2009

Working with ActionScript projects can offer some rather interesting challenges with some of the most basic parts of Flash development. Things like preloading your application and using linked MovieClips from a library, not to mention using embedded fonts in your TextFields. This really becomes interesting when you want to use more than one font in a single TextField. And sure you can embed font files right into the AS class, but that doesn’t always work. I’ve had numerous issues with OTF fonts.

The method that I have had the best success with is using the same technique as embedding symbols from Flash AS2 swfs. Here’s a step-by-step on how to do this.
(more…)

Recording and streaming video with FMS, Flex and AS3

Thursday, May 21st, 2009

For some reason all of the code examples for using FMS are in AS2. Converting the examples to AS3 can be a bit challenging, especially since there is one really key piece of information that is left out that is new to AS3 and specific to the use of FMS2. The problem is the that FMS2 only supports AMF0, but in AS3 the default setting for the NetConnection class’ defaultObjectEncoding property is AMF3. Without changing this setting to AMF0, your code will seem to be correct, but will fail to connect without really telling you why. Check out the class that I created from the Adobe example and the MXML to use it.
(more…)

Dispatching events between AS3 and AS2

Saturday, May 9th, 2009

Even though AS3 has been out for some time now, there are still situations when you will need to load an AS2 compiled SWF into an AS3 compiled SWF and communicate with it. What if you could simply dispatch an event and listen for it on the other side? That’s what sugarcookie’s ASBridge does. Let’s see how it all works.
(more…)

The problem with dropTarget

Friday, April 17th, 2009

While working on an application that has some drag and drop functionality, I noticed something very interesting about the dropTarget property of the Sprite class. It seems that the dropTarget returns the DisplayObject that is at the bottom of the display list which may not yield the result you are expecting. I added a MouseEvent.MOUSE_MOVE event listener to the Sprite being dragged and traced out the dropTarget to see what kind of result I would get.
(more…)

Creating a custom logging target

Tuesday, March 3rd, 2009

I figured since I’m on the subject I would go ahead and create a custom logging target for sugarcookie and a companion logging app – LumberJack. This particular target sends log message objects over a LocalConnection to a basic logging console that will output them into a text field. Being able to see trace statements from a site running on any server, on any network can really help when debugging your application that is deployed somewhere besides your localhost. There are other tools out there that do this like RED|Bug, Xray or even FlashTracer, but this one is extremely simple and includes all the code so you can modify it to suit your needs.

First let’s create the new log target class by extending the existing mx.logging.targets.LineFormattedTarget Flex class. Then override the logEvent method with the functionality desired and you’re in business. Here’s how I did it:
(more…)

Removing trace() statements from Flex applications

Thursday, February 26th, 2009

Removing trace() from your code is a great way to optimize it and improve overall performance. This is easy enough to do in Flash by checking “Omit trace actions” in the Publish Settings window, but in Flex there is no such setting or compiler argument that I’ve seen. No worries, there is a solution.
(more…)

Flex and Flash play nice with DisplayObjectWrapper

Friday, December 12th, 2008

If you’re a Flash developer making the switch to start using Flex, then this class from Grant Skinner is for you. DisplayObjectWrapper makes life much easier by enabling developers to easily get anything that inherits from DisplayObject (Sprite, Loader and Bitmap to name a few) to become a display child of a Flex container (Canvas, ViewStack, Accordion, etc). Awesome, now here are some code examples of how to work with SWFs in Flex.

This mxml code example shows how to:
- load a Flash 9/10 SWF
- call a method within the document class of the SWF
- receive an event from the loaded SWF
(more…)

Sharing your content with Social web sites

Wednesday, October 22nd, 2008

Sharing links to your content and some additional basic information about it is pretty easy. Most social web sites offer a straight forward way to do this through url params to a basic service. sugarcookie makes this even easier by providing functionality that takes care of the finer details for the following sites:
- Facebook
- StumbleUpon
- Digg
- Reddit
- DelIcioUs
- Twitter
- MySpace

Example usage for Facebook:

TextLink.Facebook("http://www.pmko.net","Professional Monkey Keyboard Operator");

see the full source code behind the TextLink class.

Some sites, like Facebook, will scrape the HTML from the link and utilize the page title, meta description and certain images.

Sharing content with Facebook

Sharing content with Facebook

FlashVars with Flex

Tuesday, September 16th, 2008

The switch from Flash to Flex can sometimes be frustrating when trying to do the things that we took for granite in Flash. FlashVars were so easy because they were automatically available on the root timeline object in AS2 . Well, in Flex they are still automatically made available to you, just not in a place that you might expect. The mxml code example will show how to test for FlashVars.
(more…)