My Name Is Rich

Icon

Flash Tip: Conditional Compiling

Debuging is a craft in it’s own and it’s always helpful to find new tips and tricks. So, I’m writing to post about a new trick for helping us Flash coders debug our sweet, buggy code. Adobe put in a new feature in Flash CS4 called Conditional Compiling and you can read more about it from InsideRIA’s article.

The basic idea is that you can use a compiler constant called CONFIG::Debug to tell the compile when to run some code. If the constant is set to true it’ll be run if it’s set to false then it won’t. Simple, right? Before you start coding you’ll want to go into your Actionscript 3 settings and click on the last tab surprisingly called “Config constants”. Here you can create the constant and set it’s value.

Now that you are all set you you can then use code such as this to see it in action.

1
2
3
4
5
6
7
8
9
var val:int = 0;
for (var i:int = 0; i < 200; i++)
{
    val += i * .5;
    CONFIG::Debug
    {
        trace(val);
    }
}

And that’s it. It’s a small tip but one that I’ll be definitely using from now on in my projects. If you want to see another simple example I’ve put up a zip file located here for your viewing pleasure.

Flash Tip: Copy To Clipboard

Well, I was working a small project and I realized I needed to be able to copy content to the user’s clipboard. I know this is doable since I’ve seen it done in many, many flash sites and applications. So after a quick look through the Flash Help Docs I came across a little function called System.setClipboard().

Check out the example below to see it in action. All you have to do is type your own text and press copy. Simple and easy.

This movie requires Flash Player 9

1
2
3
4
5
6
7
8
9
10
11
12
import flash.system.System;
import flash.events.MouseEvent;
 
this.copyButton.mouseChildren = false;
this.copyButton.buttonMode = true;
this.copyButton.addEventListener(MouseEvent.CLICK, this._click);
 
function _click(event:MouseEvent):void
{
	System.setClipboard(this.copyField.text);
	this.copyButton.labelField.text = "Copied!!";
}

The way this code works is that after you’ve typed your text and press the copy button. System.setClipboard() is called and a string is passed as a parameter. And that’s really all of the grunt work. Nothing more or less.

I’ve uploaded a zip file containing all the source files for your viewing pleasure.

Hope you found this example useful!

Quick Flash Tip: Centering the Stage

Ok this is a quick tip that I figured to pass along. It’s nothing revolutionary but it has helped me a lot daily.

So here’s the problem. You want to zoom into an object or multiple objects on the stage. What happens when you zoom in? Sometimes Flash will go to the area you expected and other times it’ll just go over waaaaaay to the left or right or anywhere it feels like. Now, you’re stuck looking at a blank screen.

Here’s the solution. Instead of dragging your mouse over repeatedly desperately trying to find your objects just do this…. Press control/command + A. That will select all of your objects on the stage. Second, zoom in by pressing control/command + “+”. Now you’re back in business staring at your stage objects and it’s all centered.

That’s it. Again nothing special or ground breaking but very helpful.

Reflection + MovieClip = ReflectionClip

Ever since reflections became all the craze I have always wanted to create a simple Actionscript class to… well make reflections. So I started it about a year ago and it was very scrapped together. I left it alone and then came back to it a couple months ago. I ended up re-writing a lot of it and kept tweaking it until I’ve come up with what I call, ReflectionClip. Check out the example after the jump as well as a more in depth description with code!

Read the rest of this entry »

5 Tips for new Flash Developers

flashdevelopers

When I graduated college two years ago I thought I had all the tools I needed to build flash sites. One lesson that I quickly learned is that I was wrong. I’m glad to have had my teachers and they did prepare me for life after graduation, but I didn’t realize how much more learning I had to go through. Two years later I feel like I’ve learned a lot and grown as a Flash Developer, but I still have a long way to go. What I do want to hopefully pass on to other new Flash Developers are some of the tips and lessons that I have learned. Hopefully this will help you avoid a few headaches and late nights of development. Read the rest of this entry »

OOOii & Flash Hit the Movies

OOOii

