Archive for the ‘Adobe’ Category

Open Letter to Adobe: Please fix the debug version of Flash Player

Dear Adobe,

I am a Flash developer. I do a lot of work in Flash Professional, Flash Catalyst, and the Flex framework via Flash Builder. Working in Flex, of course, makes having the debug version of Flash Player on my systems a simple job requirement. However, I am also a web user – like most geeks (and these days, really like most people in general) I do spend a fair amount of time just surfing the web. Recently, those two activities have come into conflict, though, because surfing the web with the debug version of Flash Player – especially on Firefox – has become annoying at best, and downright infuriating at worst. I know I am not alone here, either, and I have seen others comment on Twitter about their frustrations of trying to be a web user while having the Flash Player debugger installed. I am not one who is generally inclined to just complain about things without at least trying to do something about it, so I have outlined below three things that I believe can be done to fix this problem.

First, why is the debugger installed with Flash Builder, but not Flash Professional? Ultimately, the problem I and others have is that too many Flash designers publish movies with errors in them. To a point, you can almost argue that it is not entirely their fault, since the “normal” version of Flash Player is designed to fail silently, so many of these designers may be entirely unaware that their movie is generating errors. In fact, just today I reported a Flash error to a very large, quite prominent blog, and got a quick response back that they could see no errors when they loaded their page. And of course not: they have the normal version of Flash player. I forwarded them a screenshot of their page with the error displayed, but obviously it would have been better if they had known about it in the first place. So my first suggestion is this: get the debugger out to folks using Flash Pro. Push an update to Flash Pro that installs the debugger, and moving forward, make sure that whenever someone installs Flash Pro, they also end up installing the debugger (just as now happens when one installs Flash Builder). That way, all of those folks out there that are building Flash content in Flash Pro will be able to see and fix their errors before they publish.

Second, please provide a way for those of us running the debugger to turn it off. I absolutely need it in order to build my apps, and I absolutely do not need it in order to just surf the web. I’ll be the first to admit that I do not know exactly how plug-ins work, so this might be more difficult than it sounds. However, I would really love to be able to tell Flash Player that, for this browser session, I don’t need debugging, thank you very much. Even more ideally: allow me to disable debugging by default, and only turn it on when I actually need it. That way, for that majority of the time when I’m using my browser as, you know, a browser, I could actually use it and not spend so much time wondering why so many people publish Flash content with errors (although, see above). When I needed to get some work done, though, I could enable debugging and thus make it so that I did not become one of those folks.

Third, and this is really the most important piece: please fix the debugger for Firefox. It is simply broken. When I hit a page that contains Flash errors in IE, I get the error dialog box, click Dismiss, repeat for each other error, and then continue surfing. On Firefox, however, I get the error dialog, and then the browser locks up. I cannot click the Dismiss button; instead, I just get the little spinning circle. Thankfully, I have learned that I do not need to kill Firefox entirely: I can instead press Ctrl-Shift-Esc and simply kill the plugin-container.exe process. Of course, if I want to then view Flash content, I have to restart the browser. What is even more fun is when the error dialog box pops up but then immediately loses focus and drops down behind the browser window so that it cannot be seen, leading me to think that the browser itself has in fact crashed. Again, none of these problems are present on other browsers, so clearly there is just something wrong with the Firefox plug-in. By the way: I am seeing these issues on Firefox 3.6.13 on 64-bit Windows 7 Home Premium, running the debug version of Flash Player 10.1.

Thank you.

Sincerely,

Rob

(Note to my users: constructive feedback is welcomed in the comments. Generic “I hate Flash” or “Flash sux” comments will be deleted.)

Dynamically Resize Text to Fit a Text Field

In putting together the app I’m building for the Blackberry Playbook, I hit upon an interesting problem. I need to have a text field across the top of the app, but the text will be inserted dynamically based on some user settings. I can’t necessarily predict what the text will be, but I know that given several choices it might be quite long. I can’t have the field expand forever, since of course I have a limited amount of real estate. Thus, I needed to figure out a way to get the text to resize down if it doesn’t fit. While I’m quite familiar with the methods to resize a text field to fit text, I had never seen a way to do the opposite and resize the text to fit the field. A Google search didn’t turn up anything either, so I turned to Twitter. Thankfully, I got a response fairly quickly from Arul Kumaran, who is officially now one of my heroes.

Before I start in on this solution, let me say outright that this doesn’t strike me as the most elegant solution. If someone knows of a better way to do this, by all means please let me know in the comments. In the meantime, taking Arul’s suggestion I was able to get this working.

First off, we need to import the three classes we’ll need:

import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

