Luis Royo Fanart

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.

Unspoken

February 25th, 2008 by Hans Wichman

Experimenting with different versions of the same image. Not sure what my personal favourite is, I think the 3rd. The top one is clearly starting to be overdone.









Wordpress upgrade

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.

NSTTWEF !!

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

  1. create a new flash movie, size it 300 x 300, and choose a background other than white
  2. drag a TextArea on stage, name it ‘ta_test’ and enter some text for the text parameter in the parameter section
  3. 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 »

Outlook 2003 An object could not be found

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!

Flash Button Bug

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.

    Elephant Painting Finished

    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

    Elephant sketch

    Dark background

    Elephant sketch

    First step in color process

    Elephant 1st colour

    Second step in color process

    Elephant 2nd colour

    Done !


    Elephant done

    (Click image for larger version)

    Why you MUST call super

    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

    Blue Screen of Death

    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.

    Inverting the alpha of a bitmap image

    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.

    1. /**
    2. * This example demonstrates inverting an alpha channel on an image.
    3. * Since Flash premultiplies the alpha, we need to keep two separate images: one with the color data, and
    4. * one with the alpha data. It demonstrates splitting the alpha from an image, inverting and proves
    5. * premultiplying the alpha destroys color information.
    6. *
    7. * @author J.C. Wichman / Objectpainters.com
    8. */
    9.  
    10. import flash.geom.Rectangle;
    11. import flash.geom.Point;
    12. import flash.display.BitmapData;
    13. import flash.filters.ColorMatrixFilter;
    14.  
    15. //set up some default params for the images
    16. var width:Number = 100;
    17. var height:Number = 100;
    18. var fillColor:Number = 0x000000;
    19.  
    20. /**
    21. * Simple function that checks how many bitmaps have already been shown on stage and
    22. * bases the location for the next one on that information. Never use code like this
    23. * out of context, since its bad programming practice:).
    24. */
    25. function showBitmap (pBitmap:BitmapData, title:String) {
    26. var imageCount:Number = this.getNextHighestDepth();
    27. var row:Number = Math.floor (imageCount/3);
    28. var columns:Number = imageCount%3;
    29.  
    30. var newClip:MovieClip = this.createEmptyMovieClip("image"+imageCount, imageCount);
    31. newClip.attachBitmap(pBitmap, 0);
    32. newClip.createTextField("title", 1, 0, 110, 10,10);
    33. var textClip:TextField = newClip["title"];
    34. textClip.autoSize = true;
    35. textClip.text = "Image "+imageCount+":\n"+title;
    36. var tf:TextFormat = new TextFormat();
    37. tf.font = "Arial";
    38. tf.align ="center";
    39. textClip.setTextFormat(tf);
    40.  
    41. newClip._x = (columns * 150)+10;
    42. newClip._y = (row * 170)+10;
    43. }
    44.  
    45.  
    46. //setting up demo rgb image, this is an image without alpha.
    47. //Since flash uses premultiplied alpha, adding an alpha channel will ruin the image for
    48. //further use when we want to invert the alpha channel, so we keep colours separate from alpha
    49. //(omg pink shirts!)
    50. var colorImage:BitmapData = new BitmapData(width, height, false, fillColor);
    51. for (var x = 0; x < width; x++) {
    52. for (var y = 0; y < height; y++) {
    53. //fiddle with the pixel data to show a dark gradient
    54. colorImage.setPixel( x,y, x<<16|y<<8|x+y);
    55. }
    56. }
    57. showBitmap (colorImage, "Colour w/o alpha");
    58.  
    59. //now we create a demo alpha bitmap. All color info is non existent, only
    60. //alpha data is set. When x<y the alpha value is near opaque, otherwise its near transparent.
    61. //we only use 0xAF and 0x10 instead of 0xFF and 0x00 to show partial alpha values are inverted ok as well
    62. var demoAlpha:BitmapData = new BitmapData(width, height, true, fillColor);
    63. for (var x = 0; x < width; x++) {
    64. for (var y = 0; y < height; y++) {
    65. demoAlpha.setPixel32( x,y, (x<y?0xAF:0x10)<<24);
    66. }
    67. }
    68. showBitmap (demoAlpha, "Alpha only");
    69.  
    70. //now imagine you didnt have a separate alpha bitmap to start with, but a starting image with alpha
    71. //which you needed to extract first:
    72. var alphaSplit:BitmapData = new BitmapData(width, height, true, fillColor);
    73. //copy the alpha channel of one image to another image
    74. alphaSplit.copyChannel(demoAlpha, new Rectangle(0,0, width, height), new Point(0,0), 8,8);
    75. showBitmap (alphaSplit, "Alpha channel copy\n (same as previous)");
    76.  
    77. //now we are going to invert the alpha. This can be done on a pixel by pixel basis, but this might just
    78. //be faster, you'd have to test it
    79. var alphaInvert:BitmapData = alphaSplit.clone();
    80. var matrix:Array = new Array();
    81. matrix = matrix.concat([1, 0, 0, 0, 0]); // red
    82. matrix = matrix.concat([0, 1, 0, 0, 0]); // green
    83. matrix = matrix.concat([0, 0, 1, 0, 0]); // blue
    84. matrix = matrix.concat([0, 0, 0, -1, 0xff]); // alpha, negate the alpha and add 255
    85. alphaInvert.applyFilter(alphaInvert, alphaInvert.rectangle, new Point(0, 0), new ColorMatrixFilter (matrix));
    86. showBitmap (alphaInvert, "Inversion of \nalpha channel");
    87.  
    88. //now the real action, we combine our original color pixels with the inverted alpha channel
    89. var comboImage:BitmapData = new BitmapData(width, height, true, fillColor);
    90. comboImage.copyPixels(colorImage, colorImage.rectangle, new Point(0,0), alphaInvert, new Point(0,0));
    91. showBitmap (comboImage, "Colours + \ninverted alpha");
    92.  
    93. //now to prove premultiplied alpha destroys color information:
    94. var colorImgWithAlpha:BitmapData = new BitmapData(width, height, true, fillColor);
    95. for (var x = 0; x < width; x++) {
    96. for (var y = 0; y < height; y++) {
    97. //fiddle with the pixel data to show a dark gradient
    98. colorImgWithAlpha.setPixel32( x,y, (x<y?0xfe:0x01)<<24|x<<16|y<<8|x+y);
    99. }
    100. }
    101. colorImgWithAlpha.applyFilter(colorImgWithAlpha, colorImgWithAlpha.rectangle, new Point(0, 0), new ColorMatrixFilter (matrix));
    102. showBitmap (colorImgWithAlpha, "Colour with\n premultiplied \n inverted alpha");
    103.  
    104.  
    105.