Archive for the ‘Tutorial’ Category

Using code to play MovieClips in reverse and/or play them on a different frame rate.

Wednesday, October 24th, 2007

One easy way to play movies clips reversed is to affect the currentFrame propriety. The problem is that currentFrame is read only, so you need to make a custom class that extends MovieClip where you can assign values to that propriety.

The class:

The MovieClip:
movieclipanimation.jpg

So with Tweener you can now play with your MovieClip. You can play it on reverse, play it on a different frame rate, and you can even use some crazy transitions.

Example:
example1.zip

Air: Flv Snapshots

Monday, October 22nd, 2007

I just had a go at air today,

A co-worker of mine needed an application that would make it easy for him to take snapshots of .flv files for a content management system, so i came up with the idea of having a go and doing it with air.

So as a follow up i'll make a little tutorial explaining how it works. As Usual you can have a look in the code for the intructions. And should you have any questions feel free to ask them.

Air application file -Thumb

Update: Now published with the final AIR version.

Using Flade

Friday, October 12th, 2007

Hi there,
Recently i had a project that had to be done in AS2, and to top that it needed to have some physics.

My first thought was, well i'll just use the AS2 version of APE, and then remembered that there isn't one.
Then i found flade.
Made by Alec Cove ( the same guy that does APE ).
Now I wanted to see some tutorials or documentation, but as expected for such an 'ancient' engine there were none.
So I decided to make a simple little tutorial on how to throw things arround using flade.

Files: Flade Example

Demo: Flade Demo

You will need Flash 8, and the Flade files found here.

So here's the code:

Double-faced Plane (or Cube with depth=1) in Papervision3D

Thursday, October 11th, 2007

Today I had my first experiments with Papervision3D and after some time playing around I wanted to try having a double-faced Plane() with a different material on each face.

Its likely that a better way to do this exists, but one way to emulate a double-faced Plane() is to have a Cube with depth = 1, and hiding all but the front and back faces. Here's a and the code.

The hint to do this was from ldoru and the car in the images too!

 Update:  I would not longer use such an approach to achieve a double-faced Plane() with a different material on each face. I would recommend using a DisplayObject3D with two normal one-face planes inside it.

currentlabel and currentlabels

Wednesday, September 26th, 2007

currentLabel and currentLabels were a great improvement in flash. About 1 year ago I had a project with lots of characters animations, and as you know sometimes working with designers is not easy. The problem was that I had to run functions when the characters where doing some actions and some of those actions were not controlled by me, there were just embedded in the timeline. If all the animations where equal, like jump in frame 10 I could use the currentframe propriety, but they were not. That work was a really mess, but now with the help of those properties is easy.

On the next example:
Using currentLabels propriety we associated labels to functions, so when the playhead passes throw some label, the respective function is called.
We use currentLabel like a state variable that tells what is the current action of the animation.
The movieClip:
currentlabel.jpg
The code:

Reading Zip files with Actionscript 3

Monday, September 24th, 2007

Last week, while developing an actionscript application, we had the need to read files stored inside a zip file. Our first approach was to use Zinc to deflate the zip file into a temporary directory.

Because some problems arouse with ZINC I took sometime to read about this AS3 Zip Library As it turns out it does a great job and reading and building zip files and it's really easy to use. Make sure you download and install the Library.

After playing around with this Library for a while I wanted to display some images I had inside the zip file. The issue was how to convert a ByteArry into a BitmapData. It took me a while to figure it out , but as it turns out it's really easy.

Instantiate classes by name

Friday, September 14th, 2007

A couple of months ago I wanted to instantiate classes based on their name at runtime, using Flex Builder. At the time I read about the method getDefinitionByName. Everytime I tried to use it I got the error

Error #1009: Cannot access a property or method of a null object reference.   

I googled about it and found Daniel R. post on the subject. According to him

"The problem seems to be that if the runtime module makes a side-effect reference to a component, which is not included in the main application, it never really gets included in the SWF and as such causes problems when accessed"   

And his solution was to declare a static instance of the class you wanted to instantiate at runtime.

private static const classInstance:ClassToInstantiate = null;   

This *fix* becomes a problem when you have many classes to instantiate and have to declare an instante for each one. If the classes you want to instantiate are in the flash library (movieclips), there is a workaround for the problem described above.

  • When you export the Flash library, remember to check the "Export SWC".
  • Make sure you include the SWC in the Flex Builder.
  • (Here's the Magic) Just use this arguments in the compiler options:

-include-libraries $PATH_TO_SWC/LIBRARYNAME.swc 

Doing VoIP Calls

Wednesday, August 29th, 2007

We needed our Flash application to be capable of executing VoIP calls. I remember Skype had a developer API and after some digging I ended up coding a C# application that receives messages from the Flash app via a socket and controls Skype accordingly via the Skype4COM wrapper.

There was already a C# example available at the Skype4COM page that unveiled much of the works involved. I just added a socket server and a configuration XML file for skype dialnumber I wanted and the port the application opens and the Flash app has to connect to.

The attached C# code shows how the application can attach itself to Skype, receive event notifications and control it via the commands provided by the API.

Requirements (and tested with): Skype 3.5.0.202, Skype4COM, release 1.0.27.1

Skype needs to be installed on the machine. For Skype4COM to work don't forget to register the DLL by issuing: regsrv32 skype4com.dll

Carrousel How-to

Tuesday, July 31st, 2007

Hi there,

First be sure you have either flash cs3 or flex2 installed on your machine, then you'll want to download the Papervision3d engine.

Now we can get started :)
Look in the code for instructions :)

Download Actionscript source file

And that's it, if you have any questions please post them!! :) We'd love to hear from you.
Lo.