Fastest way to shut down Windows OS
Tired of fucking waiting and waiting…. for Windows to shut down. Yeah, I do!
Here’s a way which will shut down Windows completely in few seconds.
Press Ctrl-Alt-Del to open Windows Task Manager, click on Shut Down menu option and while pressing the Ctrl key, click on the Turn Off option.
Now as you count 1…2….3….4…..5….System Shut Down
Dynamically add element / attribute to a XML using E4X
Written for: Flex, ActionScript 3.0
To dynamically add element / attribute to a XML; assume that it already exists in the XML and using the .(dot) operator, pass a value to it.
Here’s an example. Consider the following XML:
var albumXML:XML = <tracks> <song tracknumber="1"> <title>Orgasm Addict</title> <artist>Buzzcocks</artist> </song> <song tracknumber="2"> <title>What Do I Get?</title> <artist>Buzzcocks</artist> </song> <song tracknumber="3"> <title>I Dont Mind</title> <artist>Buzzcocks</artist> </song> <song tracknumber="4"> <title>Love You More</title> <artist>Buzzcocks</artist> </song> </tracks>;
To add an additional element of <genre> to the first <song> node, I’ll use the following line of code.
albumXML.song[0].genre = 'Punk';
Similarly to add an attribute of duration to the first <song> node, I’ll use.
albumXML.song[0].@duration = '2:00';
trace(albumXML);
/*
<tracks>
<song tracknumber="1" duration="2:00">
<title>Orgasm Addict</title>
<artist>Buzzcocks</artist>
<genre>Punk</genre>
</song>
<song tracknumber="2">
<title>What Do I Get?</title>
<artist>Buzzcocks</artist>
</song>
<song tracknumber="3">
<title>I Dont Mind</title>
<artist>Buzzcocks</artist>
</song>
<song tracknumber="4">
<title>Love You More</title>
<artist>Buzzcocks</artist>
</song>
</tracks>
*/
Additionally, you can use the following methods of a XML object.
- appendChild()
- prependChild()
- insertChildAfter()
- insertChildBefore()
hmmm…Thats easy!
Found this video on YouTube under the title – “The Art of Starting a Royal Enfield (1)”. Being a hardcore Enfield rider myself, I was expecting a kick start with a lot of back kicks thrown in for that extra punch. What I found in the end was really funny. Check it out.
By the way, only Enfield riders would understand this. Others can just ponder over our amusement!
LHC – Ohh Yeah!
I know I’m delayed by a couple of days, but still considering the enormous nature of the project and the scientific significance I would like to say – “Collide those damn particles and lets see what we get!”
Video: Integration of Flex with Flash CS3
Found a video by Glenn Ruehle demonstrating integration of Flex with Flash CS3.
Creating a custom chrome for AIR application
Written for: Flex Builder 3 and AIR 1.1
To create a custom chrome, you will have to first remove the System chrome (default, drawn by the Operating System) and then the Flex chrome (which is rendered by Flex when System chrome is toggled off).
To remove the system chrome, browse through the application’s descriptor file (ApplicationName-app.xml) for <systemChrome> tag. Add the value of “none” so that it reads like this:
<systemChrome>none</systemChrome>
If you run the application now, you will see a chrome which is rendered by Flex itself.
To remove the Flex chrome, goto your application’s root tag. This could be <mx:Window> or <mx:WindowedApplication> and then set the showFlexChrome property to false.
The next step is to add your own controls for minimizing, maximizing, restoring, closing and dragging the window. This is can be done by using the framework’s NativeWindow class. The NativeWindow class is used for creating and controlling desktop windows for AIR apps. It contains methods for all the functionality we need for our custom chrome.
NativeWindow class’s startMove method. By doing this, the user can now move the application on the screen by dragging the red colored canvas.
<mx:Script>
<![CDATA[
private function moveWindow(event:MouseEvent):void {
this.stage.nativeWindow.startMove();
}
]]>
</mx:Script>
<mx:Canvas width="200" height="100"
backgroundColor="#EB4545"
mouseDown="moveWindow(event)"/>
The window can be minimized, maximized, restored and closed by calling the NativeWindow’s respective function for each task.
<mx:Script>
<![CDATA[
private function minimizeWindow():void {
this.stage.nativeWindow.minimize();
}
private function maximizeWindow():void {
this.stage.nativeWindow.maximize();
}
private function restoreWindow():void {
this.stage.nativeWindow.restore();
}
private function closeWindow():void {
this.stage.nativeWindow.close();
}
]]>
</mx:Script>
<mx:Button label="Minimize"
click="minimizeWindow()"/>
<mx:Button label="Maximize"
click="maximizeWindow()"/>
<mx:Button label="Restore"
click="restoreWindow()"/>
<mx:Button label="Close"
click="closeWindow()"/>
The final code will look like this:
In application descriptor file.
<systemChrome>none</systemChrome>
In MXML.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
showFlexChrome="false">
<mx:Script>
<![CDATA[
private function moveWindow(event:MouseEvent):void {
this.stage.nativeWindow.startMove();
}
private function minimizeWindow():void {
this.stage.nativeWindow.minimize();
}
private function maximizeWindow():void {
this.stage.nativeWindow.maximize();
}
private function restoreWindow():void {
this.stage.nativeWindow.restore();
}
private function closeWindow():void {
this.stage.nativeWindow.close();
}
]]>
</mx:Script>
<mx:Canvas width="200" height="100"
backgroundColor="#EB4545"
mouseDown="moveWindow(event)"/>
<mx:Button label="Minimize"
click="minimizeWindow()"/>
<mx:Button label="Maximize"
click="maximizeWindow()"/>
<mx:Button label="Restore"
click="restoreWindow()"/>
<mx:Button label="Close"
click="closeWindow()"/>
</mx:WindowedApplication>
System Notifications for AIR application
Finally, found a way to display system notifications for AIR applications! I’m using as3notificationlib for doing it. From the library’s Google Code page:
This project makes it easy to add cross-platform notifications to your AIR application. It handles “native system notifications” like the dock icon bouncing and the taskbar icon flashing, and it allows you to easily create alert “pop-ups”.
In addition to displaying text in the alert “pop-ups”, one can also add an icon, a video and a sound alert (to indicate display of the “pop-up”).




