Screen Manager.
When i write window based systems i always use a Screen Manager.
when i can control and manage and display object on my screen.
Every display object need to extends ScreenContent class, then
he can attached to the screen manager.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | package { import flash.display.Sprite; // screen content Abstract public class ScreenContentAbstract extends Sprite { private var _contentContainer:Sprite; public function ScreenContentAbstract():void { } public function hideContent():void { // hide content } public function showContent():void { // show content } public function set content(_s:Sprite):void { _contentContainer = s; } public function get content():Sprite { return _contentContainer; } } } |
Screen Manager class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class ScreenManager extends Event { private var _contentContainer:Sprite; public function ScreenManager(_f:Enforcer) { _contentContainer = new Sprite(); } // Add content to display public function addContent(_content:ScreenContentAbstract):void { _contentContainer.addChild(_content); _content.addEventListener(MouseEvent.MOUSE_DOWN, contentMouseHandler); } // Remove content from display public function removeContent(_content:ScreenContentAbstract):void { if (_contentContainer.contains(_content)) _contentContainer.removeChild(_content); } // Hide all content on display public function hideAllContent():void { for (var i:int = 0; i < _contentContainer.numChildren; i++) { if (_contentContainer.getChildAt(i) is ScreenContentAbstract) { (_contentContainer.getChildAt(i) as ScreenContentAbstract).hideContent(); } } } // Show all content on display public function hideAllContent():void { for (var i:int = 0; i < _contentContainer.numChildren; i++) { if (_contentContainer.getChildAt(i) is ScreenContentAbstract) { (_contentContainer.getChildAt(i) as ScreenContentAbstract).showContent(); } } } // Set focus on object on the display public function setFocus(_content:ScreenContentAbstract):void { _contentContainer.setChildIndex(_content, _contentContainer.numChildren - 1); } // mouse handler for content private function _contentMouseHandler(_e:MouseEvent):void { switch(_e.type) { case MouseEvent.MOUSE_DOWN: setFocus(_e.target as ScreenContentAbstract); break; } } // SINGLETON PATTERN private static var instance:ScreenManager; public static function getInstance():ScreenManager { if (instance == null) instance = new ScreenManager(new Enforcer()); return instance; } } } class Enforcer{public function Enforcer()} |
As you can see, you can add more functionality this is example only.
Thanks,
Garry Lachman

FMS blocked port detection – ActionScript 3
FMS block port detection – ActionScript 3
The fms port (1935) closed on many office firewalls, the problem
is that flash had 30 sec timeout before tunnle it to port 80.
Becouse that i write little script that use socket object to test the
port and tunnle it to http when port 1935 is closed.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
import flash.events.Event;
import flash.net.Socket;
import flash.events.IOErrorEvent
import flash.events.SecurityErrorEvent
/**
* @author Garry Lachman
*
* Usage:
* FMSPortTester.TestPorts(onSuccess)
* function onSuccess(_fmsURL:String):void {
* }
*/
public class FMSPortTester
{
public static const FMS_URL:String = "127.0.0.1";
public static const PREFIX_1935:String = "rtmp://";
public static const PREFIX_80:String = "rtmpt://";
public static const SOCKET_TIMEOUT:Number = 3;
public function FMSPortTester() { trace("static only class"); }
public static function TestPorts(_resultURLCallBack:Function):void {
// Create socket connection to fms to check the ports
var socketTest:Socket = new Socket();
socketTest.connect(FMS_URL, 1935);
socketTest.addEventListener(Event.CONNECT, onSocketConnected);
socketTest.addEventListener(IOErrorEvent.IO_ERROR, onSocketError);
socketTest.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onSocketError);
socketTest.timeout = (SOCKET_TIMEOUT * 1000);
// is connected, fms ports ok
function onSocketConnected(_e:Event):void {
_resultURLCallBack(PREFIX_1935 + "" + FMS_URL);
}
// on error, fms ports closed
function onSocketError(_e:*):void {
_resultURLCallBack(PREFIX_80 + "" + FMS_URL);
}
}
}
}