Flash, Photoshop and General Web Design Helps

Install Multiple Versions of IE on the same computer

One of the major issues in designing web pages using standards compliant code is browser to browser testing. On a recent project, I was testing in Internet Explorer 7, Firefox, Netscape, Opera and Safari. I thought I had covered my bases.

It turns out Internet Explorer 6 was even worse with styles than IE7, thus much of my site was all freaked out in IE6. So how do you test in both IE6 and IE7?

I searched around and found a lot of cautionary messages saying most of the hacks to do this didn’t work. However, one of my work buddies found a great program. It’s called “Multiple IEs” and as the name implies, it lets you install multiple versions of IE all the way back to IE3!

I think for testing purposes 6 is probably as far back as you need to go unless you have special user scenarios where you know visitors to your site are on ancient machines or traveling through some time warp portal.

There are some features (like bookmarking) that are disabled, but for simple layout and css testing this is the perfect solution:

Install multiple versions of Internet Explorer with Multiple IEs.

Highlight or Delete Form Field Data on Click with Javascript

Sometimes you want to highlight or delete the value of an HTML form field when a user clicks on it. This is very simple to do using javascript. Just add the following to your input tag:

To Highlight:
onFocus=”this.select()”

To Delete:
onFocus=”this.value=””

Here are examples of how each of these works:

Have fun and be careful!

Tracing bmp, jpg, gif and png images using Vector Magic

I just found a very cool web app that I wanted to share. In fact, it’s so cool that it is not only going in the “Web App Review” section of my site, but ALSO the “Design Tips” section. It’s just that cool.

One major issue I’ve run into when building a website for a smaller local company is what I like to call “logo blues”. Logo blues come in many varieties. Here are a few you may have heard in no particular order:

  • “Here is our logo” (hands over a business card)
  • “Here is our logo” (hands over logo xeroxed on a sheet of paper)
  • “Here is our logo” (emails Word doc with low-res logo file pasted into it)
  • “Here is our logo” (emails low res version of logo)

These items quickly jump from logo blues to logo nightmares when the client mentions that this is the only format they have their logo in. What usually follows is a long messy journey through Photoshop using lots of sharpen filter, contrast and other such nonsense. It’s even worse if you need a vector image because in that case you often need to retrace the whole image using the pen tool.

Enter Vector Magic

Vector Magic is an Adobe Flex app that lets you upload an image (jpg, bmp, tiff, png, gif, even psd) and convert it to a clean vector image. The service is free if you are ok outputting a png with a Vector Magic trademark on it. EPS files cost 1 credit which translates out to $2.95 (or $2.20 if you order before 4/12/08). The quality is pretty amazing especially for solid color logos. The time this tool could save you, especially if you need a vector version of the logo or image, is awesome.

I tested out Vector Magic, first using their own logo. Here is a sample of the quality. The image on the left is the original and the right is the clean vector version:

Vector Magic

Next I tried Google’s logo. The gradients gave VM a little bit of trouble, but still pretty good job for how easy and quick the tool is to use:

Vector Magic

Lastly, I tried a photo. Again for how simple this app is to use, I think this is pretty impressive:

Vector Magic

I should add that there are some editing features that appear to give you quite a lot of power to clean up the image. I didn’t use editing for any of my samples so these are just raw right through the VM engine.

All-in-all Vector Magic looks like a very cool tool and I am excited to use it on a real project in the future.

Visit VectorMagic.com

Flash - Set the focus on a text field Actionscript 3

Use this code to set the focus on a text field instance in your Flash:

myTextField.stage.focus = myTextField;

Note: This only works once the user has already clicked on the swf. For example, if you had a button in your Flash that said “click here to fill out a form”, and then when they clicked that button you wanted to focus on a field, this solution would work well.

Trace or track key presses in Flash using Actionscript 3

Tracking key presses can be useful both form Flash games (i.e. up, down, left, right keys) or even forms and other types of interactivity (enter key, etc.). It’s pretty simple to do in AS3 using the KeyboardEvent object. Here are a couple examples:

The first thing we need to do is set up a listener to track key events:

//Listen for key presses
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_pressed);

So basically we are saying when someone presses down a key we want to run the “key_pressed” function. Let’s create that function now.

There are a couple different ways to track which key is pressed. For the widest range of keys we’ll use the charCode. This is an integer that represents each key on the keyboard. Here’s an example to do that:


//Listen for key presses
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_pressed);

//trace a particular key press

function key_pressed(event:KeyboardEvent):void {
//trace(event.charCode);

if (event.charCode == 65) {
trace(”A”)
}

if (event.charCode == 97) {
trace(”a”)
}
}

There is a list of charCodes here.

