Archive for the 'AS3' Category
AS3 - Kool Dynamic Video Distortion: Part 1
I started working out some experiments with dynamic video effects. This one in particular uses the activityLevel from the microphone. I hooked up a scaling effect along with some DisplacementMap video I created and exported from AfterEffects. Below is a video I created of one of my coworkers acting silly. Below that is the actual working file. You need to have a webcam installed for it to work. Let me know what you guys think.
No comments
Expanding horizons: Starting to work with Flex 3 and AIR
I’ve been taking advantage of this short slowed time period to increase my tech-knowledge (don’t ask where that term came from, I just made it up as I was writing). I know that Adobe has really been pushing Flex and AIR, so that would be my logical progression / extension from Flash AS3. I have blogged a lot about quoting hours accurately so I am taking it upon myself to write an AIR app to efficiently quote project hours. I’m hoping that by blogging about it now, I’ll be prodded forward to not leave it by the wayside. I’m calling it “Quote Right! (TM)”. Stay tuned, I will release it for free.
No commentsI wanna go to Friendly’s!!!!
Another project, another crazy deadline. Hopefully the end result of this project brings a smile to everyone who encounters it, adults and children alike. Build a virtual Ice Cream Sundae and print out your creation! Fun for the whole family! Go to your local Friendly’s and tell Joe Friendly his old buddy Charlie sent ya. Lots of hard work went into this. Let me know what you guys think.
APE Tutorial/Example 2 - Flash Physics Engine: Adding walls and multiple collisions
This example just builds off the last example but I was just having a little more fun. I added a few more walls and dynamically added wheels to the APEngine to see multiple wheel collisions. I also modified the default elasticity property of the wheel to make the collisions more bouncy. I know it’s not a whole lot different from the last one but is it an example of progression and elaboration. Once again you can plug in the code below on the first frame of a timeline and it should work as long as you are linked to the APE source files.// Imports
import org.cove.ape.*;
import flash.events.Event;
import flash.display.MovieClip// listeners
addEventListener(Event.ENTER_FRAME, run);// Create an instance of the APEngine.
APEngine.init(1/3);
APEngine.container = this;
APEngine.addForce(new VectorForce(false,0,2));
// Create group
var group1:Group = new Group();
group1.collideInternal = true;
// Create rectangle to serve as the floor.
var rect1:RectangleParticle = new RectangleParticle(280, 350, 130, 10, 0, true) // Bottom Right
var rect2:RectangleParticle = new RectangleParticle(120, 350, 130, 10, 0, true) // Bottom Left
var rect3:RectangleParticle = new RectangleParticle(60, 200, 10, 300, 0, true) // Left
var rect4:RectangleParticle = new RectangleParticle(340, 200, 10, 300, 0, true) // Right
// Add to group
group1.addParticle(rect1);
group1.addParticle(rect2);
group1.addParticle(rect3);
group1.addParticle(rect4);
// Add group to engine.
APEngine.addGroup(group1);
// Constantly run these functions to keep the engine running.
function run(evt:Event):void {
APEngine.step();
APEngine.paint();
}
// Add button
mcStart.addEventListener(MouseEvent.CLICK, mcStart_CLICK);
mcStart.buttonMode = true
function mcStart_CLICK(e:MouseEvent = null):void
{
var wheel:WheelParticle = new WheelParticle(50, 0, 10);
wheel.elasticity = .6
wheel.addForce(new VectorForce(false,100,0))
group1.addParticle(wheel);
}
mcStart_CLICK()
Damn you Line Golfer!!!

