A Port Scanner using ActionScript 3 Socket in Macromedia Flash Player 8.5 alpha

I just wrote a simple port-scanner in AS3(ActionScript 3) using flash.net.Socket class in Macromedia Flash Player 8.5 alpha. I have used Macromedia FlexBuilder 2 alpha to create the user-interface but most of the code is in AS3.
I have used my own logic for port-scanning, I am not aware how it is done in actual port-scanners. Since it is a simple example, which means I have not taken care of performance, error-handling, user-input-validation etc.
I was looking for a port-scanner on internet and then this idea popped up. It works for me. I can check which all ports on my system are open. I can also check for open ports on a remote-host as well.
Here is code:
</p>




<![CDATA[
import flash.net.*;
import flash.events.*;
private var socket:Socket;
private var currentPort:uint;
private var toPort:uint;
private function createSocket():void
{
socket = new Socket();
socket.addEventListener("connect", socket_connect);
socket.addEventListener("ioError", socket_ioError);
}
private function deleteSocket():void
{
socket.removeEventListener("connect",socket_connect);
socket.removeEventListener("ioError", socket_ioError);
socket.close ();
}
private function startScanning():void
{
createSocket();
currentPort = uint(fromPort_ti.text);
toPort = uint(toPort_ti.text);
scanPort(currentPort);
}
private function scanPort(port:uint):void
{
if(port <= toPort)
{
status.text = "Scanning port:" + port + "\n";
socket.connect(host.text, port);
enableControls(false);
}
else
{
enableControls(true);
deleteSocket();
status.text = "Scanning complete..";
}
}
private function socket_connect(event:Event):void
{
openPorts_ta.text += currentPort + "\n";
currentPort++;
socket.close();
scanPort(currentPort);
}
private function socket_ioError(event:IOErrorEvent):void
{
/*
Not sure, when there is ioError I am not able to reuse same socket object.
So deleting current socket object and recreating another socket object...
*/
deleteSocket();
createSocket();
scanPort(++currentPort);
}
private function enableControls(bEnable:Boolean):void
{
host.enabled = bEnable;
toPort_ti.enabled  = bEnable;
fromPort_ti.enabled = bEnable;
scanButton.enabled = bEnable;
}
]]>













</font>
Download file


Update: This post was written when Adobe Flash Player 9 was not released and was known as Flash Player 8.5. I have updated the code for Adobe Flash Player 9.

Moving to new server

I am moving my site/blog to new server so there is going to be down-time of two-three days. I hope, it happens smoothly.
Just wanted to let you know.

I am still here...

I am still alive :). I have been busy with some personal work and other stuff. I am going to be regular soon...

Yahoo! Maps Flex API

As you know, Yahoo! Maps Beta has been launched, which is Macromedia Flash based application.
Yahoo! is also providing Yahoo! Maps Flex API which can be consumed in Macromedia Flex applications.

SCORM implementation

Hemant Sharma has posted a nice tutorial on SCORM implementation. It might be useful for people who are new to e-learning world.
BTW! Hemant is member of Macromedia Flash authoring team. He is good designer, animator, Flash programmer, singer and more. You can see his photo in About Flash dialogue box, if you are able to find Flash-8-Easter-eggs.

Interakt Online - Dreamweaver extensions company

This post is not about Macromedia Flash/Flex. It is about a company whose products have helped me in past. And I want to thank the folks behind it by spreading few words about them, which they deserve.
Interakt Online is a company that has been making some great Macromedia Dreamweaver extensions and some useful tools for long time.
I know about their products since 2001, when I wanted to work with PHP in Macromedia Dreamweaver Ultradev.
JFYI! Macromedia Dreamweaver Ultradev was a product that allowed you to build dynamic-database-driven websites. It had all features of Dreamweaver plus some server models(ASP, JSP, CFM). But it didn't have support for PHP in it's early releases, if I remember correctly.
I was very impressed by their work at that time. I have recently met some folks from this company during MAX 2005. And I amd more impressed this time, to see how they have grown(in product range, in team-size etc) during these years and have more cool products.
I just watched the featured interview of Alexandru Costin on sys-con.tv. Alexandru is talking about the company, how it has grown during last few years and what they are doing in future.
If you are working on a web-application using Macromedia Dreamweaver, you should look at Interakt Online products once, you would probably find something which could save your time.

One more day in San Francisco

I am leaving for India tomorrow night. In last two weeks, I really enjoyed my stay in SF and great time in MAX. I learnt so many things, not only technically but also other general things.
I hope to blog my experience for this entire trip including MAX. I have already drafted the post but I am still finding better words to express things properly. You know, how good I am with English :-)
I will be on vacation during first three weeks of November. I am planning to use this time to get good command over ActionScript 3, Flex framework internals. I would also create some applications in Macromedia Flex 2/AS3/other-technologies, of-course using Macromedia FlexBuilder 2.
As a programmer, I can be more expressive with ActionScript 3 and Macromedia Flash Player 8.5. Thanks to Macromedia Flash Player team for their hardwork, they have done awesome job.

Make MenuBar look better inside ApplicationControlBar

ApplicationControlBar(ACB) adds some default top and bottom margins, so Menubar inside it would like this:

</p>



















</font>
If rollover highlight of Menubar fits vertically, it would look much better. You can see below:

</p>





















</font>
What all you need to do:-

  • Set the marginTop and marginBottom of ACB to zero
  • Set the height of MenuBar to 100%
  • Move all controls excepts MenuBar to another container(HBox) inside ACB
  • Set the margins(top and bottom) of that HBox to five.

Some of the new components in Macromedia Flex 2

Flex 2 public-alpha release is an alpha quality release. Which means there could be many issues in different areas, however, I would love to hear from you for your suggestions, queries and bug-reports on following components. I have been involved more on these components:

  • ApplicationControlBar
  • ButtonBar
  • ToggleButtonBar
  • VideoDisplay

You can contact me directly on aqabiz-at-macromedia.com.
If you have suggestions, queries and bug reports for any other area of this public-alpha, please feel free to contact me or post message in Flexcoders list.
BTW! Give a try to RichTextEditor, it is complete text editor. I know, many of you have been requesting for it for sometime.


Yes, that's what you need to do to have complete text-editor in your application.

Macromedia Labs is online

Folks, Macromedia Labs website is live. You can go ahead and download Flex 2.0 alpha. This whole thing is very-very exciting, I can understand how you folks must be feeling :)
You will find many examples of components, a wiki and lot more to get you started. I would write more about it but later.