Wednesday, April 14, 2010

Javascript Scroll to Top

I was building a website for a client, all self contained into one Flash file. A good friend pointed out to me that with every link in the footer, while it changed the site as expected, the site stayed in one place. Meaning the content changed, but there was no jump to the top of the page like you'd expect from a normal HTML page. A lot of these sites I build are landing pages for AMOE, meaning I'm basically doing in Flash what is normally done in HTML/Javascript. The main difference is that I don't do Javascript, so building these in Flash and giving an HTML experience (sounds funny, I know) is my goal. Doing this in Flash cuts down on my development time greatly. Annnnnnnnnnd tangent.

The point of this post is, you can scroll to the top of the browser window directly through a Flash call. And that ActionScript is?

import flash.external.ExternalInterface;
ExternalInterface.call("self.scrollTo(0,0)");

That's it. No need to reference a Javascript script in your HTML page. You can also use getURL with the same value, but I found that if you need to run any other scripts at the same time, they may clash. Javascript can only run one at a time if running through the address bar. I found this out while trying to use SWFAddress with getURL. One had to give.

Tuesday, April 13, 2010

Global clearInterval

i = setInterval(function(){},100) + 1
while(i--){
clearInterval(i)
}

See that above? Run that at any time during your Flash to completely clear out any intervals you have running. If you're like me, sometimes you have 2-3 running at a time, and switching between frames and inadvertantly resetting your intervals renders some crazy results. When you call this, don't forget about your intervals that are running onMotionComplete. Make sure you stop your tweens at the same time, or they'll keep running and reset your interval. Damnit if that last piece of advice didn't waste an hour of my time!

I'll let Ted explain how it works:
http://ted.onflash.org/2004/11/fun-with-intervals.php

Tuesday, March 30, 2010

Auto-Formatting your XML for legibility

Generally all of my XML work involves Flash, and trying to figure out how to point to my nodes to grab data. I use AS2, so I still use "myXML.firstChild.childNodes[4].firstChild" notation. I know there are other ways I can call this out by testing for nodeName or by using attributes, but I still prefer this method when I'm not the one writing the XML.

Anyway, tracing your XML in Flash, you'll notice Flash cares less about giving this information back to you in a digestable format. They give it to you like this:

<?xml version='1.0' encoding='utf-8' ?><somenode>someinfo</somenode><somenode><somenode><somenode><somenode></somenode></somenode></somenode></somenode></code></code></em>

Chewing through that can be a pain. I ran across a website that you can plug this into, and it will spit out beautifully formatted XML for your reading enjoyment:
http://www.shell-tools.net/index.php?op=xml%5Fformat

Thursday, January 21, 2010

Opening PWI files in Vista

This isn't a design related post, but it's something that's bothered me for long enough, so I figured I'd post this. If you're one of the unfortunate few that are stuck using Windows Mobile (okay, okay, it has its strengths, but it frustrates the hell out of me), you've undoubtedly created files using the Notes program. The Notes program saves its files as PWI (InkWriter/Note Taker/Pocket Word Document). For the life of me, I couldn't find a program to convert or view these files on my PC. I just copy everything over when I'm upgrading my OS, doing a hard reset, or upgrading my phone. So I've been sitting here with years old PWI files on this computer. One of them had the list of video games I lent my nephew, and I'm determined to get them back.

After a few days of searching, I came across the answer here:

http://social.microsoft.com/Forums/en-US/windowsmobile/thread/6de0c870-da9f-47d0-8425-fde62ff98223/

I've had the right program already installed the entire time. If you open the Notes panel in Outlook, chances are all of your PWI files on your computer are already sitting in there, waiting to be read. I can confirm that I was able to see all of my notes, along with my hand drawn notes as well.

Wednesday, October 14, 2009

iPhone GUI 3.0 PSD

Gone are the days when I was the only mobile designer I knew. Now everyone and their mama is creating UI's for the iPhone. The guys over at teehan+lax have provided us designers with an awesome resource, a PSD file of nearly every iPhone GUI asset.

It's not perfect, but it's as close as you're gonna get. I would prefer if every element was created as a shape or layer style, some are flattened so they aren't as easily edited. And the volume control knob isn't correct. But other than those minor flaws, this kit has saved my life numerous times.

http://www.teehanlax.com/blog/?p=1628

Setting Up Photoshop For Web, App and iPhone Development

Most people who have designed websites or apps in Photoshop will, at one point or another, have had issues trying to match colors in images to colors generated by HTML, CSS or code. This article aims to solve those problems once and for all.

http://www.smashingmagazine.com/2009/10/12/setting-up-photoshop-for-web-app-and-iphone-development/

Monday, October 12, 2009

Font Bureau clashes with NBC over font licensing

NBC Universal and CNBC Inc are in some legal hot water with the type foundry The Font Bureau. A lawsuit claims both companies bought a single-seat license for some popular fonts, but later copied them to multiple computers and even sent copies to third parties.

http://arstechnica.com/tech-policy/news/2009/10/font-bureau-clashes-with-nbc-over-font-licensing.ars