From the guy who brought you Line Rider, here comes Line Golfer. The game must be laced with crack cocaine because I couldn’t stop playing with it. At Wrigley’s CandyStand you can play other courses others have drawn or draw your own and submit it for consideration. The concept of the game incorporates multiple levels of genius; the simplicity, allowing others to build the courses for you, the addictiveness of it… don’t get me started. The game is built using APE, the flash Physics engine written by Alec Cove from what I understand. Very kool. It’s great to see people build on Flash technology that is out there. I guess that is why some thing like this is so inspiring for me. Let me know what you think.
APE Tutorial 1 - Flash Physics Engine: Getting started
I have searched for days now looking for good APE tutorials and I have found little to no help. I decided to gather what I know, digest it for the average human being and post tutorials. I will try to make this concise.
For this first tutorial I have decided to strip down using APE to it’s basic necessities; present a good foundation that can be easily built off of. The following is the sequence of what needs to happen to get a firm understanding of how APE is used.
- Import the APE package
- Create an instance of the engine
- Create a group that you will add particles to (wheels, circles, rectangles, etc)
- Create your particles
- Add your particles to the group
- Add the group to the engine
- Run the engine
Thats it, once you grasp this concept you are on your way to leading the industry with richer internet applications and you can promise the world a better tomorrow. I suggest going thru the APE documentation to see what you can add on to my file. I will do more Tutorials soon where I will go more in depth on how to use the bells and whistles. Below is the code I used to make the example. You can actually plug this code into the root of the timeline with no graphics and it will work as long as you have APE hooked up to your Flash AS3 class path. Hit me up with questions.
// Imports
import org.cove.ape.*;
import flash.events.Event;
// listeners
addEventListener(Event.ENTER_FRAME, run);
// Create an instance of the APEngine.
APEngine.init(1/4);
APEngine.container = this;
APEngine.addForce(new VectorForce(false,0,2));
// Create group
var group1:Group = new Group();
group1.collideInternal = true;
// Create wheel with motion.
var wheel1:WheelParticle = new WheelParticle(0, 0, 30);
wheel1.addForce(new VectorForce(false,30,0))
// Create rectangle to serve as the floor.
var rect1:RectangleParticle = new RectangleParticle(200, 300, 300, 10, 0, true)
// Add particles to group.
group1.addParticle(wheel1);
group1.addParticle(rect1);
// Add group to engine.
APEngine.addGroup(group1);
// Constantly run these functions to keep the engine running.
function run(evt:Event):void {
APEngine.step();
APEngine.paint();
}
So little time
I miss experimenting with Flash. I’m always working on projects and other stuff that needs to get done. I am going to make it a point to start fiddling with some of the new physics Technologies that are out. I have some ideas that could be pretty kool. WOW and APE, here I come!
AS3 - MovieClipUtil.getFrame() - get frame number by passing frame label
Download Class
Very easy to use:
MovieClipUtil.getFrame(clip, “FRAME_LABEL_1″)
This is a handy tool we had in AS2 but is much more efficient to implement in AS3. In AS2 we had to duplicate the MovieClip, go to that specific frame label, return the current frame, then remove that MovieClip. It was a true ghetto work-around, but it worked. The AS3 is much more clean.
/*
Returns a frame number. Returns MovieClip current frame if nonexistent.
*/
function getFrame($clip:MovieClip, $label:String):Number
{
var arr:Array = $clip.currentLabels
for(var i:Number = 0; i < arr.length; i++ ){
if($label == arr[i].name){
return (arr[i].frame);
}
}
return ($clip.currentFrame);
}
2 comments
Problems using the MovieClip’s “enabled” property - AS3
UPDATED: This is a more in depth look at mouseEnabled and mouseChildren.
I’ve racked my brain and scoured the internet for 2 days now wondering why I’m having so much trouble getting the enabled property of a MovieClip to work correctly. It should be as easy as saying:
mcClip.enabled = false;
All Button functionality should be disabled right?! Not so in AS3 my friend. The situation goes awry when using event listeners. But the thing is that AS3 is completely event based, so I’m not even sure what use the enabled property is, but that could be my bias. Here is what was really going on. Instead of using enabled = false, you need to use mouseEnabled = false. But here is the kicker: if you have any MovieClips inside of the MovieClip that you are applying events to (regardless if there are instance named or not), that container MovieClip will continue to receive events (CLICK, ROLL_OVER, etc). You need to use mouseChildren = false on that container clip, and THEN the disable/enable toggle will work. Place the following code on the timeline with aMovieClip containing another MovieClip inside it on stage.
// Importsimport flash.events.MouseEvent
// MovieClip on the timeline with other MovieClip inside
this.mcContainer.buttonMode = true ;
this.mcContainer.mouseChildren = false ;
this.mcContainer.addEventListener(MouseEvent.CLICK, this.run)
// Event handler
function run ($event:MouseEvent) {
trace(”RUN”)
}
// Toggle enabling
function manageButtonState ($clip:MovieClip, $state:String = “ON”):void {
switch ($state.toUpperCase()) {
case “ON” :
$clip.mouseEnabled= true;
break;
case “OFF” :
$clip.mouseEnabled = false;
break;
default :
$clip.mouseEnabled= true;
}
}
// Call toggle
this.manageButtonState (this.mcContainer, “OFF”);
No comments