Welcome to Mediasparkles

News : Flash

The JSAPI: Before and after - a (very small) case study

When I was working at the University of Virginia, I once created this little demonstration of entropy, a quantitative measure of disorder. It consisted of a sentence whose letters were dispersed randomly (disorder) with entropy and then put back in order with negentropy. The random disorder and systematic re-order of the letters of the sentence was easy.

The hard part was preparing a movie clip for every single character in the sentence. The sentence consisted of 153 characters. Since I was always trying to achieve minimum file size and maximum flexibility, I didn't want to just break apart the sentence and turn each static character into a movie clip. I wanted to only use one movie clip with a dynamic text field inside and use it over and over again. The problem with that is that each letter has a different width, and if you don't know that width, you don't really know where to place each movie clip. So I created a guide layer with a static text field with the entire sentence in it. For each character in the sentence, I then put an instance of the "letter" movie clip in another layer on the stage, temporarily changed the dynamic text field inside to the value of the character I was positioning, aligned it with the corresponding character in the guide sentence, named the movie clip instance, then moved on to the next character. Yes, it took forever. Yes, it was a big pain in the butt.

Two years later - enter the JSAPI. I studied Keith Peters' Waving Text extension and realized that I could use very similar JSFL code to accomplish in a few seconds today what must have taken me several hours two years ago. Here is the code of the JSFL command:


my_doc = fl.getDocumentDOM();
my_doc.selectAll();
my_doc.breakApart();
var my_frame = my_doc.getTimeline().layers[0].frames[0];
var elems = my_frame.elements;
for(var i=0;i < elems.length;i++){
my_doc.selectNone();
my_doc.selection = [elems[i]];
my_doc.convertToSymbol("movie clip", "", "center");
my_doc.selection[0].name = "c" + i;
}

It breaks apart any string of text (153 characters takes a few seconds but succeeds), turns each character into a movie clip and gives it an instance name. The only drawback is that you end up with 153 movie clips in your library, each containing a static text field, but for the time savings I'd be willing to accept the minuscule increase in file size.

The moral of the story: Where was the JSAPI when I needed it two years ago?

 posted by Vera (11/30/2003 10:11:00 PM);




V1 Component Methods and their v2 equivalents

Tom Muck's post titled OOP Sacrilege has inspired me to put together a list of v1 component methods and their v2 equivalents. The following v1 components are covered so far:

FCheckBox
FComboBox
FDataGrid
FListBox
FPushButton
FRadioButton
FScrollPane

Note that methods that have changed in MX 2004 are in a slightly different color than those that have stayed the same.

Please let me know if you notice anything missing or inaccurate.

Update: Thanks to Chafic Kazoun for telling me about some of the setStyle() alternatives for v1 DataGrid methods.

Another update: It looks like Eric Canty has packaged up my HTML file into a .rar file that you can download. If you extract the contents of the .rar file into C:\Documents and Settings\{your name}\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\HelpPanel\Help, the v1 vs. v2 table will be available in your Help Panel!

 posted by Vera (11/29/2003 09:12:00 PM);




I'm Here Too

Aaron and Jessica of We're Here

Do you recognize these two people? That's right, they are Aaron Adams and Jessica Speigel, founders of We're Here. I am visiting Seattle right now and today had the tremendous pleasure of spending an evening with them. It was a lot of fun. Note to self: Must make it to Seattle more often.

I would like to use this opportunity one more time to thank Jessica and Aaron for being there. They have been such a large and important part of the Flash community, and I am sure that all of us have benefitted from their work in one way or another. Keep up the great work!

 posted by Vera (11/23/2003 10:59:00 PM);




Please welcome Nigel Pegg to the blogosphere

Everybody's favorite component engineer has finally started his own blog: The Flash UI Forum. And not only did he start a blog, but he actually wrote his first real post.

If you have any pressing component issues or questions, email Nigel. If he is asked the same question three times or more, he will try to answer it in his blog.

 posted by Vera (11/13/2003 11:00:00 PM);




If you can't get enough of Web Service Classes...

Jeffrey Hill has written a comprehensive tutorial for Flash-DB titled Using the Flash MX 2004 Web Service Classes. He covers such things as Log, PendingCall and SOAPCall.

Thanks to Mike Brighton for pointing this out.

 posted by Vera (11/13/2003 07:36:00 AM);




MXDJ is here!

I got my first copy of the MX Developer's Journal. This is a great thing to have because I was able to take it with me and read it at a coffee shop instead of being glued to a screen.