You’ll notice that the link above only has charCodes for upper case letters. One way to figure out charCodes for a lower case (or any) key is to trace the charCode as you press a key. Uncomment the trace(event.charCode); line in the code above and Flash will trace a charCode each time you press a key.

Now for some keys there is an even easier way to track pressing. It’s called keyCode and it is more readable than the cryptic charCode. Here is some sample code for that:

//Listen for key presses
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_pressed);


//trace a particular key press

function key_pressed(event:KeyboardEvent):void {

switch (event.keyCode) {
case Keyboard.SPACE:
trace(”space”)
break;

case Keyboard.UP:
trace(”up”)
break;

case Keyboard.NUMPAD_4:
trace(”4″)
break;

case Keyboard.INSERT:
trace(”Insert”)
break;

/*for this trace to work while testing your movie you’ll need to go to
Control>>Disable Keyboard Shortcuts in the window’s menu*/

case Keyboard.F1:
trace(”F1″)
break;
}

}

You can get the keyCodes for that method at the same link as above.

Note - if you see the little AIR logo before the keyCode, it means that particular keyCode only works in the AIR runtime. Or should I say Adobe AIR Runtime… which translates to Adobe Adobe Integrated Runtime Runtime. Sorry … tangent.

So for any keyCodes with that logo in front, you’ll need to use the charCode method I outlined above.

Friends - I hope this helps you accomplish all of your wildest key press tracking dreams! Good luck!

loadMovie in AS3 - Load an image into a movie clip on the stage

loadMovie is gone in AS3. I liked to use loadMovie to pull swfs and jpgs into existing movie clips on the stage. You can still do this fairly easily by using the load() method. Here’s how:

var i =new Loader();
i.load(new URLRequest(yourimage.jpg));
movieClipInstance.addChild(i)

Basically we are loading the image into a Loader called “i”. Next we add i as a child to our movie clip that is on the stage.

Simple! Thanks Dmode for help on this.

onPress, onRelease, onRollOver, OnRollOut, etc. in Actionscript 3

When Actionscript 2 came out, I stopped using buttons and the old Actionscript 1 on(release) methods and starting creating movie clips for my buttons and using instanceName.onRelease functions to make buttons out of those movie clips.

Now with AS3 there is a new way to perform these functions. It’s not much harder than the old way, just different. Here are some examples:

onPress
buttonInstance.addEventListener(MouseEvent.MOUSE_DOWN,function():void {
trace(”down”);
}
);

onRelease
buttonInstance.addEventListener(MouseEvent.MOUSE_UP,function():void {
trace(”up”);
}
);

onRollOver
buttonInstance.addEventListener(MouseEvent.MOUSE_OVER,function():void {
trace(”over”);
}
);

onRollOut
buttonInstance.addEventListener(MouseEvent.MOUSE_OUT,function():void {
trace(”out”);
}
);

Pretty simple right? Not too bad at all.

Click here for some examples of other mouse actions you can track.

Flash - Change a movie clip’s color using Actionscript 3

That’s right folks. In Actionscript 3, your good old friend setRGB is long gone. But you can still set the color of a movie clip by using the new ColorTransform method.

The first step is simply to import ColorTransform so you can use it in your Flash

import flash.geom.ColorTransform;

Then do the following to change the color of your movie clip (in this case the clip has an instance name of MyMovieClip)

//Change MyMovieClip color to blue (336699)

var newColorTransform:ColorTransform = MyMovieClip.transform.colorTransform;
newColorTransform.color = 0×336699;
MyMovieClip.transform.colorTransform = newColorTransform;

Easy right? Simple! Not too difficult at all! Now go out there and change the color of lots of fun things pal!

Using XML in Flash with Actionscript 3 and E4X

E4X may be the best thing about Flash CS3! It stands for ECMAScript for XML and it is the new way to interact with XML in Flash AS3. What is ECMAScript? I don’t know - nor do I care. What I do know is it ROCKS your socks off. If you have used XML in Flash before you’ll will be amazed at how much easier it is.

Remember this?
xmlInstance.firstChild.firstChild.firstChild.firstChild.firstChild.childNodes[5]?

Now you can do this:
xml.nodeName[5]

It is soooo much easier to do. Thank you AS3.

Take a look at the “Chuck Quotes” swf below. Bask in its utter radness. It randomly selects one of 10 Chuck Norris facts and displays it next to the handsome face of none other than Chuck Norris. Here is the actionscript I used to build this beauty:

