Debugging Flex 2.0.1 Modules

Filed under: Articles — Robert Taylor at 7:59 pm on Thursday, March 15, 2007

Flex 2.0.1 was released with the ability to create modules...

"Modules are SWF files that can be loaded and unloaded by an application. They cannot be run independently of an application, but any number of applications can share the modules. Modules let you split your application into several pieces." - Adobe

This isn't a new concept. If you develop in Flash you do this all the time. So its nice that Flex now supports this as well. The nice thing about modules are they do not compile with classes that exist in the their SWF counterparts. So if SWFA is loading SWFB and SWFB has a class that is also in SWFA, then SWFB will not compile with that class (or component) -- resulting in smaller file size. Nice!

Now the bad news, there is a known issue with modules as mentioned here. Breakpoints are not supported in modules. If you work in Flex, you know how important the debugger is in finding problems in code. You can't live without it. Well, here is a nice solution for now for debugging your modules I came up with...

Create a class called Debug. Mine is located in a folder called utils.

Actionscript:
  1. package utils
  2. {
  3. public class Debug
  4. {
  5. public static function breakpoint(...rest:Array):void
  6. {
  7. // ...put a breakpoint on this line...
  8. }
  9. }
  10. }

Now in Flex put a break point on the line that says "// ...put a breakpoint on this line...".

In your Module you can now create psuedo breakpoints. Wherever you would like to monitor data, just call the Debug function:

Example:

Actionscript:
  1. public function test():void
  2. {
  3. Debug.breakpoint(this);
  4. }

You can pass any number of parameters in that you would like to evaluate. Hope this helps other that are using Modules in Flex 2.

SWFAdapter – Proxy to Communicating to Flash 8 SWFs from Flash 9

Filed under: Articles — Robert Taylor at 11:01 am on Monday, December 11, 2006

A new member to the FlashInterface family is in the works. This little guy will be called SWFAdapter. It uses ExternalInterface and the AS 3.0 Proxy class. SWFAdapter is not an upgrade or replacement to FlashInterface, rather a different means to talk to Flash 8 SWFs. By using the Proxy class, you can address the object, properties and functions as if it resided natively inside the Flash 9 player. This solution will not offer all the bells and whistles of FlashInterface, so if you are looking for a more robust solution you might consider it. For more information on the FlashInterface solution click here.

So what does the API currently look like for SWFAdapter?

var movie = new SWFAdapter("flash/sample.swf", new SWFLoader());
addChild(movie.content);

Scenario 1 - Inline Assignment from different objects

movie.dot.label.abc = 123;
trace(movie.dot.label.abc); // (Optional)
movie.dot.label.text = movie.dot.label.abc;

var pos:Number = movie.dot._x;
movie.dot._x = pos + 20;

Scenario 2 - Inline Assignment from same object

movie.dot.label.text = movie.dot.label.text;

Scenario 3 - Direct calls to root functions

movie.gotoAndStop(++count);
movie.hide();

Scenario 4 - Property Assignments

movie.dot._visible = false;
movie.box._x = 20;
movie.dot.label.text = "2";
movie.dot.label._x = 100;

Scenario 5 - Complex Inline Property Assignments

movie.dot.label.text += "X";
movie.dot.label.text = movie.dot.label.text + " goodbye";

Scenario 6 - Property Getters

trace(movie.dot.label.text);
trace(movie.myObject.name);

Scenario 7 - Complex Numeric Assignments

movie.dot._x += movie.dot._x;
movie.dot.label._x += 20;
movie.dot._x++;

trace(movie.dot._x)
movie.dot._x+=20;
trace(movie.dot._x);

Scenario 8 - Property Assignments from Another Movie

movie.dot._x = movie2.dot._x;

Currntly Testing
movie.x = 123;
movie2.x = movie.x;
trace(movie._x, movie2._x, movie.x, movie2.x);

If you want to play around with the files, that I am currently working on, download them here. Got input or feedback, ideas, anything, email me!

Download SWFAdapter workspace here.

FlashInterface video tutorials (01-04) available

Filed under: Articles — Robert Taylor at 8:32 am on Wednesday, December 6, 2006

Get a jump start on using FlashInterface in your projects. This first set of videos will go over installing, setup and building a quick test demo in the Flash 8 authoring environment.

http://www.flashextensions.com/tutorials.php 

Wanted - FlashInterface Samples and Examples

Filed under: Articles — Robert Taylor at 9:46 am on Tuesday, December 5, 2006

