Archive for the 'CS3' Category
I 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. 2 comments
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()
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
Latest JSFL Documentation - CS3
Download CS3 JSFL Documentation here
This is a link to the latest and greatest JSFL documentation - CS3. Grab it while it’s hot. It’s full of stuff that wasn’t in there in previous documentation. If this link ever goes bad and it shouldn’t, leave me a comment and I will put it up myself. Enjoy.
No commentsJSFL – Set selected objects on a whole pixel in CS3
I haven’t posted in a while. This is a very simple yet effective JSFL I wrote for a coworker. He needed an easy way to set all the objects he had selected on stage to a whole pixel. Sometimes vectors get blurry if they land on a fraction of a pixel and clients can be quick to point this out. It would suck to do this manually if you had any number larger than 12. Imagine if you had 200 objects onstage and everyone was potentially not on a whole pixel. The world would be doomed without this.
// An array of objects that are selected.
var objects = fl.getDocumentDOM().selection
// Loop thru the objects and set their X and Y coordinates to a round number.
for(var i = 0; i < objects.length; i++){
objects[i].x = Math.round(objects[i].x)
objects[i].y = Math.round(objects[i].y)
}
Thats it. Stick the above code in a JSFL file, select some objects and run it.
SOURCE FILE
No comments