var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest(”http://www.jesseharding.com/blog/files/chuckisms.xml”));
loader.addEventListener(
Event.COMPLETE,
function(evt:Event):void {
xml = XML(evt.target.data);

var high:Number = xml.chuckism.length()-1;
var low:Number = 0;
var randomNum:Number = Math.round(Math.random() * (high - low)) + low;

var randomChuck:String = xml.chuckism[randomNum].@text;
chuckquote.text = randomChuck;
}
);

I’ve got a sample fla file that is very well commented and shows you how to build the “Chuck Quotes” swf below.

Download the fla here

Here is the Chuck Quotes swf:

You need Flash to see to this

Flash Preloader in ActionScript 3 (AS3)

Dmode posted a good article on how to create a Flash Preloader using Actionscript 3 (AS3).

You can see a sample of the preloader here.

Read Dmode’s Flash Preloader in ActionScript 3 (AS3) post

Adobe Photoshop Express Beta

Today, Adobe announced Photoshop Express, which as far as I can tell is like Flickr on steroids. It’s an online photo sharing RIA (rich internet application) and allows you to not only upload photos and create galleries, but also to do some minor photoshop-ish editing to those photos. The gallery on the home page looks really interactive so that could be cool.

I signed up, but still haven’t received my confirmation email. When I do, I’ll play around some more and give a more detailed review in my web app review section.

Read Adobe’s Press Release here.

Flash player 9 won’t install in Internet Explorer 7

Last week I had a weird thing happen. Firefox is my browser of choice, but I still use IE for testing and whenever I want to get really frustrated about css. Thus, I’m used to the normal weirdness that occurs when you jump from FF to IE to check a design, but I was surprised last week to see that the Flash player appeared to have uninstalled itself. “Weird” I thought, and simply went and installed it again from adobe.com. It appeared to install normally, and even played the “successful install” video. However, it was still not working, and upon closing IE and opening it back up the Adobe page still thought I didn’t have it installed.

I’m not sure what caused this to happen, but in case it has happened to you, I finally found a fix after about 60 minutes of messing around and trying different things.

Here is what you need to do:

1- Close all your programs
2- Open up your “Add/Remove Programs” window from the control panel
3- Uninstall anything that says “Flash Player”. I had 3 files. One had to do with Active X. The other 2 were called Flash Player 9 something or other.
4- Visit adobe.com in both IE and FF to reinstall the plugin.

Like I said, I’m not sure what causes this Flash player bug in IE, but I do know that I was able to remedy it by using those steps.

Good luck!

Flash 9 Security Update coming in April of 2008

I recently read on Emmy Huang’s blog that there is a new security update coming out for Flash 9 that may affect existing swf content on the web. This Flash Player update will address some of the vulnerabilities that were discovered in December of last year.

For the most part it looks like there are easy work-arounds to fix any possible problems but if you are using any of the following actionscript items you’ll want to read the Developer Center article about the update.

  • Use of sockets or XMLSockets, regardless of the domain the SWF is connecting to
  • Use of addRequestHeader or URLRequest.requestHeaders in any network API call when sending or loading data cross-domain OR Provides access to content on remote domains as a web service provider
  • Use of SWFs that are exported for Flash Player 7 (SWF7) or below that communicate with the hosting HTML by any means
  • Use of ‘”javascript:’” through network APIs to communicate outside a SWF

If you are not sure if your Flash needs to be updated, the Developer Center article goes into detail on each of the issues and gives examples of possible uses.

Using Random Numbers in Flash to create Randomization

One of my favorite things to do when creating a Flash site is to use random numbers to generate some fun randomization on the site.

You can create tons of cool randomness by generating a random number within a range. Here is the script I use. This is AS2 and AS3 friendly:


var high:Number = 10; //set the high number in your range here
var low:Number = 1; //set the low number in your range here

//Now generate the random number
var randomNum:Number = Math.round(Math.random() * (high - low)) + low;

//And trace it to make sure it is working
trace(randomNum);

I’ve used this with an xml file to load a random photo out of group of 10 or 20. Just grab the total number of nodes using .length and set that as your high variable.

Here is an example of that
http://www.jumpingjacktrailers.com/ (in the polaroid spot)

I’ve also used it to load a random movie clip or tell a movie clip on the stage to gotoAndPlay a random frame.

Here are a couple examples of that:
http://www.trickortreatstreet.us/
http://www.kassingandrews.com/

This keeps your site looking fresh, and also gets your site more visits/hits either by keeping users coming back, or by enticing them to hit refresh to see the randomization.

Hooray!

Browser statistics, Resolution statistics, OS statistics

Have you ever been working with a client, and they tell you the web site you are building looks funky in their IE5 800×600 browser? You immediately tell them that NO one is still using IE5 or 800×600, but they look at you with that unconvinced, skeptical or just confused daze.

Maybe I am just slow but I never realized until today that W3C schools, the source of all things true and good about XHTML and CSS, publishes monthly statistics for Browser, Resolution and OS statistics. This is great info and valuable ammunition for that pesky, slow-to-upgrade client:

Browser Statistics
Resolution Statistics
OS Statistics

Link text overlapping in IE 7 - CSS issue?

Today I ran into a really weird bug in IE 7. I had done some CSS and HTML handed it off to our programmer to add to our site. My version worked in both Internet Explorer and Firefox, but once it got included into the asp code and added to the site, it looked funky (see below)

IE 7 bug

Side note: it still looked fine in Firefox (Surprise!)

I looked at the styles and checked our version control only to find that nothing had changed. It was as if IE was ignoring the margin and absolute positioning I had styled. I was stumped.

Next I viewed the source in IE and noticed some extra white space in one of the anchor tags:

IE 7 bug

It was a long shot, but I jumped into the ASP and noticed that the anchor tag was broken up into 3 lines of response.writes. I combined those 3 lines into one. The source now looked like this:

IE 7 bug

And wala! The page looked great:

IE 7 bug

It’s funny how tiny things like that can set IE off. If you’re having any similar issues with overlapping link text etc. make sure you don’t have any white space within the link text area.

As usual, what appeared to be an extremely tough problem ended up being an easy fix.

Web-Safe Fonts

All web designers have had to explain to a client or colleague the “web-safe font” problem. For the first 2 or 3 years that I designed sites, I basically rotated between Arial and Times when it came time to choose a font for a new design. Around 1999 or 2000 Verdana also became popular as a substitute to Arial.

If you are working on a site design and are tired of the same old fonts, you may find the following list useful. It’s not huge, but these are web-safe fonts (i.e. fonts that will show up correctly on most if not all operating systems) with their PC and Mac names:

PC Font Name
Mac Font Name

  • Arial, Arial, Helvetica
  • Arial Black, Arial Black, Gadget
  • Comic Sans MS, Comic Sans MS
  • Courier New, Courier New, Courier
  • Georgia, Georgia
  • Impact, Impact, Charcoal
  • Lucida Console, Monaco
  • Lucida Sans Unicode, Lucida Grande
  • Palatino Linotype, Book Antiqua, Palatino
  • Tahoma, Geneva
  • Times New Roman, Times
  • Trebuchet MS, Helvetica
  • Verdana, Verdana, Geneva
  • MS Sans Serif, Geneva
  • MS Serif, New York

30 On Air

Are you an Adobe user? Like making videos? Got a quick 30 seconds?

Create a video for Adobe telling in 30 seconds or less why you use or love the Adobe product you do. Post your vid to youtube and tag it with “30onair” and Bob’s your uncle - you’re an Adobe star.

You can see the other videos here:
http://www.30onair.com/

I’ll be making my vid(s) within the next day or two and you know I’ll be posting them here as well!

Google Alerts

Google Alerts can be a pretty cool tool especially if you are looking to track the popularity of a client, product, topic, yourself, or pretty much anything.

http://www.google.com/alerts?hl=en

You simply enter in a topic, your email address and a few simple settings and you’ll receive email telling you when Google indexes a site that talks about that topic. You can specify how often you want to receive emails (daily, weekly or as it happen) and what type of sites you want Google to alert you about (all, blogs, news, etc.)

I’ve used this for my Tornadostream project to find out when people are blogging about it. It’s a pretty nifty little tool!

Moving background with AS3

AS3 pro Dan Smith took my moving background FLA file and updated it to ActionScript 3.

http://www.smithmediafusion.com/blog/?p=347

Thanks Dan!

Creating a background that moves with your mouse in Flash

I’ve been seeing a lot of Flash sites lately that have the background that moves as your mouse moves. It’s a pretty cool effect. The objects in the background move less and the objects in the foreground move more. It almost gives the site a 3D feel.

Anyway - I thought I’d jump into Flash and try to figure out how it’s done. It was actually a LOT easier than I thought it would be (Disclaimer: This is AS2 not AS3).

You can see our finished file here.

The code is explained below, or if you want to jump right to the finished product download the source.

Instructions

The first thing you need to do is start an onEnterFrame function which basically continually checks to see what is going on in your Flash:

this.onEnterFrame = function(){

}

Subtracting the x and y mouse positions from the width and height of the Stage will give us the effect of the background moving opposite from the mouse:

this.onEnterFrame = function(){
cursorX = Stage.width - _xmouse;
cursorY = Stage.height - _ymouse;

}

Now all we need to do is create some movie clips, give them instance names and tie their movement to the cursorX and cursorY variables we created:

this.onEnterFrame = function(){
cursorX = Stage.width - _xmouse;
cursorY = Stage.height - _ymouse;

cir1._x = (cursorX * .15);
cir2._x = (cursorX * .15 + 450);
cir3._x = (cursorX * .01 + 350);
cir4._x = (cursorX * .05 + 200);

cir5._x = (cursorX);
cir5._y = (cursorY);

}

You can play with the math and see how it affects the movement of your movie clips to get that 3D effect. Good luck!

Error in my_thread_global_end(): 4 threads didn't exit