The TextField class will be used, obviously, for the field itself. The TextFieldAutoSize class handles resizing the text field, which, paradoxically, we still need to do. Finally, the TextFormat class is needed anytime you want to format text in ActionScript. Because font size is a format, we need that one too.

OK, next we need to create the text field, populate it with sample text for testing purposes, set its initial size (via a variable I can use for the test later), and add it to the stage. I want to make sure that my initial text is long enough to not fit in the field.

var txtTest:TextField = new TextField();
var desiredWidth:Number = 200;
txtTest.width = desiredWidth;
txtTest.text = "If this works, it'll be really really really really cool.";
addChild(txtTest);

Next, we need to resize the field. This is where I start to think that we aren’t going to win any awards for this code, but hey it works. The concept provided by Aral is to have the field resize, and then detect the new width. If it’s greater than what we started with, we size the text down, then repeat until the text no longer forces the field to resize. Resizing the field requires that we use one of the static properties of the TextFieldAutoSize class:

txtTest.autoSize = TextFieldAutoSize.LEFT;

(The other options are CENTER and RIGHT. For the app, I’ll like use CENTER, but any will work for this app.)

OK, next up is creating the instance of the TextFormat class to set the size. I’m going to go ahead and set a nice big initial size while I’m at it, as well as apply the format to the field:

var txtTestFormat:TextFormat = new TextFormat();
txtTestFormat.size = 20;
txtTest.setTextFormat(txtTestFormat);

The final setup bit we need is a way to dynamically reset the size. I had to do some head-scratching here, because I had always assumed that the size property of the TextFormat class took a number. That’s certainly what it looks like, but it turns out that it actually takes an object. Not sure exactly why, but whatever – we need to create a generic object to hold our size so that we can manipulate it:

var newSize:Object = new Object();
newSize.size = txtTestFormat.size;

OK, now for the magic bit. I’m going to create a function that will test the size of the text field. If it’s greater than the initial size, then I’m going to reduce the size of the text, set that size to the TextFormat object, and apply it to the text field. Then, I’m going to have the function call itself to repeat the testing and resizing until the text no longer causes the field to resize:

function resizeText():void
{
 if(txtTest.width > desiredWidth)
 {
   newSize.size--;
   txtTestFormat.size = newSize.size;
   txtTest.setTextFormat(txtTestFormat);
   resizeText();
 }
}

Here’s all of the code together:

import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

var txtTest:TextField = new TextField();
txtTest.width = 200;

txtTest.text = "If this works";
addChild(txtTest);
txtTest.autoSize = TextFieldAutoSize.LEFT;

var txtTestFormat:TextFormat = new TextFormat();
txtTestFormat.size = 20;
txtTest.setTextFormat(txtTestFormat);
var newSize:Object = new Object();
newSize.size = txtTestFormat.size;
resizeText();
function resizeText():void
{
 if(txtTest.width > 200)
 {
  newSize.size--;
  txtTestFormat.size = newSize.size;
  txtTest.setTextFormat(txtTestFormat);
  resizeText();
 }
}

So there you have it. Again, I really think there must be a better, more elegant way to handle this, but for the time being it works. Thanks again to Aral for setting me off in the right direction with this.

Speaking at BFlex in October

I have been invited to speak at BFlex at the end of October.

BFlex is a full-day of hands-on-training on all things Flex. I will be doing a session on Flash Catalyst. While there are a lot of tutorials out there on Catalyst, and conferences and user group meetings have been awash with hour-long overviews of it, this is going to be one of the first opportunities for people to really take time and go in-depth with this exciting new product. Read the rest of this entry »

ActionScript: Your visual blueprint for creating interactive projects in Flash CS4 Professional

Last night, when I got home, I had a big box waiting on my porch …

ActionScript book cover

It is available now from Amazon and your local bookstore. Enjoy!

Adobe BrowserLab and Flash Catalyst

This week, I did a user group meeting on two exciting new technologies from Adobe – BrowserLab and Flash Catalyst. Briefly, BrowserLab is a new hosted service (meaning that it’s an online tool hosted by Adobe) that allows you to test web pages in a variety of browsers that you may not have installed on your computer. Currently, it tests on Firefox 2 and 3 and IE 6 and 7 on XP, and Firefox 2 and 3 and Safari 3 on Mac. So as a Windows user running IE8 on Vista, I at last have a way to find out what my page looks like on IE 6 and on a Mac. Pretty cool.

Flash Catalyst is the newest tool in the Flash Platform. Catalyst allows you to take designs created in Photoshop or Illustrator and easily convert them to Flex-based Flash applications.

You can view the recording of the meeting if you want to get more information on either technology and to see my demos.

Because the Catalyst demos ended up taking longer than I had planned, we are going to continue the discussion about Catalyst at our August meeting. This session will also be recorded, and I’ll post the details then.