Excel is Excellent!

english mobile

Lately it seems that, more often than not, I am working with at least two spreadsheets open. Don't tell Steve Howard, but I think I've fallen in love with Excel. It seems to make me orders of magnitude more efficient. Not just for crunching numbers, but a wide variety of tasks.

Planning

I first started using Excel for planning when I was in business for myself. The best way I've ever found is just to break the job down into as many smaller tasks as I can, then estimate each one. Excel makes this a breeze.
Now I'm working in more of a team environment, I find that these spreadsheets are even more useful. Need to print out a list of tasks that need to be discussed at the next meeting? Simply filter on all the tasks that are not complete, but have comments (which is where I put the questions I need answered before I can move forward). Need to write a status report? Copy and paste the completed and planned items into an email.

XML

I admit that I'm almost a big a fan of OxygenXML as I am of Excel, so I rarely use Excel for editing XML. But it's not a cheap program, so if your XML-editing needs are simple, you may find that Excel's XML generation tools do a great job.

Debugging

The company I work for has a culture of including trace statements for "informational" purposes as well as debugging purposes. This is actually pretty nice, but it can make it harder to find debugging statements when you're trying to track down a problem. I find Excel's data filtering feature makes this much easier.

Code Generation

Flash Builder and other IDE's like IntelliJ do a great job of generating code in many circumstances, but there are a lot of things that Excel does much better when you use formulas, especially when the code is based on data that is coming from a spreadsheet anyway. Here are some of my favorite formulas:
Covert the contents of A1 all to Uppercase: = UPPER(A1)
Wrap the contents of A1 in quotes and append q comma (useful when hard-coding Arrays): = """" & A1 & """" & ","

FlashTips #5: Copy Variables in Flash Builder

english mobile

Have you ever wanted to copy all the values of the member variables of a Class instance you were debugging in Flash Builder? If the data types of those variables are simple, you can do this pretty easily by right-clicking on the variable name in the variables panel and selecting "Copy variables." This will copy the name of each member property and its value to the clipboard. Values that are Strings, Numbers and Boolean work, but XML does not--it just copies "XML" as the value--and I suspect that other complex types will not work well either.

As an example of how to use this, today I wanted to copy the contents of the loaderInfo.parameters (a.k.a. FlashVars) so that I could remind myself of what values are incoming. I right-clicked on the parameters object, copied the variables, and pasted into Notepad for future reference.

FlashTips #4 Turn off AutoSave on reference projects

english mobile

When a Flash Pro project is not set up to save automatically, it will prompt you to enable autosave when it has unsaved changes. I usually say yes, because I don't like to lose work. However, Flash considers a file to be "changed" even if you've just popped open a MovieClip to see where that button is so you can duplicate its position elsewhere.

This can make it inconvenient to have a file open to use it for reference as you work in another file, especially if you use version control. Fortunately, I discovered a way to get around this behavior recently.


Simply click the "wrench" icon in the file Properties panel. This will open a dialogue with a check box you can uncheck the Autosave option while you have the file open, using it for reference. If you don't save the file when you close it, your explorations in the file won't be saved and cause your file to show as edited in version control. Since you didn't save the Autosave change either, next time you open it to edit it, it will Autosave as usual.

When Good (Flash Builder/Flash Pro) Projects go bad

english mobile

I love Flash Builder—especially the refactoring help—so it broke my heart when I found that many of my favorite features, such as renaming variables and classes on the fly, didn't work. I was also getting all sorts of weird other problems, such as getting two copies of warning and error messages. I also couldn't edit files when I spotted problems in debug mode, because I'd get a weird error message that the file I was trying to edit was a "generated file," whatever that means.

Finally I figured out that all these issues were symptomatic of the same issue—accepting Flash Builder's defaults when I created a new Flash Pro project. Let's take a step back and look at what the history of my project was. First, the team I am on primarily develops in AS2, and we have a lot of relative path #includes and a source path that point to the same place on everyone's hard drive. To support this, everyone has the same directory structure.

At the moment, I'm reworking the existing code into AS3, but the last thing I want to do is introduce an unfamiliar directory structure. So I used the normal team directory structure and pointed my Flash Builder project at the usual location. What I somehow failed to realize was that Flash Builder has a default place it wants projects to be, so it created a directory in that spot with the same name as my xfl file. This is where all my actionscript files were being "generated" to for use in Debug. Not only did this cause the "generated files" method, but somehow it borked most of the refactoring support in the project.

So how did I fix it? First, I made sure to put all my code into version control, just in case something went wrong.

Next, I deleted the project, making sure to deselect "Do not delete contents." This gets rid of the shadow project and its files. Next, I added it again (File>New>Flash Professional Project). When I selected my target file, I unselected "Use Default location." Since this is an XFL project, when I clicked the "Browse" button next to "Project Location," I navigated to the directory that contains the directory with my XFL file in it. If you were doing this with an fla project, you'd probably want to navigate to the directory with the fla in it.

