Archives for

Flash

Firefox 3 + Adblock = disaster

I installed Firefox 3 in my Mac yesterday and I'm liking it better than version 2. It seems to be faster and it solved some problems I was having.

So my day went along until I wanted to test a Flex app I am developing in Firefox (my default browser for these things is Safari). What do I see? Just the background. Nothing else. Not even right click > Movie not loaded message. No JavaScript errors... At first I thought Firefox 3 had broken SWFObject, or even SWFAddress.

IFBIN: free and open source Flex examples

IFBINWe were involved in the IFBIN project as Flex by Example authors where we submitted one example for an early Flex beta that demonstrated the use of Remote Object and ColdFusion. We are happy to see IFBIN now evolve into an open source and free collection of great Flex and Flash examples. If you are learning Flex or Flash, we highly recommend you to download it. Although there are no tutorials that accompany the examples, the sources are heavily commented. Enjoy!

How to transfer data with Flash Remoting

In the Introduction to Flash Remoting post, I explained how to connect to a Flash Remoting gateway. I believe that the most difficult part when using Remoting, however, is knowing how to manage the transfer of data from and to the server. This transfer happens when Flash makes a call to a service and sends parameters, and when the server sends a response (not a void function). I will first briefly explain how to send and receive any type of data and then go through all the data types available and show you how to handle them.

Trio Motor Flash Remoting Sample Application

Trio Motor

When the Flash Remoting components were rewritten in ActionScript 2.0, Mike Kollen and I wrote an article for the Macromedia Developer Center that explained how to build the work order status widget. That small widget alone was worth a whole article. We had, however, other 2 articles planned that showed other features of the application. We actually re-built the whole Trio Motor application using the newer components and the new Flash Remoting API. For simplicity, the original ColdFusion components were kept, with simply minor modifications.

FlashForward Finalists

FlashForward finalists have been announced . Voting for People’s Choice is also open.

XForms and DENG on Infoworld

A very good article comparing 3 different implementations of XForms has been published this week by Infoworld. If you notice the ranking, DENG has the highest of all of them :)
It's nice to see that this great work by Claus is receiving some recognition.
We are waiting now for his next project UGO (the next version of DENG ++ ). I hope we can taste it any time soon (any word on this Claus?).
Wishing the best for the DENG team :)

Last days to submit your work at Powered by Detroit

If you have a site that uses Flash and ColdFusion, don't forget to submit it at Powered by Detroit Flash/CFM Contest. You only have a few days left until February 1st.

The available categories are:

  • Application
  • Art
  • Experimental
  • Technical Merit
  • Video

We'll also be speaking at the conference in the server side track. Our topic will be ColdFusion Flash Forms in Depth. So if you are interested in knowing about the new Blackstone Flash Forms, you are invited to attend.

Flash movie not loading when browsing secure site

I installed the secure certificate, browsed the website with all the browsers I have, everything worked fine. But guess what, I missed one small section of the website when testing it with IE. Since I don’t use it, I never noticed anything. I got a call from the customer saying that it was not working, but only when using IE. What? Flash not working with IE? I am used to CSS not working in IE, but Flash?

Making a long story short, the fact was that the movie wouldn’t load under https, but would load fine under http. I finally found that all the files under that directory were not getting cached thanks to the content expiration setting in IIS, and that, combined with SSL, made IE not able to load the Flash movie.

Changing the content expiration setting from “immediately” to a small period of time solved the problem.

Flash Remoting V2 + Trio Motor V2

As many of you may know, Macromedia released the new ActionScript 2.0 API for Flash Remoting. It is a big step forward. You will find a lot of changes in the syntax and most of the old syntax is deprecated, but they are all improvements. We have now a better, cleaner and more flexible API than we had in the previous version. The most important feature is the documentation; they did a great job (Hopefully, they will do the same with everything else they release).

Along with the Remoting components, an article written by Mike Kollen and I has been published on Devnet. It is about the new version of Trio Motor using the Remoting API v2. It is the first of a series of three and focuses on the small Work Order Status widget.

The article explains the basics of the new API using some of the Remoting classes like Service, PendingCall, Recordset, DataGlue, etc. What it does not cover is the connector component. If someone is interested in an example of the connector, I’ve got good news for you. I made a version of the widget using the connector but we later decided not use it for the article. You can take a look at it. The only thing that you may need to change is the GatewayUrl of the connector so that it is your own default gateway. Right now it is set to localhost but you can change it manually in the component parameters.

In the next two articles we'll make the big jump to the whole Trio Motor application and we’ll go deeper into Object Oriented Programming, so stay tuned.

Remoting components
Devnet article
Trio Motor Connector Files

A TextFormat bug?

I wonder if this is a bug.
This is the scenario: you have a TextField to which you have applied a TextFormat. Then you try to add some text to the TextField. There are two possible outcomes of doing that: if it is an HTML TextField, the formatting is preserved after inserting the additional text, as you would expect. But if it is a non-HTML TextField, all formatting is lost when the text is added.
An example of this:
After pressing "Add Text", the String "is a long" loses its formatting in the non-HTML TextField
This is the code:
t = "this is a long text bla bla bla bla bla";

tfield1.html = true;
tfield1.border = true;
tfield1.htmlText = t;

tfield2.html = false;
tfield2.border = true;
tfield2.text = t;

var tformat = new TextFormat();
tformat.bold = true;
tformat.italic = true;

tfield1.setTextFormat( 4 ,15, tformat );
tfield2.setTextFormat( 4 ,15, tformat );


but.onRelease = function()
{ tfield1.htmlText += " more text "; tfield2.htmlText += " more text "; }

Flash casting weirdness

Now that we have strict typing in ActionScript 2.0, the compiler complains whenever we try to assign a value to a variable that doesn't match its expected type. That is easy to see in the following example:

I made a class ( Container ) that holds any kind of data. Since it is very generic, it only knows that it holds an Object.
This class also has a method ( getItem() ) that returns that data. So if we try to assign the return value of getItem() to a reference of a type other than Object, the compiler will complain:

var c:Container = new Container(new Array());
var i:Array = c.getItem();

the compiler will throw an error like this:
Type mismatch in assignment statement: found Object where Array is required. var i:Array = c.getItem();

So the solution for this is to cast the returning data to the class that we need. We have two options:

Option 1 var i:Array = Array(c.getItem());
Option 2 var i:Array = (Array)(c.getItem());

Both works very well except when you try to cast to your own classes, not the built-in ones. To show that, I made another class ( Item ) and a test class ( TestCasting ) that shows this behavior:

Option 1 var i:Item = Item(c.getItem());
Option 2 var i:Item = (Item)(c.getItem());

The first option runs without a problem, but the second doesn't. It simply assigns "undefined" to the variable without the compiler complaining. So it's obviously better to avoid the second option. I used to do it that way because it always works in Java, but not in Flash. You never know when these little things will jump on you.

For a better understanding, I put this example in a zip to download.

Implementation of the List Iterator in Flash

I made an AS2.0 class that implements a similar interface to the Java List Iterator. This class is useful for going through every element in an Array, but without the famous i++ variable. A nice use of this class is when you have a loop on an EnterFrame so that you don’t need to maintain the variable i across the frames but simply evaluate hasNext() and call next() if there are more elements.
If you want to know more about this Interface you can take a look in the Sun site.
You can download the source and an example.
You can view the code in the browser.