Subcribe via RSS

Brand new property MovieClip.isPlaying

January 18th, 2012 | 2 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.

UPDATE: I forgot to mention you need to target Flash Player 11 in your Flash IDE. This is not available by default in Flash CS5 or CS5.5 as you can only select up to Flash Player 10.2. In order to add Flash Player 11 follow the instructions explained here.

Important: If you run the movie within the Flash IDE it won’t work. The movie will be played by Flash Player 10.2. Test your published SWF file in your browser. You can now download the Release/Debug Flash Player 11.1 from the Adobe website here.

Resizing your content with 9-slice scaling

January 11th, 2012 | 2 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!

UPDATE: You can download this example in Flash CS5 here.

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.

What about Flex?

November 12th, 2011 | 1 Comment | Posted in Flex

After the announcement that Adobe stopped the development of Flash Player in mobile browsers, everybody was concerned about Flex. Adobe has published a post trying to give answer to the most important questions regarding the future of Flex.

It’s worth a read. You can find it here.

Flash Player 11.1 and AIR 3.1 available!

November 11th, 2011 | 1 Comment | Posted in Flash

Adobe just released the Flash Player 11.1 and AIR 3.1 for desktop and mobile devices. I wouldn’t wait a minute to give it a try!

You can find an article from Adobe here.

More joy for Flash enthusiasts :)

Adobe ceases Flash player development in mobile browsers

November 11th, 2011 | No Comments | Posted in Flash

These past few days have been crazy after the announcement that Adobe stops the development of Flash Player for mobile browsers.

Flash always has been the technology that was able to do things that HTML couldn’t. With the big improvements the web is experimenting with HTML5, Flash has less room to be the chosen technology for all the interactive content in the World Wide Web.

I have been working recently with Flash on an Android tablet for the browser and talking about performance I have to say you have to create the content thinking on the device to get good results. I believe this is an important reason why Flash in the mobile browsers are not always welcome.

I am working on the elearning industry and this decision causes we take measures, as we need to run the content within the browser, Flash is not a good choice when we want to bring courses to tablets or mobiles.

Sad days…

Adding Flash Player 11 to Flash Pro CS5 and CS5.5

November 2nd, 2011 | No Comments | Posted in Flash

Richard Galvan from Adobe has published a great article explaining how to add Flash Player 11 to our Flash Pro CS5 or CS5.5. Especially interesting if you want to take advantage of the brand new Stage3D.

You can read the article here.

Adobe MAX 2011 sneak peeks online!

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

Adobe just shared the sneak peeks of Adobe MAX 2011. We can see some new cool features that we may have available in Adobe products. They are doing an amazing work!

You can watch the videos on Adobe TV here.