That fixed the problems with the day-to-day operation of the project, but it created a new one. My project uses xml files to drive a lot of the content, and these were no longer loading properly when I launched the project from Flash Builder, though they worked fine when launched from Flash Pro. The reason for this issue is that Flash Builder created a bin-debug folder next to my xfl folder, but we traditionally expect that Flash Pro will make the swf next to the xfl (so that is where the XML files are stored). The final step is to go into the Project Properties in the Run-Debug Settings and edit the path to point to the root of the project.

FlashTip #3: What color is that thing in Photoshop

english mobile

If you've ever searched on "Photoshop for Developers," you've probably noticed that most results are either really shallow or should more aptly be titled Photoshop for people who can't read the help and figure it out. So, I thought I'd post every once in a while when I find something that helps me with my real workflow as a working developer. It will probably still be shallow, but at least I know it fills a real need.

Today, I want to talk about what to do when you get a file where you need to find out what color something on a layer is, but it is so covered up in effects that the eyedropper tool won't work. If you're lucky, the designer has included a palette, but somehow that brand of luck and I seldom meet.

Recently, I discovered this simple tip to find out what color that object is (assuming it's a solid color underneath). All you need to do is click the dropdown to the right of the "fx" in the layers panel, then click the eye icon to turn off the effects.

Endless Scrolling Bathroom

english mobile

It often seems that I'm drawn to questions on Stack Overflow that have to do with manipulating pixels directly. This week, I fielded a question from someone who wasn't happy with the solution he was using where he was using the graphics object and filling it with the bitmap he was trying to scroll.

I gave him syntax to do it with copyPixels, but what I gave him didn't completely solve his problem, since copyPixels doesn't automatically create multiple copies of the bitmap to fill in the area left empty when you move the graphic. I came up with some code that worked, but it wasn't optimal, and I didn't give a good explanation of why it worked.

So I thought I'd share a better solution with everyone, along with an explanation of what's happening.

Anatomy of an Endlessly Scrolling Background

Let's take the example of a background scrolling from right to left. To create a scrolling background, you need to break the image into two segments—one on the left and one on the right. The pixels on the left side of the image need to slide in from the right hand side, replacing the pixels that are sliding off. In fact, they are the very same pixels that slid off.

This means that the rectangle we're using for the source of these pixels (again, on the left side of the image), is continually growing as it is joined by more and more pixels. By the same token, the pixels on the right hand side, which are the ones that are still left after the pixels moved around to slide in from the right, occupy a rectangle that is constantly shrinking.

To complete the effect, we transpose the two rectangles so that the shrinking right-hand rectangle is on the left side and the growing rectangle from the left side of the image is on the right. Check out this demo, where the red and blue rectangles show where the source pixels are coming from and the lower animation shows the finished effect.

Download the source code.

About the Bathroom Still Life

Sometimes I walk into the bathroom and I see something like this, so I'll go get my phone and snap a picture. It's almost as if my toiletries have lives of their own. By capturing these moments, I can share that secret life in some way. I think of this one as "Toothbrush 'From here to Eternity.'"

FlashTip #2: Changing the view on audio folders

english mobile

I deal with audio files nearly every day. These files are ones that have been recorded by our voice talent, so all the track information that is wonderful when you've downloaded a music file or ripped it from CD isn't useful.

What is useful is knowing how big the file is and when it was last modified. You know, like you can easily see in directories that do not contain audio files.

Not long ago, I found a way to change the view on the folder all at once, instead of having to remove all of the unneeded columns and replace them with the ones I want. All you do is right click on the folder, then select properties. Select the "Customize" tab, and you will see that "Optimize this folder for:" is set to "Music."

Now select either "General Items" or "Documents." Here is what it looks like set to "Documents."

FlashTip #1: Center on Stage

english mobile

One of the things I find most frustrating about Flash CS5.5 is that checking the "Align to Stage" check box in the Align panel seems to yeild results that are not even remotely what I was expecting. For example, if I want to center an object on the stage horizontally and I have this box checked, the center of the object will align with the left edge of the window.

A quick fix I've found for centering objects on stage is simply to cut them and paste them back in. Unlike other applications, Flash doesn't paste objects at the coordinates where they started, but in the center. To paste them at their original coordinates, use Paste in Place (Ctrl-Alt-V). I normally find this annoying, but it turns out to be a great workaround to a feature that doesn't seem to be working correctly.

Is this fixed in CS6? I don't know, but I should be installing CS6 today, so I may update this post later with the answer.

Change of Direction

english mobile

I haven't said much lately on this blog. Mostly that's because I am not doing Flex very much, and haven't been for a while. I did a short stint with Captivate, but now most of my work is in Flash. And, actually, I am doing more these days in AS2 than AS3. Hopefully that will change, since I am rewriting our codebase to a consistent AS3 framework.

I've decided to shift the focus of this blog away from pure Flex and more to "anything vaguely to do with the Flash Platform that I think is interesting." One of my plans is to add a new tag, FlashTips. This is a double entendre, because many if not most of them won't directly be about Flash, but all of them will be very short, like flash fiction. I am finding that Flash offers huge scope for productivity improvements for small changes in workflow that take minutes to learn.

I hope you like the change.