Month: March 2012

  • How to make opacity background for TextField in Flash or add alpha channel for background color

    How to make opacity background for TextField in Flash or add alpha channel for background color

    Hi, here I want to show you how to add alpha channel for TextField background color in Flash.

    You can do it using next source code below:

    textField = new TextField();
    textField.blendMode = BlendMode.LAYER;
    textField.alpha = .9; // opacity = 90%
    textField.background = true;
    textField.backgroundColor = 0x000000;

    Happy coding!

  • How to forward port into VirtualBox or How to connect with guest virtual machine via ssh

    How to forward port into VirtualBox or How to connect with guest virtual machine via ssh

    Let me describe my task.
    I have installed Linux Ubuntu Server in my VirtualBox. I use this virtual machine for some experiments. I don’t want do some tasks on my physical PC.

    To connect with this Virtual Machine I want to use SSH.

    It can be done via forwarding physical PC port in Virtual Machine.

    Here is how to do this.
    Run this commands in terminal:

    $ VBoxManage setextradata "YOUR_VM_NAME" \
    "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP
    
    $ VBoxManage setextradata "YOUR_VM_NAME" \
    "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
    
    $ VBoxManage setextradata "YOUR_VM_NAME” \
    "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222

    Replace pcnet with e1000 if you are using Gigabit adapter

    Now if you connect to your PC via ssh with 2222 port you will forwarded in Virtual Machine

    ssh -p 2222 hudson@localhost

    Where hudson – username on Virtual Machine
    That’s all

  • How to write logcat from emulator (device) to external file. Or trick with Continuous Integration

    How to write logcat from emulator (device) to external file. Or trick with Continuous Integration

    Let me describe my problem.

    I have Android project which is under Continuous Integration (CI) server. In my case it is Jenkins.

    Then I run my tests I just can see JUnit output in Jenkins console.

    If some unexpected error happens I can’t see logcat from Android emulator.

    Here I want to show you how I grab logcat from Android emulator. Now If something strange happens I can see logcat from emulator.

    I made it using BASH script which is bellow. This script grab logcat and periodically check logcat filesize AND can create new file for logcat if it is greater than 5MB. Script can add time postfix to file if new one file was created.

    PLEASE, TELL ME IF YOU KNOW THE BETTER SOLUTION !!!

    HERE the BACH script:

    #!/bin/sh
    LOGCATFILE=$1/logcat.out
    touch $LOGCATFILE
    adb -s $2 logcat -v time > $LOGCATFILE&
    PID=$!
    
    while true; do
    FILESIZE=$(stat -c%s "$LOGCATFILE")
    echo "Size of $LOGCATFILE = $FILESIZE bytes."
    echo "PID = $PID"
    if [ "$FILESIZE" -gt 5242880 ]
    then
    echo "$LOGCATFILE is too large = $FILESIZE bytes."
    now=$(date +"%Y_%m_%d_%H_%M_%S")
    NEWLOGFILENAME=/home/igor/logcat_$now.out
    cp $LOGCATFILE $NEWLOGFILENAME
    kill -9 $PID
    adb -s $2 logcat -v time > $LOGCATFILE&
    PID=$!
    fi
    sleep 10
    done

    To run just create file with executable permission and as parameter to script write path to dir with log
    SECOND parameter is your device name which you can get when run adb devices in your terminal

    Example:

    igor@igor-laptop:~$ adb devices
    List of devices attached
    HT10WPL00853 device

    The script parameters in my case will be next:

    igor@igor-laptop:~$ ./write_logcat.sh ~/Temp HT10WPL00853

    Hope, It help you!