Recently I was working on a project that required me to fade a sound in and out dynamically. Here is the result:
FadeSound (clever name, huh?) is an AS3 class that extends Flashs built in Sound class and includes fading in and fading out (including auto-fade out on sound completion).
Here is the source: http://blog.organa.ca/flashContent/fadeSound/SoundFader_Organa.zip
You can probably just dive in and figure it out based on the examples, but I’ll do a write-up after the break.
Read the rest of this entry »
December 27th, 2010 by Peter Organa
Posted in
AS3,
Programming,
Source Code | Comments Off on FadeSound AS3 – A class which fades sounds in and out automatically
UPDATE
I’ve updated the Flash Pie Chart, made it more awesome and put it up for sale on ActiveDen as a Flash component and Flex Class!
Check it out! It’s pretty rad!
So as I wrote earlier I’m working on transforming my 3D Pie Chart into a proper AS3 component. Holy crap, it’s harder than I thought!
By far the most useful resource I’ve found is this one written by Jeff Kamerer from Adobe. The document is divided into 9 parts (it’s a small book!) and covers:
I’ve trudged my way through the first 3 parts and… GREAT SUCCESS! I’ve got my Pie Chart publishing from a component inspector window (shown on the left).
The bit of code that caused me the most grief is the section that pertains to the dataProvider. It seems that if I want custom parameters in my Component Inspector I need to create my own DataProvider classes.
[Collection(collectionClass="ca.organa.Data.Collect", collectionItem="ca.organa.Data.ComponentInfo", identifier="sliceLabel", name="Pie Chart Data")]
public function set dataProvider(value:Collection):void {
if (_dataProvider != null) {
_dataProvider.removeEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange);
}
_dataProvider = value;
_dataProvider.addEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange, false, 0, true);
invalidate();
}
Jeff covers the topic here.
I’ll post about components again once I’ve gone further into this stuff. My next challenges are going to be getting live preview working, and getting a proper colour picker in the component inspector (is that even possible?). Read the rest of this entry »
September 8th, 2009 by Peter Organa
A few weeks ago I started work on a new game as a hobby project… unfortunately I also started playing A LOT of Company of Heroes on the PC, so progress on the programming has been slow, very, very slow.
But I did write at least one useful piece of code that I think some people might find useful: Level Scrolling.
When I was working on my first Flash 2D platform engine Sprocket (game was never finished). I found one of the biggest problems was having the level scroll properly. So this time when I started writing the game engine, scrolling was the first thing I nailed down.
In Sprocket I found that scrolling with the Character locked in the center of the screen was unsatisfactory as enemies could easily sneak up behind you. So I developed a system where the mouse controls the user’s view. I was inspired by the scrolling in PC games such as Abuse, and Soldat.
In my new game I’ve created a LevelDisplay class which handles all scrolling work automatically. Just tell the LevelDisplay what game sprite to focus on and it will handle the rest.
Keep in mind all of this code is very early, so please don’t just plonk this in your game. Once I’ve built an actual game I’ll have a better idea of how successful my implementation actually is. But for now I’ll share what I have and maybe you can get some use out of it.
Read the rest of this entry »
August 23rd, 2009 by Peter Organa
Ok, so I’m coming down with a serious case of blog guilt. I haven’t posted in… well a while.
First my excuse:
I just finished a big freelance job. Now that the job is done I can get on to some more exciting stuff!
To warm myself up. I’m posting something I played around with recently. I explored Flash’s fl.motion.BezierSegment class. It’s neat and surprisingly easy to use.
You can see the swf in motion after the break. I’ve included the source code, enjoy!
Grab the source here
Read the rest of this entry »
July 6th, 2009 by Peter Organa
Recently I watched a video on Ted.com. In the video Steven Strogatz talks about sync, in one segment he speaks about flocking behavior and lists the three simple rules that govern flocking. Later I found that this type of artificial flocking behaviour can be referred to as ‘Boids‘.
So yeah… I decided to code it up in Flash ActionScript 3.0.
The image on the left doesn’t really do the app justice.
Click more to see the app in action.
Read the rest of this entry »
January 7th, 2009 by Peter Organa
Recently I had some time to goof off at work and I wanted something quick and dirty to play with. So I tried to generate a flame using Perlin noise.
Now I know a ton of people have already done this kind of stuff. But I wanted to give it a shot myself. I don’t think my attempt is half bad either.
Really this is just a Perlin noise field in a bitmap being scrolled and blurred on 3 layers. Sorta simple… kind of 😀
The source code is super messy and not very edit friendly, but you’re welcome to it if you want it:
Click to download Source
You can see the swf in action after the break.
Read the rest of this entry »
November 24th, 2008 by Peter Organa
Alright, here it is flipBoard Ver. 1.0!
This is an animated picture transition engine written in AS3 which uses as3flickrlib to connect to Flickr to pull images in real time.
I realized that the panels in the previous version were far too small and far too fast. Giving the impression that the panels were just kind of shimmering rather than actually flipping. This version has much larger and slower panels.
I’ve also added title and author support!
Another new feature is skipping images: If you click on the image you can force it to go to the next image without waiting for the timer. I’ve added a new transition style (circular) for these forced swaps.
After the break I’ll show off the working swf, I’ll give a link to the source code and I’ll describe how to use the application.
I’ve also included a bare bones example of my as3flickrlib implementation.
Read the rest of this entry »
June 2nd, 2008 by Peter Organa
First of all, I made it to ten posts! W00, I really wasn’t sure if I’d make it this far.
Recently at work, I had to write an AS3 image viewer with zoom and pan capabilities. It was a lot harder than I had anticipated. I decided to write another (much better) version for the blog. I’m hoping that by releasing this code I’m saving a couple people a lot of grief.
You can zoom in/out with the buttons in the bottom right corner, or by using your mouse wheel (Mouse wheel might not work on a Mac! Let me know if it’s an issue or if you have a solution).
After the break you can see the application in action.
I’ll also try to explain some of the ActionScript parts I found interesting.
Read the rest of this entry »
May 18th, 2008 by Peter Organa
Update May 27, 2008: Hey guys I just found a much better way of doing colour separation. The code below takes a very brute force approach. It seems the Flash engineers were one step ahead of me though. There’s a method called copyChannel() which essentially takes a selected colour channel from one bitmap and moves it into another. The below code is still a decent introduction to parsing through bitmaps and bitwise operators. It’s just not the efficient way to do this task.
After the Red tick failure this morning, I wanted to get right back into it and do something quick.
In this project I:
A) Load in an external image
B) Read in all of the image’s pixel values and split the data in to red, green, blue.
C) Feed the colour data into seperate layers
D) Animate ’em!
I’ll go into the code after the break.
But first:
I stumbled upon this link while looking into bitwise operators:
Bitwise gems
It’s a great resource and I’d strongly suggest looking into it, especially if you’re not familiar with getting colour data out of hex numbers.
Read the rest of this entry »
May 12th, 2008 by Peter Organa