The Burned Out Hippy - Hugging Flash into Submission

Maintaining Aspect Ratio

When manipulating large images for backgrounds or full-screen image galleries, one of the most common problems that I’ve encountered is maintaining the image’s aspect ratio on resize. Especially so if I’m playing with a dynamically fed gallery that contains images of different size ratios.

So here’s the solution to your woes. It’s one that’s worth saving to one side as a “copy and paste solution”. Increase the height of the image (or movieclip) to the size that you want it to be and then apply the following line of script…

(AS3)

mc.scaleX > mc.scaleY ? mc.scaleY = mc.scaleX : mc.scaleX = mc.scaleY;

(AS2)

mc._xscale > mc._yscale ? mc._yscale = mc._xscale : mc._xscale = mc._yscale;

(“mc” of course should be replaced with the target of your image or movieclip)

Hope that helps!

Post to Twitter Post to Facebook Post to StumbleUpon Post to Digg

Removing non alpha-numeric characters from a string

posted by The Hippy in Actionscript 3, Useful code bits

Need to strip slashes, back slashes, hyphens and other symbols from a string? Looked at regex and cried “why? why? why?” at the moon repeatedly? Considered throwing your monitor out of the window? No worries. Here’s your solution:

var r:RegExp = new RegExp(/[^a-zA-Z 0-9]+/g) ;
yourString = yourString.replace(r, "");

Robert’s your father’s brother.

Post to Twitter Post to Facebook Post to StumbleUpon Post to Digg

Converting characters into a URL friendly format

posted by The Hippy in Actionscript 3, Useful code bits

There is a handy command in Actionscript that I’d previously never encountered until this week:

escape()

If you’re receiving a text input and needing to send it out to a URL, for example in a search box, you need to convert any special characters into character codes before you request the URL. For example, a space should be sent as %20.

The escape() command allows you to do this with one command rather than having to search through character by character and reference it to a character codes array.

Read the rest of this post >

Post to Twitter Post to Facebook Post to StumbleUpon Post to Digg

King of the Shortcuts (FlashDevelop)

I’ve been using FlashDevelop for a while now. As Actionscript editors go it’s great, but it’s also 100% free which sweetens the deal even more. It does everything I need it to; creates projects, organises files and code hints comprehensively. In a word, it rocks.

But yesterday I was introduced to something in FlashDevelop that I’d never seen before. The king of all shortcuts:

CTRL - SHIFT - 1

How I’ve lived without this shortcut before I don’t know. I feel like a fool for not discovering it earlier. It does absolutely everything…

  • Place your cursor next to a class variable, hit the king and you get a little pop-up menu offering to create you getters and setters.
  • Written a variable inside a function and now want to make it into a class variable? Place your cursor, hit the king and you’ll be offered to “Promote to class member”. It will then declare the variable at the top and correct your function accordingly.
  • Need a new function? Type the function name, press the king, “Generate function”. Done.
  • Need a new class? Type the name, king, “create class”, done.

This shortcut literally does absolutely everything from declaring variables to generating functions. I keep discovering even more things all the time. It’s such a timesaver. Truly the ultimate multi-purpose shortcut.

Post to Twitter Post to Facebook Post to StumbleUpon Post to Digg

A Quick Announcement

posted by The Hippy in Musings

You’ve probably noticed over the last year that I’ve not been posting much on TBOH. This was simply down to not having the time to play, experiment and share. The recession hit a few of my clients hard and this of course had quite a knock-on effect on me. I was finding that I was constantly having to chase down non-paying or late-paying clients, which was becoming a full-time job in itself. Cutting a long story short, I woke up one morning and realised that I hadn’t designed or developed anything for over six months purely due to excessive admin – and I decided there and then that this couldn’t go on.

“Life moves pretty fast. If you don’t stop and look around once in a while, you could miss it.”

Ferris Bueller

So 2 months ago I accepted a full-time position with a fantastic digital agency called ThinkJam, and began the process of slowly dissolving my company. On October 1st Plagro officially closed its offices to new business.

Although I will continue to maintain the websites of existing Plagro clients on a freelance basis, I now intend to take a break from the stresses of running a business and concentrate purely on development for a while. ThinkJam are a fantastic company with some extremely impressive clients. Even after only 2 months I feel very comfortable working for them and have already noticed a massive improvement in both my development skills and my own general well-being. They’re a great agency and I think I’m going to be very happy with them.

So what does this mean for TBOH?

Well, it means that I now have a lot more time for personal projects. I’m currently spending my spare time working with a few APIs that I’ve been meaning to play with for some time now and I’ll post any findings as I go along. I will also be revisiting the Tweeter class very soon – I’ve been working on a series of classes that I’m currently calling TweetEvent that will allow for greater searchability of Twitter (hashtags and users included)…and I will post it up as soon as it’s vaguely usable.

As I’m developing on a full-time basis again you’re also likely to notice an increase in short posts – I would like to keep up the momentum of simple problem solving posts both for my own reference and as a way of helping others who encounter the same time-wasting issues.

So…onwards and upwards…

Post to Twitter Post to Facebook Post to StumbleUpon Post to Digg

Recent Posts
Recent Comments
About Us
mimi: You are totally freaking awesome. This did the trick....
The Hippy: I'm pretty sure that Orange are aware of it, but I'm not entirely sure as to the reas...
Headboy_Roy: After speaking to Orange for an hour and then doing the same with HTC, I used Google ...
The Hippy: You're very welcome. Glad to be of help....

This site is the playground of the The Burned Out Hippy, head honcho of the web design and multimedia company Plagro. It serves no other purpose than to act as a place where I can store my most recent Flash ActionScript experiments. However, I will be posting code whenever an experiment is complete so that you can have a play with it yourselves.

Read more about The Burned Out Hippy...