How to make VideoDisplay component work with Macromedia Flash Communication/Media Server?

If you already know about VideoDisplay component, please skip next two paragraphs to see the solution.
VideoDisplay component in Macromedia Flex 2.0 would be replacement of MediaDisplay component in previous versions of Flex. Unlike MediaDisplay component, it doesn’t have any UI controls, it’s a face-less component. It provides you API to control the video playback. So you can build user-interface, controls around it and skin it according to your choice. This was quite difficult with MediaDisplay.
Macromedia Flex 2.0 is still in alpha-phase and if you strongly feel the need of controls, please give us your feedback. We can probably ship it with some default controls.
Anyways, let’s talk about the issue which some people faced while using VideoDisplay with RTMP URLs.
Problem: VideoDisplay component doesn’t play video from a RTMP URL?
For example, following code would compile but won’t work as expected i.e. it won’t play video when application is run.

Solution: VideoDisplay is based on Peldi’s FLVPlayer. Like FLVPlayer, it requires a server-side ActionScript file(main.asc) to be placed inside corresponding FlashCom application directory on server.
If you are missing main.asc on server-side, VideoDisplay won’t be able to play videos from a RTMP URL.
You need to place main.asc inside “scripts” folder under your FlashCom application directory. I am taking above code as reference to explain where you can place main.asc. You can see the directory structure of a FlashCom application in following image:
directory structure of videodisplay flashcomm application.
Description about directories shown above:

  • videodisplay - this is your application directory on flash-media-server
  • scripts - this is the directory where you need to place main.asc and if required, other server-side AS files.
  • streams - this is the directory which contains application-instances directories. For example, definst which is default instance directory.
  • definst - this directory corresponds to default instance of videodisplay application. In this case, intro.flv is placed inside this directory.

I have uploaded the main.asc on my server so that you can download it from here itself. You can also get the same file from Peldi’s blog, but you need to download the entire FLVPlayer.zip to get main.asc.
Download main.asc

My blog is back

My blog was down for couple of days because I was moving it to new server. Then it took sometime to configure it. I was using Berkeley file-based database in previous installation; I realized that it didn’t work on this new server because the directory path was different.
Thanks God, I had exported all entries as html page before moving to new server. That’s how I am able to import all old entries with all approved-comments. Entry orders have changed which means all people who were linking to my blog-posts would find that links are broken. I am sorry about that :(
I also noticed that my all old posts re-appearing on MXNA, so I want to apologies for that. I have no idea how it happened. I have not pinged to MXNA, may be MXNA found these entries new and pulled.
I am planning to put new template on my blog with links of all other blogs(I follow).

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:\

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; }


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:
\


If rollover highlight of Menubar fits vertically, it would look much better. You can see below:
\


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.