All posts by Angel Vladov

Creating an image only mobile button skins for Flex 4 (AIR Mobile)

One of the main differences when creating mobile Flex AIR apps from normal Flex Apps is that it’s better to use ActionScript only skins. With that in mind I’ve created a simple skin for image buttons.

Why this skin is better than using the default spark.skins.mobile.ButtonSkin? The answer is quite simple – performance. Since this is going to be an image only skin, we don’t need label element and all the other functionality the default mobile button skin has.

In order to use the class you just create a new skin extending the ImageButtonSkin. The properties you have to set inside tour constructor are upBorderSkin, downBorderSkin, measuredDefaultWidth and measuredDefaultHeight.

For the border skin properties you can use – images, SWF symbols, FGX files

Usage example:

public class ExampleButtonSkin extends ImageButtonSkin {

    [Embed(source="/assets/buttons/Example_up.png")]
    private var up:Class;

    [Embed(source="/assets/buttons/Example_down.png")]
    private var down:Class;
    
    public function ExampleButtonSkin ButtonSkin() 
    {
        super();
        upBorderSkin = up;
        downBorderSkin = down;
        measuredDefaultWidth = 230;
        measuredDefaultHeight = 80;
    }
}

If you want to use FXG border skins then you don’t need up and down variabled. You can set the FXG classes on the upBorderSkin and downBorderSkin directly.
Continue reading Creating an image only mobile button skins for Flex 4 (AIR Mobile)

JavaScript .Net like String formatting function

Just a simple extend to the JavaScript String prototype which makes things much more readable 🙂

String.prototype.beginsWith = function(str) {return (this.match("^"+str)==str)}
String.prototype.endsWith = function(str) {return (this.match(str+"$")==str)}
String.prototype.format = function() {
    var s = this,
        i = arguments.length;

    while (i--) {
        s = s.replace(new RegExp('\{' + i + '\}', 'gm'), arguments[i]);
    }
    return s;
};

Example:

var str = 'Just a {0} test to {1} if things works. Really {0}, isn't it?';
alert(str.format('simple', 'see');

How to fix sound/video problems in Ubuntu

For all of you out there struggling to fix their Ubuntu sound issues 🙂

  1. Fixing sound (microphone):

    sudo gedit /etc/modprobe.d/blacklist

  2. Fixing video driver (tpm error at startup)

    sudo gedit /etc/modprobe.d/blacklist

     Add the following lines:

    #trusted platform module
    blacklist tpm
    blacklist tpm_bios
    blacklist tpm_infineon
    blacklist tpm_tis

  3. Fixing output sound from headphones

    sudo gedit /etc/modprobe.d/alsa-base.conf

    Add these lines at end of file:

    options snd-hda-intel model=3stack enable=yes
    options snd-hda-intel model=auto position_fix=1 enable=yes

  4. Fixing SKYPE 2.2 video to work

    Run skype using this command (change links in menu)

    bash -c ‘LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype’