Subcribe via RSS

Brand new property MovieClip.isPlaying

January 18th, 2012 | No Comments | Posted in ActionScript3

I have discovered recently the new isPlaying property for the MovieClip class that Adobe introduced in Flash Player 11.

I do recommend you read What’s New in Flash Player 11 where you will find interesting new features like this one.

It’s great we finally have an easy way to know if our animations are running or simply stopped.

Take a look at the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import flash.events.Event;
import flash.events.MouseEvent;

this.addEventListener(Event.ENTER_FRAME, onLoop);
stage.addEventListener(MouseEvent.CLICK, onClick);

mc.play();

function onLoop(e:Event):void
{
  txtInfo.text = mc.isPlaying ? "MovieClip playing!" : "MovieClip stopped";
}

function onClick(e:MouseEvent):void
{
  if (mc.isPlaying) {
    mc.stop();
  } else {
    mc.play();
  }
}

As we see the use of this property keep things very simple and this is really welcome! Quite surprising this has not been available before.

Note the mc.play() in line 7. It seems this property does not know the MovieClip is playing by default, and the value gets updated when we use the MovieClip playback functions such as play(), stop() and so on…

If you are going to use the isPlaying property ensure to use those functions to have the correct value.

This is the result of the above code (Flash Player 11 required):

This movie requires Flash Player 9

You can download this example in Flash CS5 here.

Resizing your content with 9-slice scaling

January 11th, 2012 | No Comments | Posted in Flash

I’ve found these days some designers and even programmers not aware of the 9-slice scaling that Flash provides, and that’s why I’d like to introduce it here for those who does not know it either.

This feature allows you to determine the way a MovieClip is scaled. Doing that you will be able to resize without unwanted results like your MovieClip is distorted.

With tablets and smart phones on the market, it’s a good idea to resize our content accordingly to the area we have available, and here is where 9-slice scaling will help you out.

Look at the picture below and notice the rounded corners it has:

Now look at the difference we get after applying an horizontal resize of the MovieClip:

As you can see with 9-slice scaling we can achieve the result we really expect.

In order to enable this feature, you just need to open the Properties panel of the MovieClip and select Enable guides for 9-slice scaling as shown in the picture below:

Then when you edit the MovieClip it will show you the guides that you can easily adjust to your needs as seen in the following picture:

This scaling mode cannot be applied to Buttons or Graphics Symbols. The same applies when we nest them inside a MovieClip. The 9-scale scaling will only be applied to the compatible content.

It would be perfect to have 9-slice scaling for Bitmaps as a built-in capability in Flash, but meanwhile Grant Skinner created a nice solution called BitmapSlice9. It allows you to break your Bitmaps in pieces and use the 9-slice scaling with a great results!

Improving game development with Texture Packer

December 5th, 2011 | No Comments | Posted in General

If you have ever tried game development surely you noticed how important the management of the images is. A 2D game involves lots of images for the animations of our characters.

Having a good organization and optimization is quite a tricky job.

Here is where Texture Packer comes to save our lives. This is a great utility that will help you to build your games better, faster and optimized.

This tool supports a lot of different popular frameworks like Cocos2d, Corona and Sparrow among others. Specially for Flash, if you are using Starling framework it will suit you perfectly as it’s based on Sparrow.

It comes with features like quality color reduction, automatic resizing, trimming of your graphics and reuse of the same graphic data to avoid duplicates.

Now Texture Packer added recently the option to import SWF files. A very welcome feature that helps a lot when you manage Flash graphics for your art work.

Congratulation to Andreas Löw who is the author of this amazing tool.

You can check it out in the official website here.

Happy game development!

New mouse capabilities in Flash Player 11.2 and AIR 3.2

November 23rd, 2011 | No Comments | Posted in Flash

Adobe just released the beta of Flash Player 11.2 and AIR 3.2 for Desktop with brand new capabilities.

One of the great new additions is the mouse right and middle click events. That means we finally can remove completely the context menu! Focusing in games we have the mouse lock that will be available only in fullscreen mode and new relative mouse coordinates.

You can take a closer look at it in this post from Thibault Imbert.

FDT 5 is here!

November 17th, 2011 | No Comments | Posted in General

Cool stuff is what we find in this new release of FDT from PowerFlasher.

This great ActionScript plugin for Eclipse Platform is released this time with a Free version without restictions in time but with limited features that will suit you for small projects.



On the other side the FDT 5 Max, which is the complete version of the plugin, comes with a new great bunch of new features like:

  • haXe Support
  • ASDoc Support
  • Advanced Refactoring
  • FDT & Mobile
  • SWC Source Attachement
  • AIR SDK Merging

You can get the full details of FDT 5 here.