The journal covers Dreamweaver, Flash, Fireworks, Freehand, ColdFusion and Director. The articles are separated by software, i.e. all the Dreamweaver articles are in one section, all the Flash articles are in another section, etc. Each page is marked by a tab in the appropriate color and logo indicating which section the page is in, such as the red Flash logo for Flash articles.

Some of the articles in the Flash section of this issue are
Owen van Dijk: The Flash MX 2004 Professional Data Architecture where Owen talks about Policy Files, Web Services, and DataBinding
Jesse Warden: From Design to Reality where Jesse shows different ways of planning and implementing solutions for large collaborations between designers and programmers with pros and cons for each
Peter Elst: Customizing Components in Flash MX 2004 where Peter talks about styling components and applying themes

A tiny piece of criticism, Jesse: Not everybody will know exactly what you mean by chattyfig archives. It might have been good to include a link.

Starting in January, the MXDJ will come out once a month. If you want to get in on this, hurry because the introductory special of $29.99 for a year ends November 15.

 posted by Vera (11/12/2003 10:32:00 PM);




Flash Parade cancelled - now what?

The official announcement that Flash Parade is cancelled was made today. I had already bought a plane ticket. I am probably not the only one.

Some people have suggested that those of us who were going to go to Flash Parade meet up anyway, in Marseille or elsewhere. I think that's a great idea because the main reason I was going was to meet people.

So what do you all think? Are you interested? If so, where should we meet? I would like to get a head count and ideas for locations. Leave a comment or email me.

 posted by Vera (11/07/2003 05:21:00 PM);




ASVGuy

Burak Kalayci of ActionScript Viewer fame has started his own Flash blog today. It was about time. Now go add him to your links list. And if your name is Mike Chambers, you should add him to the MXNA.

In his first post, Burak talks about a Wired article which announces all the Macromedia blogs when they first started emerging. If you're up for a little time traveling way back to May 9, 2002, go read it.

While we're on the subject of Burak... look who made Site of the Month for October 2003!

 posted by Vera (11/05/2003 06:21:00 PM);




DataGrid vs. mDataGrid

Having trouble getting the mDataGrid to work in Central? Me too. But I got it now thanks to Phillip Kerman's kind assistance.

The beta docs say that this is how you create a new DataProvider in Central:

dp = Central.DataProviderClass();


But that does not seem to work. Instead, you have to do this:

dp = new DataProviderClass();


Here is a simple example that populates the mDataGrid in Central, assuming that the instance name of your mDataGrid is dg:

dp = new DataProviderClass();
dp.addItem({Name:"Leia", Gender:"Female", Hairstyle:"Buns", Weapon:"Bikini"});
dp.addItem({Name:"Luke", Gender:"Male", Hairstyle:"Bowl cut", Weapon:"Saber"});
dg.setDataProvider(dp);


Note: You could also use Array and push instead of DataProviderClass and addItem.

To achieve the same thing in Flash MX 2004, you would probably do something like this:

dp = new Array();
dp.push({Name:"Leia", Gender:"Female", Hairstyle:"Buns", Weapon:"Bikini"});
dp.push({Name:"Luke", Gender:"Male", Hairstyle:"Bowl cut", Weapon:"Saber"});
dg.dataProvider = dp;


Note: In Flash MX 2004, you can use addItem or push interchangeably, but in Central, you can only use addItem if you also use DataProviderClass. Also, in Central, at least as of this beta, you do not have the dataProvider property. You have to use setDataProvider instead.

These are good things to keep in mind when working with either version of the DataGrid.

 posted by Vera (11/03/2003 10:48:00 PM);




Time to ditch the Bindings tab

The classes in Window > Other Panels > Common Libraries > Classes are turning out to be true gems. First Edwin Wong showed us how to use web services without using the Component Inspector. He used WebServiceClasses instead.

Now Peter Elst has come up with a way to use DataBinding without the Component Inspector as well. He used DataBindingClasses instead.

There is one more set of classes to be explored now: UtilsClasses. This one is probably the most mysterious of them all. While searches for WebServiceClasses and DataBindingClasses bring up at least a few Help docs in the Help Panel, a search for UtilsClasses brings up nothing at all.

 posted by Vera (11/02/2003 10:38:00 AM);




Which MX 2004 number are you Part II

Remember when there was talk of numbered T-shirts given out by Macromedia with pre-orders of Studio MX 2004? I don't know about you, but I was first in line. My number is 00.

 posted by Vera (11/01/2003 07:40:00 PM);