Lee Brimelow posted this video interview featuring the great people at OOOii. They talk about the company and how they are using Flash and AIR in movies today, most recently Star Trek. It’s pretty cool to see this software get pushed into this new territory so to speak. One thing I love is how they talk about even using Director back in the day. That brings back a lot of memories. It’s really good to see this collaboration of Flash, After Effects, Photoshop and more to produce something engaging and entertaining for a large feature film.

Check out the video at Lee’s blog and definitely go to the company site for more info.

OOOii

Custom Blend Modes in Flash 10

Lost In Actionscript

Blend Modes can be a tricky area in flash. When you recieve a psd and the designer has gone a bit crazy with the layer blend modes it can make things a little difficult to recreate in flash. Luckily, Shane McCartney over at Lost in Actionscript came up with a viable solution dubbed the “Ultimate Blend Mode Collection.”

What I love most about this is that it’s very simple to use. All you need to do is import a simple .swc and you’re free to use the set of Blend Modes in your projects. The sad part is that it’s only for Flash 10 so if you’re still working in 9 you will be out of luck. For a more detailed look into this check out the original blog post and also don’t forget to get all the assets here.

Here’s a quick list of the supported blend modes:

  • Add
  • Hard Mix
  • Hardlight
  • Glow
  • Subtract
  • Stencil Luma
  • Extrapolate
  • Difference
  • Average
  • Lighter Color
  • Lighten
  • Color Dodge
  • Stencil Alpha
  • Stamp
  • Softlight
  • Silhouette Luma
  • Silhouette Alpha
  • Screen
  • PinLight
  • Phoenix
  • Overlay
  • Negation
  • Multiply
  • Linear Light
  • Linear Dodge
  • Linear Burn
  • Darken
  • Desaturate
  • Exclusion
  • Color Burn
  • Alpha
  • Darker Color
  • Motion Tweens in Flash CS4

    Flash CS4

    I’ve been lucky enough to work with Flash CS4 and while it does come with it’s share of bugs I wouldn’t go back to Flash CS3. One of the improvements that I love is the new tweening engine. If anything it makes animating in Flash 10x more enjoyable. The update borrows a lot of features from After Effects and brings with it a whole new way of thinking when you animate in the IDE. So, to help myself and other people get used to the new engine I’m listing a little link roundup that not only talks about the new changes but also shows some examples of what you can do.

    Animation Learning Guide for Flash CS4

    Motion Migration Guide for Flash CS4

    The new way of tweening of Flash CS4

    Lists of keyboard modifiers in the Flash CS4 motion model

    I’ve also included a zip file of a ton of examples. I didn’t make these but I did find it at adobe’s site.

    http://download.macromedia.com/pub/developer/motion-is-awesomer.zip

    Finally, here are a few other miscillaneous links from a feature tour of CS4 and some basics of animatin. Nothing big but it’s always good to brush up on the basics even if it’s for a reminder lesson.

    Lee Brimlow’s Tour of Flash CS4

    Principles of Animation

    Obtaining Object Properties and Values in Flash

    First, I have to say this is nothing special or ground breaking. I’m mainly putting this up to hopefully remind myself of how I did this and possibly find a better way in case I need to do this in the future.

    Now with that out of the way I’ll explain what I did and how I solved it. I was working on a project and in one moment I had to obtain a series of properties and it’s values from an object such as this:

    var o:Object = {time: 1, color: "red", food: "cereal"};

    Read the rest of this entry »

    Cheestrings

    Mr Strings

    I just came across this site called Cheesestrings.. It’s currently on the FWA. What I like the most about this is that everything seems so well put together. From the music, design, how you create your character. There’s a lot of thought put into it all. Such a fun concept and I get to make my own person… or thing.. actually I’m not really sure what it is. But I love the polish and style of the design. Go ahead and play around with it. Also, check out what everyone else has created it’s pretty interesting to see the different styles people come up with.

    About Me

    My name is Richard Perez and I am an alumni of Rochester Institute of Technology. This is my personal blog where I like to post about anything that insterests me. Which can range from design, programming, family, and tech gadgets. Currently, I work at HZDG in New York City as an Interactive Flash Developer. I love design and combining that with flash makes my day ten times better.

    Categories

    Calendar

    September 2010
    M T W T F S S
    « Mar    
     12345
    6789101112
    13141516171819
    20212223242526
    27282930