There seems to have been a lot of Flash bashing, both within the community and without, in the last few weeks. In terms of the external criticism, I refrained from a knee jerk reaction: “Flash sucks? Well, YOU suck!” and actually took a look for myself at the state of Flash. Of course, there are some on the outside who would say that there is no excuse for Flash anywhere ever. They refuse to even install the Flash player plugin on their machine. On the other end of the spectrum are those who think that Flash is the be-all and end-all. If it can’t be done in Flash, it isn’t worth doing.
Read more...Simple one but useful.
[as3]new FPSMeter(this, 10, 10);[/as3]
gives you a numeric readout of the current calculated frames per second.
Demo time:
[kml_flashembed publishmethod=“static” fversion=“10.0.0″ movie=“https://www.bit-101.com/2003/wp-content/uploads/2009/08/FPSDemo.swf” width=“400″ height=“400″ targetclass=“flashmovie”]
[/kml_flashembed]
Here’s the code for that demo:
[as3]package
{
import com.bit101.components.*;
import flash.display.Sprite;
import flash.events.Event;
[SWF(backgroundColor=0xeeeeee, width=400, height=400)]
public class Playground extends Sprite
{
private var running:Boolean;
public function Playground()
{
new FPSMeter(this, 10, 10);
new PushButton(this, 10, 30, “Draw”, onClick);
new PushButton(this, 10, 55, “Clear”, onClear);
}
A bit off topic, so I’ll keep it short. For the last year or so I have given Pistach.io exclusive ad rights to this site. This is no longer an exclusive deal and actually there will be no Pistach.io ads on this site as of the end of this month. I am currently selling ads through https://buysellads.com/. Click the “Advertise Here” block on the left if you are interested. Or contact me directly if you want something more custom.
Read more...You make a text field, give it a text format, and put some text in it. All is good, until you start doing something to that text field. There are at least two specific problems you’ll run into:
Rotate it and your text disappears.
Scale it up or down, and it’s going to be all jittery as the text field chooses different sizes of text to match the scale.
Normally, the handling for all of these is to embed the font in the text field. But with Flash 10, there’s a quick trick that might get you by in a lot of these cases: use 3D properties.
Read more...Today on Twitter, Robert Penner posted a couple of really interesting links…
https://theshyam.com/2009/08/is-inheritance-overrated-needed-even/
and
https://code.google.com/p/noop/wiki/ProposalForComposition
This got me in a researchy mood about inheritance vs. composition, and I dug up this great series of interviews with Erich Gamma (one of the original Design Patterns Gang of Four):
https://www.artima.com/lejava/articles/gammadp.html
https://www.artima.com/lejava/articles/reuse.html
https://www.artima.com/lejava/articles/designprinciples.html
Actually, the last one had the info I was more looking for, but the first two are chock full of interesting data and viewpoints. This post is about some of the data in the second article on flexibility and reuse. Gamma talks about three levels of code reuse:
Read more...Well, we have the first major contribution by someone other than myself. Rashid Ghassempouri decided to revamp the color chooser to allow for a color panel popup so you can choose a color with the mouse. Actually, he added all kinds of cool options to it, but in the interest of keeping minimal minimal, I cut it back a bit. 🙂
Anyway, now you can specify “myColorChooser.popup = true;” and you’ll get a default gradient color popup that you can choose just about any color from with a click of the mouse. You can also pass an instance of any display object to the “model” property, and that display object will be used as the popup. Finally, you can specify “popupAlign” as either “top” or “bottom” (ColorChooser.TOP, ColorChooser.BOTTOM), and the popup will appear in that direction. Here’s a bit of a demo:
Read more...My good friend, Tink, has been bugging me for close to a year to come to London and do a training workshop for the London Flash Platform User Group. I finally gave in since I’ll be in the neighborhood next month for FOTB. Here’s the details:
https://www.lfpug.com/actionscript-30-animation/
Basically, I’ll be going through a good portion of the materials of Foundation ActionScript 3.0 Animation: Making Things Move!, in roughly the same order as they are presented in the book. It’s a two-day workshop and I believe the audience is limited to about 15, so it should offer plenty of time for in-depth explanations, hands-on coding, and one-on-one help. Last I talked to Tink, about half the seats were sold, so if you’re in the vicinity, or will be that week, and it seems like something you might benefit from, don’t wait til the last minute.
Read more...I assume the latter…
Anyway, trying to wrap my head around AS3’s Matrix3d class. In particular, the pointAt method. This supposedly, “Rotates the display object so that it faces a specified position.”
Here’s the class I’m using for testing:
[as]package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Vector3D;
[SWF(width=800, height=800)]
public class MatrixStuff extends Sprite
{
[Embed (source=“Compass.jpg”)]
private var Compass:Class;
private var sprite:Sprite;
public function MatrixStuff()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var compass:Bitmap = new Compass();
compass.x = -compass.width / 2;
compass.y = -compass.height / 2;
sprite = new Sprite();
sprite.addChild(compass);
sprite.x = 400;
sprite.y = 400;
sprite.z = 100;
addChild(sprite);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
sprite.transform.matrix3D.pointAt(new Vector3D(mouseX, mouseY, 0));
}
}
}[/as]
This should make the image “face” the mouse. Here’s the result:
Read more...I just noticed that my Minimal Components have been added to wonderfl.
https://wonderfl.net/blog/2009/08/added-some-libraries-and-checkmate-vol2-started.html
If you’re not familiar with wonderfl, it’s a site that allows you to type ActionScript into the page and compiles and runs it right there. You can then save and share your own creations and modify the creations of others. It contains a bunch of libraries for different effects and functionalities, and now contains my components.
Read more...Now with full class generation. 🙂
Even generates empty event handlers if you specify an event.
I actually went through and refactored all those nasty long conditionals into strategies. That worked nicely. Now when i release the code, you won’t puke all over your computer. 🙂
https://www.bit-101.com/MinimalDesigner/
I fixed the bugs people told me about, but with all the refactoring today, may have introduced a bunch of new ones. I know there are a few formatting issues in the class, but we’ll deal with those later. So far, everything it generates has compiled for me. Yay!
Read more...