Some of you have emailed me regarding projects you have been creating or working on that are using FlashInterface. If you have been working on a project that is accessible via the web, send me a link to the webpage via email or this post. I will post examples on the FlashInterface page for all to see! If you haven't started a project with FlashInterface, what are you waiting for!!!

FlashInterface 2.1 Released (Major Release)

Filed under: Articles — Robert Taylor at 9:39 am on Tuesday, December 5, 2006

If you have been using FlashInterface 1.0 for projects, you will want to upgrade to this new release. It has major improvements to the prior version. Here are some of the changes that it includes.

  • Streamlined API

I don’t think it could get any simpler! (but you never know). You no longer have to be concerned with finding out the ID of the SWF to register a SWF to use FlashInterface. All the ties into the classes are now reside internally to the class. The only time you need to know the ID is when you want to communicate directly to that particular SWF.

  • Global Dispatching

All members subscribed to an event receive it with a single dispatch. You no longer need to send it to each SWF individually.

  • Switch On / Off public access

You can make your public functions accessible or inaccessible with the new publish function. Determine when items are available to other SWFs.

  • Compatibility with Flash 8, Flash 9, and Flex 2 applications

This release has been tested with the different platforms and frameworks. It also provides examples of using it in each environment.

  • New and improved examples and documentation

Online and Flash 8 Authoring documentation has been dramatically improved. Explanations on how to use the functions is now better explained in the online documentation with this new interface.

Anyone attempting to build an application that mixes Flash 8 and 9 SWFs should use FlashInterface. It has been designed specifically to enable developers to easily overcome the hurdles presented between working within both ActionScript Virtual Machines (AVM).

Enjoy this new release! Visit FlashInterface page.

FlashInterface example source now available

Filed under: Articles — Robert Taylor at 8:46 am on Monday, November 27, 2006

I have been getting a number of requests about getting the source files to the examples. I was hesitant in doing so just because of shear file size. But I will give it a go. I guess it should concern me when the videos reach these numbers as well. Just trying to manage the bandwidth :). I will start working on producing some videos that will demonstrate basic usage and how some methods that may not be as visible. Download the source files here.

Interfacing between Flash 8 & 9 - Problems and Solutions

Filed under: Articles — Robert Taylor at 8:33 am on Tuesday, November 14, 2006

In order to appreciate the thought and time that went into the final solution, it is first and foremost important to understand:

  • What is the problem?
  • How it will affect your past and future projects?
  • What options are available?
  • Why FlashInterface is the best solution?

A Brief Overview

We all know Flash is an amazing tool for both designing interactive media and developing Rich Internet Applications (RIA). Over the past decade, Adobe (formerly, Macromedia) has done a great job at enhancing the player while keeping compatible with previous player versions (no small task). However, like most things, there are only so many new enhancements that you can add before it is time to do a “do-over”. Think of it like this. You could keep extending the life of your computer by upgrading the memory or hard drive, perhaps a better video card. But as more time elapses, it profits you less to do the upgrades and more to purchase a new computer. The same is true of software. (Read on ...)

Communicating between Flash 8 and 9 players through FlashInterface

Filed under: Articles — Robert Taylor at 10:06 am on Thursday, November 9, 2006

The Flash Player 9 runs in a new ActionScript Virtual Machine (AVM). Though many new projects can be developed ground up using Flash 9 or Flex, it is likely that your projects will still be using elements and SWFs that have been published for the Flash 8 player or lower. Flash has always offered the ability to load up one SWF inside of the other and then you could treat that SWF as if it resided as a native inside the loading SWF, communicating and driving it directly within your application. Communicating between the two AVMs is no longer that simple.

FlashInterface is a set of AS2.0 and AS3.0 classes that offer a solution to communicate between the AVMs with a common API. FlashInterface will allow you to move forward, building Flash 9 player applications while still using existing SWF resources from previous Flash player versions.

In the next few blogs I will go into further detail with examples and scenarios for using FlashInterface in your Flash and Flex projects. The APIs for the classes are fully documented, and there are online examples. Other examples will be available shortly.

Download FlashInterface Classes

Flex Video Tip - Automatic Builds

Filed under: Articles — Robert Taylor at 9:25 am on Wednesday, November 1, 2006

Description: Flex provides the means to automatically build projects. This tip details how.

Find this tip under Flex Tips, Tricks & Treasures

Flex Video Tip - How to Import Classes Automatically

Filed under: Articles — Robert Taylor at 6:20 am on Friday, October 27, 2006

Description: This is a nice-to-know feature for those that aren't aware you can do this. It will automatically import the class without you having to look up the classpath.

Find this Flex Tip and other videos here!

Next Page »