February 29th, 2008 by Hans Wichman
Although I wish I could learn to draw by the book, at this point in my life I don’t see it happening anytime soon. Assuming I’m not too tired to draw, I’m almost always too tired to do repetitive exercises (that’s why I’ll never be a great guitar player either
). Although drawing in general helps you improve, it’s not the same as studying art. Ah well I decided that that is how it is for now, I’m sure it’ll change someday and I can invest more time in the foundations of drawing instead of simply just reproducing what others drew before me.
That said, beautiful women and scary beasties ofcourse remain my favourite subject, and luckily there’s a lot of them to go around, so I can keep this up for years:). Here is some more Luis Royo fanart, just a quick sketch, but I liked it nonetheless.

Posted in Artwork | 3 Comments »
February 25th, 2008 by Hans Wichman
Posted in Artwork | No Comments »
February 2nd, 2008 by Hans Wichman
Today I got some funny comments on my blog, and with even more weirdness in the comments management panel, so it was that time again to change the passwords and perform another security upgrade. So welcome to this new version of wordpress. Installation was as painless as ever.
Posted in General | No Comments »
January 30th, 2008 by Hans Wichman
Also known as a Non Selectable Transparent Textfield With Embedded Font :).
Some of the V2 Flash Components are less than intuitive now and then. While working on the new trophy tour for Heineken we had to create an application with a transparent textarea with non selectable non editable text using a non standard (embedded) font with Spanish characters (amongst others) ( in Flash 8 ). Oh yeah and the text had to be rendered smoothy using advanced anti-aliasing.
This leaves you with different options. Although I was tempted to simply use a standard textfield, this should be easy to implement using a TextArea component as well, right? Sure. As an easy reference for our own and your convenience, here is a step by step approach.
Creating the test movie
- create a new flash movie, size it 300 x 300, and choose a background other than white
- drag a TextArea on stage, name it ‘ta_test’ and enter some text for the text parameter in the parameter section
- compile the movie, you’ll see a textarea with a border, a white background, whose text is editable and selectable
ActionScript 2, timeline scripting or parameter settings?
You’ll have to decide if you want to approach this using the parameter settings, timeline code or actionscript 2 code. In some cases you can choose, and in some I found timeline code was the easy/only option. This can probably be fixed by waiting a few frames after instantiating the TextArea, but this sounds like a nice exercise for some other time. Let’s keep it simple for now and use whatever works for demonstration purposes.
Read the rest of this entry »
Posted in AS2, Flash, Tutorial | No Comments »
January 30th, 2008 by Hans Wichman
The funny thing with ‘professional’ software is the weird things you run into. Everytime. When you don’t need it. At 1 A.M.
This time around Outlook started whining about objects not found. It didn’t say which object which is kind of an easy way out. I can just see ourselves running around “Couldn’t find an object, couldn’t find an object”. Go figure.
Solutions on the microsoft site led to nowhere. They proposed creating a new profile, migrating all your mail, settings, rules etc to the new profile. I think not! The problem was easily created (really, I didn’t even had to do anything !) it should be easily fixable.
Luckily after googling for an hour or so I found this one:
Outlook 2003 The operation failed. An object could not be found error
“Answer: Close outlook, simply delete all the *srs files from %userprofile%\application data\Microsoft\Outlook.
EG C:\Documents and Settings\username\Application Data\Microsoft\Outlook\outlook.srs
When outlook is re-opened it will create a new *.srs file (* = the name of your profile in outlook)”
Yeah baby, simplicity rocks!
Posted in Tips&Tricks | No Comments »
January 23rd, 2008 by Hans Wichman
Also known as:
cannot click more than once on flash button
have to move mouse before you can click a button again
v2 components cause weird strange button behavior
If you work with V2 components in Flash, this tip will surely help you out some day: when using V2 Components such as a Combobox, you may find your buttons no longer work correctly. Overall, this manifests itself by not being able to click more than once on a button. Before you can once again click on the button, you must first move the mouse again. Especially with navigation buttons, on which you are usually click-click-click-click-click-ing, this is less than optimal.
This is appearently caused by some components which are not playing nice with a component’s focus. The fix is relatively simple and disturbing at the same time:
In the onPress handler of such a button, you must include the following:
Selection.setFocus (this);
A focus rectangle now appears on every button, and to remove that, you use the following:
this._focusrect = false;
It is also possible to apply this to all buttons at once:
Button.prototype.onPress = function () (
this._focusrect = false;
Selection.setFocus (this);
)
This will not be an option in most cases however, unless you rigidly commit yourself to overriding only a button’s onRelease handler.
Posted in AS2, Flash, Tips & Tricks | 3 Comments »
January 18th, 2008 by Hans Wichman
I started working on a new painting this week, and this time it’s an elephant painting. This thread posts the sketch and a few steps to the end result (at the bottom!).
Basic sketch
Dark background
First step in color process
Second step in color process
Done !
(Click image for larger version)
Posted in Artwork | 4 Comments »
December 7th, 2007 by Hans Wichman
When implementing super and subclasses, Flash will call the superclass’ constructor automatically unless you call it yourself.
‘Great’, I hear you think. Well… not so much.
Imagine you have the following code:
class Super {
public function Super () {
trace ("super called");
}
}
class Sub extends Super {
}
var myObject:Object = new Sub();
Result? Yes indeed, it traces “super called”. The constructor for Sub doesn’t exist, so the default constructor is used, which calls the super class constructor by default.
All’s fine…
Next example:
class Super {
public function Super (pName:String) {
trace ("super called with "+pName);
}
}
class Sub extends Super {
}
var myObject:Object = new Sub();
Result? The super constructor is still called! (To my amazement, but anyway). It is called with no parameters since we didn’t pass any, so I guess that was to be expected. So although this is a little evidence that we should have called the constructor explicitly, it still wouldn’t have prevented us from calling it without parameters.
Ok, next bit of code:
class Super {
public function Super (pName:String) {
trace ("super called with "+pName);
}
public function mySuperMethod() {
}
}
class Sub extends Super {
public function Sub() {
}
}
var myObject:Object = new Sub();
Result? Yes, the super constructor is still called, since that was the default behavior. Us defining a constructor doesn’t mean we have overridden the superclass constructor.
Ok, let’s move on!
class Super {
public function Super (pName:String) {
trace ("super called with "+pName);
}
public function mySuperMethod() {
}
}
class Sub extends Super {
public function Sub() {
super.mySuperMethod();
}
}
var myObject:Object = new Sub();
Result? The super constructor is NO LONGER called. Appearently something is getting messed up by the super. statement. In both the Flash IDE and the MTASC compiler the super constructor fails to run. If we replace super.mySuperMethod(); with mySuperMethod(); the super constructor is called again. Note that super.mySuperMethod is NOT a case of calling the superclass’ constructor, I’m simply calling one of the superclass’ methods.
Conclusions:
- always called super ( … ) ; explicitly
- do not use super. to clarify your code, unless you consequently follow the first rule
Posted in AS2, Flash, Research, Tutorial | No Comments »
December 7th, 2007 by Hans Wichman
I love saying those 4 words, don’t you? Repeat after me “BLUE SCREEN OF DEATH BLUE SCREEN OF DEATH”, and why shouldn’t we, time enough to do so while trying to fix those annoying day wasting system crashes.
In this case the following applies:
- BSOD ( blue of screen death ) occurs on system reboot through a RDP ( remote desktop connection )
- The message is ati2dvag.dll TERMINAL_SERVER_DRIVER_MADE_INCORRECT_MEMORY_REFERENCE
In my case the following steps fixed the problem:
- Goto My Computer, Hardware, Display Devices, Delete ATI display device
- reboot
- download and install latest ATI driver only package (7.11)
- install drivers
- reboot
Done. Hope this helps you too.
Posted in Tips&Tricks | No Comments »
November 30th, 2007 by Hans Wichman
A piece of code and a demo says more than a thousand words :). This code demonstrates inversion of an alpha channel in Flash8/AS2.
/**
* This example demonstrates inverting an alpha channel on an image.
* Since Flash premultiplies the alpha, we need to keep two separate images: one with the color data, and
* one with the alpha data. It demonstrates splitting the alpha from an image, inverting and proves
* premultiplying the alpha destroys color information.
*
* @author J.C. Wichman / Objectpainters.com
*/
-
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.BitmapData;
import flash.filters.ColorMatrixFilter;
-
//set up some default params for the images
var width:Number = 100;
var height:Number = 100;
var fillColor:Number = 0x000000;
-
/**
* Simple function that checks how many bitmaps have already been shown on stage and
* bases the location for the next one on that information. Never use code like this
* out of context, since its bad programming practice:).
*/
function showBitmap (pBitmap:BitmapData, title:String) {
var imageCount:Number = this.getNextHighestDepth();
var row:Number = Math.floor (imageCount/3);
var columns:Number = imageCount%3;
-
var newClip:MovieClip = this.createEmptyMovieClip("image"+imageCount, imageCount);
newClip.attachBitmap(pBitmap, 0);
newClip.createTextField("title", 1, 0, 110, 10,10);
var textClip:TextField = newClip["title"];
textClip.autoSize = true;
textClip.text = "Image "+imageCount+":\n"+title;
var tf:TextFormat = new TextFormat();
tf.font = "Arial";
tf.align ="center";
textClip.setTextFormat(tf);
-
newClip._x = (columns * 150)+10;
newClip._y = (row * 170)+10;
}
-
-
//setting up demo rgb image, this is an image without alpha.
//Since flash uses premultiplied alpha, adding an alpha channel will ruin the image for
//further use when we want to invert the alpha channel, so we keep colours separate from alpha
//(omg pink shirts!)
var colorImage:BitmapData = new BitmapData(width, height, false, fillColor);
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
//fiddle with the pixel data to show a dark gradient
colorImage.setPixel( x,y, x<<16|y<<8|x+y);
}
}
showBitmap (colorImage, "Colour w/o alpha");
-
//now we create a demo alpha bitmap. All color info is non existent, only
//alpha data is set. When x<y the alpha value is near opaque, otherwise its near transparent.
//we only use 0xAF and 0x10 instead of 0xFF and 0x00 to show partial alpha values are inverted ok as well
var demoAlpha:BitmapData = new BitmapData(width, height, true, fillColor);
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
demoAlpha.setPixel32( x,y, (x<y?0xAF:0x10)<<24);
}
}
showBitmap (demoAlpha, "Alpha only");
-
//now imagine you didnt have a separate alpha bitmap to start with, but a starting image with alpha
//which you needed to extract first:
var alphaSplit:BitmapData = new BitmapData(width, height, true, fillColor);
//copy the alpha channel of one image to another image
alphaSplit.copyChannel(demoAlpha, new Rectangle(0,0, width, height), new Point(0,0), 8,8);
showBitmap (alphaSplit, "Alpha channel copy\n (same as previous)");
-
//now we are going to invert the alpha. This can be done on a pixel by pixel basis, but this might just
//be faster, you'd have to test it
var alphaInvert:BitmapData = alphaSplit.clone();
var matrix:Array = new Array();
matrix = matrix.concat([1, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, 1, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, 1, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, -1, 0xff]); // alpha, negate the alpha and add 255
alphaInvert.applyFilter(alphaInvert, alphaInvert.rectangle, new Point(0, 0), new ColorMatrixFilter (matrix));
showBitmap (alphaInvert, "Inversion of \nalpha channel");
-
//now the real action, we combine our original color pixels with the inverted alpha channel
var comboImage:BitmapData = new BitmapData(width, height, true, fillColor);
comboImage.copyPixels(colorImage, colorImage.rectangle, new Point(0,0), alphaInvert, new Point(0,0));
showBitmap (comboImage, "Colours + \ninverted alpha");
-
//now to prove premultiplied alpha destroys color information:
var colorImgWithAlpha:BitmapData = new BitmapData(width, height, true, fillColor);
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
//fiddle with the pixel data to show a dark gradient
colorImgWithAlpha.setPixel32( x,y, (x<y?0xfe:0x01)<<24|x<<16|y<<8|x+y);
}
}
colorImgWithAlpha.applyFilter(colorImgWithAlpha, colorImgWithAlpha.rectangle, new Point(0, 0), new ColorMatrixFilter (matrix));
showBitmap (colorImgWithAlpha, "Colour with\n premultiplied \n inverted alpha");
-
-
-
- Download this code: invertBitmapAlpha.txt
Posted in AS2, Flash, Tutorial | No Comments »