Friday, July 26, 2013

Tour de Flex

I was trying to look for the Style Explorer for Flex 4 but it seems that the closest alternative right now would be...

The contents shown in the above are taken from 'Adobe' website.

You can click on the button shown in the above to download and
install the desktop application 'Tour de Flex' too.

* Click here for the official website for 'Tour de Flex'.
^ Click here for the web version of 'Tour de Flex'.

Thursday, July 18, 2013

One of Windows OS missing component - Rename Multiple Filenames

Sometimes renaming a list of files can be pretty annoying and it gets more and more frustrating when there are a lot of files. And this can be pretty disturbing to the type of people that prefer to rename their filename with something meaningful. Therefore you can consider the following softwares.

  • A.F.5
    • I'm using this in the office. Basically, the interface of this software is pretty simple and although it doesn't come with a lot of features, but it is already more than enough.
  • Bulk Rename Utility
    • As I was browsing through blogs, discussion boards, etc, this seems to be one of the hottest alternative. It can even support filename replacement using Regular Expressions. However, the interface looks kinda squeezy to me. =.=

Friday, July 12, 2013

Creating a custom Service

Well, basically if you are using a Windows server or you are doing a lot of development work, you might be running a lot of services locally. (Ex: Apache, WAMP, etc...) Imagine how much time you can save by creating a Service that will start these programs automatically.

Steps for creating a new Windows Service
Before moving on any further, you will need to grab hold of these 2 files first.
They are instsrv.exe and srvany.exe.

Click here to download the files now.
Click here to download the original package from Microsoft.
(If you are using the package from Microsoft,
you will need to extract the files from the package.)

Step 1 - Open up the Windows Start menu, enter cmd into the
Search programs and files field, Right-Click on the program
cmd.exe and select Run as Administrator.

Step 2 - Enter the following into the Command Prompt window.

"{yourPath}\instsrv.exe" {name} "{yourPath}\srvany.exe"
Replace {yourPath} with the directory that has the files instsrv.exe and srvany.exe.
Replace {name} with the Name of the new Service that you are going to create.

And there you go, you have successfully created a new Empty Service.

Step 3 - Open up the Windows Start menu, enter regedit into the
Search programs and files field and run the program regedit.exe.

Step 4 - Look for the new Service under the following directory.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{name}
Replace {name} with the Name of the new Service that you have created.

Step 5 - After selecting the new Service that you have created, Right-Click and
create a new Key. Rename the new Key as Parameters

Step 6 - Under Parameters add a few new String Value.

Step 7 - Entering some values
NameTypeData
ApplicationREG_SZ{the full path of your application}
Ex: G:\service\run_notepad.bat
AppDirectoryREG_SZ{the path to your application}
Ex: G:\service\

Step 8 - Open up the Windows Start menu, enter services into the
Search programs and files field and run the program Services.

Step 9 - Locate and open up the new Service that you have created.

Step 10 - You can set the Startup Type to either Automatic or
Automatic (Delayed start). (Automatic will start the Service
when Windows boots up. Automatic (Delayed start) will start 2 minutes
after the last Automatic Service has been executed.)

On top of that, some programs will only run smoothly with a particular user
account. That's where the Log On tab comes in. You can specify the
User Account Credentials that you are going to use when you run this Service.

Step Remove - To remove a Service,
type the following command in Command Prompt window.

"{yourPath}\instsrv.exe" {name} REMOVE
Replace {yourPath} with the directory that has the file instsrv.exe.
Replace {name} with the Name of the Service that you are going to delete.

And there you go, you have successfully removed a Service.

Wednesday, July 3, 2013

Flex: Accessing the buttons of a ButtonBar

I was trying to figure out a way to access the individual buttons of the ButtonBar yesterday. After spending a bit of time working on it, I finally managed to do it. Here's a solution to the problem.

Here's the source code of my main application - SimpleButtonBarSelect.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      creationComplete="creationCompleteEvent(event)"> 
 <fx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
   import mx.events.FlexEvent;
   import mx.events.IndexChangedEvent;
   
   import spark.components.ButtonBarButton;
   import spark.events.IndexChangeEvent;
   
   //A set of data that will be used to populate the ButtonBar
   [Bindable]
   private var dummyData:ArrayCollection = new ArrayCollection(
    [{label: "1", value:9},
    {label: "2", value:8},
    {label: "3", value:7},
    {label: "4", value:6},
    {label: "5", value:5},
    {label: "6", value:4},
    {label: "7", value:3},
    {label: "8", value:2},
    {label: "9", value:1}]);
   
   //Upon clicking on one of the checkbox,
   protected function clickEvent(event:MouseEvent):void
   {
    var isOddDisable:Boolean = chkOdd.selected;
    var isEvenDisable:Boolean = chkEven.selected;
    
    var tempButton:ButtonBarButton;
    var tempLabelNum:Number;
    
    //Loop through all the buttons of the ButtonBar
    for(var i:int = 0; i < btnBar.dataGroup.numElements; i ++)
    {
     tempButton = ButtonBarButton(btnBar.dataGroup.getElementAt(i));
     tempLabelNum = Number(tempButton.label);
     if(tempLabelNum % 2 == 0)
     {
      //If the label is a odd number
      //check it against the value of the chkOdd checkbox
      tempButton.enabled = !isEvenDisable;
     }else{
      //If the label is a even number
      //check it against the value of the chkEven checkbox
      tempButton.enabled = !isOddDisable;
     }
    }
   }
   
   //Upon clicking on one of the buttons of the ButtonBar, we
   //will update the 'Result:"
   protected function changeEvent(event:IndexChangeEvent):void
   {
    var tempBar:ButtonBar = ButtonBar(event.target);
    var tempObj:* = tempBar.selectedItem;
    
    lblResult.text = "Result: Button " + tempObj.label +
     " with a value of " + tempObj.value + " has been selected."
   }
   
   //Dispatch a change event at the start of the application since
   //one of the buttons are selected by default.
   protected function creationCompleteEvent(event:FlexEvent):void
   {
    btnBar.dispatchEvent(new IndexChangeEvent(IndexChangeEvent.CHANGE));
   }
   
  ]]>
 </fx:Script>
 <s:VGroup width="100%"
     height="100%" 
     verticalAlign="middle" 
     horizontalAlign="center">
  <s:Label text="Click on the following to disable the respective buttons."/>
  <s:HGroup width="100%" >
   <s:Spacer width="100%"/>
   <s:CheckBox id="chkOdd"
      label="Disable Odd Buttons"
      click="clickEvent(event)"/>
   <s:CheckBox id="chkEven"
      label="Disable Even Buttons"
      click="clickEvent(event)"/>
   <s:Spacer width="100%"/>
  </s:HGroup>
  <s:ButtonBar id="btnBar" 
      dataProvider="{dummyData}" 
      requireSelection="true" 
      labelField="label"
      change="changeEvent(event)"/>
  <s:Label id="lblResult" text="Result:"/>
 </s:VGroup>
</s:Application>
* Click here for the demo shown in this post.
^ Click here for the source files for the demo.