Archive for the ‘Actionscript3’ Category

Swc Image problems

Thursday, March 6th, 2008

Last month I had to run one image sequence with 100 images, so I create a new movie in flash, put every image in every frame, image1 to frame1, image2 to frame2, etc. It ran ok in flash but when I exported it to flex (SWC format) the problem began. Every time I did some modifications to one of the SWC files in the project it started to delay 15 minutes to build. So be careful with the number of images inside a SWC file, it can be very boring.

APE + Arkanoid = Aperkanoid

Friday, February 29th, 2008

Pedro Lourenço and Bilou have been working on a project that involves using the APE physics engine for Flash. Here's a demo of using APE that allows to play a bit with different parameters of the engine like damping, gravity, mass, etc. The source code has a lot of comments ( as does the engine itself ) that should permit anyone starting with APE to get going.

Some minor issues/glitches on the engine are noticeable, mainly when you crank up strength values, or at least make masses way to small for the forces being applied to them. You can spot them when the ball is re spawned near the screen centre, this probably happens because objects start moving so fast that once the engine tracks where they're at, faults have already occurred. Overlapping also occurs, a bit more often than it should but there are some ways to workaround it...or you can learn to live with it!

Go ahead, try the demo to understand APE a bit better, "a" and "s" move the pong around, "r" resets the level once all targets are gone. Fiddle with the values on the bottom and press enter to set them.

 

Ape Arkanoid

Source Code (tested in Flex Builder 3)

Giving Flex Builder a Library (SWC)

Wednesday, February 27th, 2008

Have you ever wondered why Flex doesn't have a nice library like Flash IDE?
You'd love to use Flex but not having that nice little library there puts you off?
Well here's how we do it:
First create your FLA file, then create all the items you want inside (they don't need to be on stage just library will do), be sure to tick 'export for actionscript' and 'export in firstframe', also you can change the base class to something else that will add functionality to your movieclip.
Then in export preferences, tick 'export swc'.
Ok so now we have a nice little SWC file, how do we get it into Flex? Easy :)
Open project properties, go to Build Path > Library Path and add your SWC file.
That's it!
Congratulations now you have auto complete goodness on your AS3 Flex Builder application :)
Just keep in mind that these elements will be exported in the initial load of your website, so if you want to preload them be sure to use the preloader.

Papervision3d GW Memory Leak

Tuesday, February 19th, 2008

Yesterday I came across a nasty leak with GW, it just wouldn't kill my moviematerials after I removed all the references to them, I tried it all, removeChild, removeListener, weak keys... you name it.

So I finally decided to go have a look at Papervision's destroy methods, and surprise surprise they weren't being called, no harm there, it's alpha these things are meant to happen :)

So here's what you have to do to force those destroy methods to execute, and clean your memory.

In org.papervision3d.core.proto.MaterialObject3D  set the destroy method from protected to public, do the same to all the materials that you use, like org.papervision3d.materials.MovieMaterial . When you're done with these just the destroy method in your class. For me it looks something like this:

Hope this helps.

MVC in Adobe Flex

Wednesday, January 30th, 2008

Here's a set of different perspectives in respect to the use of the Model-View-Controller software architecture when using Adobe Flex:

"MVC considered harmful" [weblogs@macromedia]

"How Flex fits the MVC models" [livedocs@adobe]

"The Flex Show - Episode 33: PureMVC Framework" [theflexshow]

Update: The follow-up by Grant Skinner is also a good read on the subject.

Why I won’t enter the eBay Flex widget contest

Wednesday, January 30th, 2008

After reading about the eBay Flex widget contest over at Doug's blog and seeing eBay changing the contest rules, to allow the use of open-source code licensed under the MIT or BSD licenses, I got curious and went to the site. I registered, got the API access keys and tried a couple of samples they have for download. Just like Doug said: "thought maybe I’d whip something together and enter".

While I was brainstorming today with Bilou about possible things we could do, I went over to to read the FAQ again and saw this clause:

The eBay Developer Widget Build Off Contest 2008” (the “Contest”) is open to legal residents of the fifty United States, the District of Columbia, Canada (excluding the province of Quebec) or the UK;

Since we're in Portugal, I guess we won't be entering this contest anymore. That's bad, why not open the contest for other developers?

Update: Sunny Li, from eBay, was kind enough to reply to us saying that the reason only US, CA and UK are allowed into the contest is purely legal. You can check his response here.

Metaprogramming with Actionscript3 Metadata in Flex Builder 3

Saturday, January 26th, 2008

I first became interested in metaprogramming and metadata in Actionscript3 after reading about it on Ely Greenfield's blog here. What caught my eye at first glance was the use of flash.utils.describeType():XML, a method I've never seen anyone use in the past year of programming and reading about AS3.

(more...)

getDefinitionByName

Friday, January 25th, 2008

Imagine you have a .swc file that contains objects named from "mcObj0" to "mcObj11", and want to add those objects randomly to the screen. One way to do this would be:

A better approach is one that uses 'getDefinitionByName'. This method allows to create objects dinamically and results in less code written. That means we could refactor the above code into:

Look ma, only three lines, that's great! To use this method you also have to remember to add the compiler parameter "-include-libraries". Here is how to do it:

- In the project properties choose "ActionScript Compiler"

- On the "Additional compiler arguments" field add the following:

-include-libraries PATH_TO_SWC

The path should be the absolute path, relative won't work.

WOW meets Papervision3D

Wednesday, January 23rd, 2008

WOW was released today, in case you don't know what WOW is let me quote a little description from WOW: "WOW-Engine is a free AS3 open source physics engine written by Seraf ( Jérôme Birembaut ) capable to handle positions in a 3D environment."

We've all been waiting for this moment for a very long time, to have physics
and 3D come together, so without further due here's a little demo I've thrown together in an hour or so.

The code will follow shortly, I just need to tidy it up :).

demo

Enjoy.

Customized actions for FLVPlayback Component

Tuesday, January 22nd, 2008

If you need a standard flash videoplayer, then the FLVPlayback component is the right thing for you.

Just create a new FLA and drag&drop a FVLPlayback component from the components library into a movieclip in your library, export it for actionscript and compile the SWC.

All the functionallity stuff is already handled by adobe. But that's where I got stuck for quite some
time. I needed a player, that used the forwardButton and backButton for switching the videos (and not seeking forward and back).

The answer was really simple: Just override the functions once the component loaded its skin: