Me (Stanislav Stankov) growing up

Real Time Messaging Protocol presentation (BG)

Hey I write presentation presenting RTMP protocol, Bulgarian language.
presentation it is : Real Time Messaging Protocol
RTMP description : RTMP.pdf
filles with all images & doc files : docs.zip

whats in zip?

in-zip-file

in-zip-file

Preventing SWFs From Running Locally

IT is great to read this article. Lately the swf that I start localy do not check where they are started and I get a thrown errors… you can just make it little more professional by reading it.
Preventing SWFs From Running Locally

svn cleanup

svn cleanup — Recursively clean up the working copy.

So what does this means?

It means that all “.svn” folders in you rfolder and sub folders are removed.

When do I use it?

Hmm.. basically when you want in your working local folder to not have any “.svn”. That are bugging you and taking only more time to get all folder files.

Solution #1 : Registry file

CleanSVN.reg – register add you to your right click menus in folder “Delete SVN Folders”. Tested and works 100% on XP, Vista and 7.

Screen-shots:

delete svn folders

delete svn folders

Solution #2 : C# app

C# software app that do the job.

Screen-shots:

directory remover - start

directory remover - finish

directory remover - finish

realated topics:
How to clean .svn folders from your project
How To Recursively Delete .svn Folders
Delete All .svn Files in windows

SharedObject between 2 movies

So lets create 2 files:

setCookies.fla

setCookies.fla flash env with component names

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var date:Date = new Date();
val_ti.text = ">> " +date.time;

setCookie_btn.addEventListener(MouseEvent.CLICK, clickHandler);
show_btn.addEventListener(MouseEvent.CLICK, showHandler);


function clickHandler(info:MouseEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    local_data.data.key = val_ti.text;
    status_txt.text = local_data.flush();
}

function showHandler(info:MouseEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    read_ti.text = local_data.data.key;
}

getCookies.fla

getCookies.fla flash evn with component names

getCookies.fla flash evn with component names

1
2
3
4
5
6
7
8
9
10
11
var timer:Timer = new Timer(500, 0);
timer.addEventListener(TimerEvent.TIMER, checkForCookieHandker);
timer.start();


info_ta.text = "check for cookies every 0.5 sec ... ";
function checkForCookieHandker(info:TimerEvent):void {
    var local_data:SharedObject = SharedObject.getLocal("VSh", "/");
    local_data.flush();
    info_ta.text = "[" + timer.currentCount + "] key: " + local_data.data.key + ", size: " + local_data.size + "\n" + info_ta.text;
}

Demo

Set cookie

This movie requires Flash Player 10

Get cookie

This movie requires Flash Player 10

see also:
where is .sol files in windows 7

source files in flash-cookie.zip

Firebug for IE, Opera, Safari

What if you need trace in browser environment?
Need Firebug for IE, Opera, Safari?

check it here: getfirebug

where is .sol files in windows 7

Hi if you are searching where .sol files are set in Windows 7, check here:

C:\Users\USER\AppData\Roaming\Macromedia\Flash Player\#SharedObjects

Camera.getCamera problem => solution

When you try to add a camera by name like this:

1
2
var cameraName:String = "WebCam";
var cam:Camera = Camera.getCamera(cameraName);

or like this

1
var cam:Camera = Camera.getCamera(cameranames[0]);

both return cam = null

Solution:

You need to add camera index like String in order to work

1
2
3
4
5
6
7
8
9
10
11
var cameraName:String = "WebCam";
var camera:Camera;
const imax:int = Camera.names.length;
var i:int = 0;
while (i < imax) {
    if (Camera.names[i] == cameraName) {
        camera = Camera.getCamera(String(i));
        break;
    }
    i++;
}

or use this function

1
2
3
4
5
6
7
8
9
10
11
12
13
const camera:Camera = getCamera("webCam");
       
private static function getCamera($cameraName_:String):Camera {
    const imax:int = Camera.names.length;
    var i:int = 0;
    while (i < imax) {
        if (Camera.names[i] == $camName_) {
            return Camera.getCamera(String(i));
        }
        i++;
    }
    return null;
}

so now you will have your camera that you wanted:

thank to:
pooja

ScanScout AS3 Overlay Manager

Hi I will post some code that will make you easier to implement Scan Scout AS3 Overlay.

We have class that hold the needed values:

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
package com.stanislavstankov.ss.dto {
   
    public final class ScanScoutAS3OverlayDTO {
       
        private var _partnerId:String;
        private var _pageURL:String;
        private var _mediaId:String;
        private var _mediaURL:String;
        private var _mediaTitle:String;
        private var _mediaDescription:String;
        private var _mediaKeywords:String;
        private var _mediaCategories:String;
       
        /*------------------------------------
            Constructor
        ------------------------------------*/

        public function ScanScoutAS3OverlayDTO($partnerId_:String, $pageURL_:String, $mediaId_:String, $mediaURL_:String, $mediaTitle_:String, $mediaDescription_:String, $mediaKeywords_:String, $mediaCategories_:String):void {
            _partnerId = $partnerId_;
            _pageURL = $pageURL_;
            _mediaId = $mediaId_;
            _mediaURL = $mediaURL_;
            _mediaTitle = $mediaTitle_;
            _mediaDescription = $mediaDescription_;
            _mediaKeywords = $mediaKeywords_;
            _mediaCategories = $mediaCategories_;
        }
        /*------------------------------------
            Public methods
        ------------------------------------*/

       
        public function get partnerId():String {
            return _partnerId;
        }
       
        public function get pageURL():String {
            return _pageURL;
        }
       
        public function get mediaId():String {
            return _mediaId;
        }
       
        public function get mediaURL():String {
            return _mediaURL;
        }
       
        public function get mediaTitle():String {
            return _mediaTitle;
        }
       
        public function get mediaDescription():String {
            return _mediaDescription;
        }
       
        public function get mediaKeywords():String {
            return _mediaKeywords;
        }
       
        public function get mediaCategories():String {
            return _mediaCategories;
        }
       
        public function toString():String {
            return "[ ScanScoutAS3OverlayDTO partnerId='" + partnerId + "'\n\t pageURL='" + pageURL + "'\n\t mediaId='" + mediaId + "'\n\t mediaURL='" + mediaURL + "'\n\t mediaTitle='" + mediaTitle + "'\n\t mediaDescription='" + mediaDescription + "'\n\t mediaKeywords='" + mediaKeywords + "'\n\t mediaCategories='" + mediaCategories + "'\n ]";
        }
       
    }
}

and manger that do all the work

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package com.stanislavstankov.ss.mngrs {

    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.TimerEvent;
    import flash.net.URLRequest;
    import flash.system.Security;
    import flash.utils.Timer;
    import com.stanislavstankov.videoPlayer.events.VideoEvent;
    import com.stanislavstankov.ss.dto.ScanScoutAS3OverlayDTO;
    import com.stanislavstankov.videoPlayer.player.Player;
   
    public final class ScanScoutAS3OverlayManager {
       
        private var _ss_ads:*;
        //NOTE: Do not append cache-buster. Use this URL as is
        private var _ssURL:String = "http://media.scanscout.com/ads/ss_ads3.swf";
        private var _ssLoader:Loader;
       
        private var _video:Player;
        private var _parent:Sprite;
        private var _core:ScanScoutAS3OverlayDTO;
       
        /*------------------------------------
            Public methods
        ------------------------------------*/

       
        /**
         * Config the manager
         * @param   object that hold the needed values
         * @param   video player
         * @param   the display object that the ads will be added
         */

        public function config($core_:ScanScoutAS3OverlayDTO, $video_:Player, $parent_:Sprite):void {
            _core = $core_;
            _video = $video_;
            _parent = $parent_;
           
            _video.addEventListener(VideoEvent.STARTED, videoStartedHandler);
            _parent.stage.addEventListener(Event.RESIZE, resizeHandler);
        }
       
       
        /*------------------------------------
            Private methods
        ------------------------------------*/

       
        //NOTE: ScanScout must not be loaded unless ScanScout is to be used on the particular stream
        //Also, do not load ScanScout until the video begins
        //These rules are in place to avoid the transfer of assets across the wire unless they are to be used
        private function initiateScanscout():void {
            Security.allowDomain("*");
            _ssLoader = new Loader();
            _parent.addChild(_ssLoader);
            if (_ssLoader.contentLoaderInfo.bytesLoaded == _ssLoader.contentLoaderInfo.bytesTotal) {
                _ssLoader.contentLoaderInfo.addEventListener(Event.INIT, ss_notifyAdsLoad);
            } else {
                _ssLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, ss_notifyAdsLoad);
            }
           
            _ssLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ss_failedAdsLoad);
            _ssLoader.load( new URLRequest(_ssURL) );
        }
       
       
        private function init():void {
           
        }
       
       
        /*------------------------------------
            Event Functions
        ------------------------------------*/

       
        private function resizeHandler(info:Event):void {
            if (_ss_ads != null) {
                _ss_ads.setSize(_parent.stage.stageWidth, _parent.stage.stageHeight - Controls.HEIGHT);
            }
        }
       
        private function videoStartedHandler(info:VideoEvent):void {
            initiateScanscout();
        }
       
        private function ss_failedAdsLoad(e:IOErrorEvent):void  {
            //handle error
            trace(e.text);
        }
       
        private function ss_notifyAdsLoad(e:Event):void {
            _ss_ads = e.target.content;
           
            var timer:Timer = new Timer(1000);
            timer.addEventListener(TimerEvent.TIMER, ss_videoTimeUpdate);
            timer.start();
           
            // Set event listeners:
            _ss_ads.addEventListener("ss_pause", ss_onPause);
            _ss_ads.addEventListener("ss_resume", ss_onResume);
           
            // Set the input parameters for the Ad Rendering Engine:
            _ss_ads.setParam("ss_partnerId", _core.partnerId);
            _ss_ads.setParam("ss_pageURL", _core.pageURL);
            //unique identifier to the video. Can be the mediaURL if that doesn't change on each request
            _ss_ads.setParam("ss_mediaId", _core.mediaId);
            //http URL to the FLV
            _ss_ads.setParam("ss_mediaURL", _core.mediaURL);
            //required metadata: should not be the same across all videos
            _ss_ads.setParam("ss_mediaTitle", _core.mediaTitle);
            _ss_ads.setParam("ss_mediaDescription", _core.mediaDescription);
            _ss_ads.setParam("ss_mediaKeywords", _core.mediaKeywords);
            _ss_ads.setParam("ss_mediaCategories", _core.mediaCategories);
           
            // Size to fit video screen and place top-left:
            _ss_ads.setSize(_parent.stage.stageWidth, _parent.stage.stageHeight - Controls.HEIGHT);
            //TODO: set to left-side of video
            _ssLoader.x = 0;
            //TODO: set to top of video
            _ssLoader.y = 0;
           
            //Kick off the ad presentation:
            _ss_ads.launch();
        }

        private function ss_videoTimeUpdate(evt:TimerEvent):void {
            //playhead_time should be the video time in seconds
            _ss_ads.videoTimeUpdate(_video.time);
        }
       
        private function ss_onPause( evtObj:Object ):void {
            /* TODO: place a call to your video pause routine here */
            _video.pause();
           
        }
       
        private function ss_onResume( evtObj:Object ):void {
            /* TODO: place a call to your video resume routine here */
            _video.resume();
        }
       
        /*------------------------------------
        **************************************
            ScanScoutAS3OverlayManager Singleton Pattern begins
        **************************************
        ------------------------------------*/

       
        private static var _instance:ScanScoutAS3OverlayManager;
        private static var _allowInstance:Boolean = false;
       
        /*------------------------------------
            Constructor
        ------------------------------------*/

        public function ScanScoutAS3OverlayManager():void {
            if (!_allowInstance) {
                throw new Error("This class is Singleton class. Use getInstance method.");
            } else {
                init();
            }
        }
       
        public static function getInstance():ScanScoutAS3OverlayManager {
            if (_instance == null) {
                _allowInstance = true;
                _instance = new ScanScoutAS3OverlayManager();
                _allowInstance = false;
            }
            return _instance;
        }
        /*------------------------------------
        **************************************
            ScanScoutAS3OverlayManager Singleton Pattern ends
        **************************************
        ------------------------------------*/

       
    }
}

and you call it like:

1
2
var sc:ScanScoutAS3OverlayManager = ScanScoutAS3OverlayManager.getInstance();
sc.config(data, player, this);

Assembler snake

Compiler used: http://www.emu8086.com/

Code:

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name "snake"

; създай snake.com
org     100h;

jmp     start

; ------ константи ------
; клавишни кодове на bios
KEY_LEFT        equ 4bh
KEY_RIGHT   equ 4dh
KEY_UP          equ 48h
KEY_DOWN    equ 50h
KEY_ESC     equ 1bh
KEY_SPC     equ 39h

; константи отнасящи се до змията
SNAKE_BODY_COLOR    equ 0eh
SNAKE_BODY_CHAR equ '*'
SNAKE_BODY_SIZE     equ 7

; координати на змията, посока от главата към опашката
snake dw SNAKE_BODY_SIZE dup(0)

; последен елемент от змията
tail        dw ?

; накъде е насочена змията при начално стартиране
cur_dir db KEY_RIGHT

wait_time   dw 0

; начално съощение към потребителя, първият ред е празен, защото през него минава змията
; $ се обозначава края на съобщението
msg db "======================", 0dh, 0ah
        db "=========Snake=========", 0dh, 0ah
        db "    Правила на играта:", 0dх, 0ah
        db "    Змията се управлява от клавишите за посока", 0dh, 0ah
        db "    ESC спира играта", 0dh, 0ah
        db "======================", 0dh, 0ah
        db "======================$", 0dh, 0ah


; ------ КОД ------

start:
; Изписване на начално съощение с координати (DS:DX)
mov     dx, offset msg
mov     ah, 9
int         21h


; скриване на курсора
mov     ah, 1
mov     ch, 2bh
mov     cl, 0bh
int         10h


game_loop:
        ; Избиране на страница, VIDEO MODE
        mov     al, 00h
        mov     ah, 05h
        int         10h
       
        ; хващане на новата глава на змията
        mov     dx, snake[0]
       
        ; преместване на курсора на позиция (dl, dh);
        ; DH - red
        ; DL - kolona
        mov     ah, 02h
        int         10h
       
        ; Принтиране върху екрана на SNAKE_BODY_CHAR, на позицията на курсора:
        ; AL - char - a, знака който ще отпечатва
        ; BL - cvqt
        ; CX - колко пъти да повтори знака
        mov     al, SNAKE_BODY_CHAR
        mov     ah, 09h
        mov     bl, SNAKE_BODY_COLOR
        mov     cx, 1
        int         10h
       
        ; хващаме опашката
        mov     ax, snake[SNAKE_BODY_SIZE * 2 - 2]
        mov     tail, ax
       
        ; извикване на процедурата move_snake
        call        move_snake
       
        ; премества курсора на позиция (dl, dh) -> позицията на опашката (tail)
        ; DH - red
        ; DL - kolona
        mov     ah, 02h
        mov     dx, tail
        int         10h
       
        ; слага ' ' на позицията на курсора (сриваме старата опашка)
        ; DH - red
        ; DL - kolona
        mov     al, ' '
        mov     ah, 09h
        mov     cx, 1
        int         10h
   
    check_for_key:
        ; проверява дали има клавишен код в буфера на клавиетурата
        mov     ah, 01h
        int         16h
       
        jz      no_key
       
        ; приверява дали е натиснат клавиетурен клавиш
        ; AH - BIOS kod
        ; AL - ASCII char
        mov     ah, 00h
        int         16h
       
        ; проверява дали последно хванатия клавиш е бил ESC, ако да, се препраща към stop_game
        cmp     al, KEY_ESC
        je          stop_game
       
        ; хваща се последният натиснат клавиш, като посока
        mov     cur_dir, ah
   
    no_key:
        ; ако няма хванат клавиш изчаква малко време преди да провери отново
       
        mov     ah, 00h
        int         1ah
       
        cmp     dx, wait_time
        jb          check_for_key
       
        add     dx, 4
        mov     wait_time, dx

; вечен интервал
jmp     game_loop

stop_game:
    ; показва курсора черен
    mov     ah, 1
    mov     ch, 0bh
    mov     cl, 0bh
    int         10h
   
ret

; --------------------
; Процедури
; --------------------

; move_snake, създава анимация, като премества
; всяка част от тялото на змията една позиция напред,
; като изтрива опашката после <- това става в главната програма.
; Идеята е последната част се изтрива, а другите части се преместват:
; част0[ i ] -> част[ i + 1 ]
move_snake proc near
    mov     ax, 40h
    mov     es, ax
   
    ; DI, взема позицията на опашката
    mov     di, SNAKE_BODY_SIZE * 2 - 2
   
    ; премества всички части на змията
    mov     cx, SNAKE_BODY_SIZE - 1
    move_array:
        mov     ax, snake[di - 2]
        mov     snake[di], ax
        sub     di, 2
       
    ; върти докато di = 0
    loop  move_array
   
    cmp cur_dir, KEY_LEFT
        je      move_left
       
    cmp cur_dir, KEY_RIGHT
        je      move_right
   
    cmp cur_dir, KEY_UP
        je      move_up
   
    cmp cur_dir, KEY_DOWN
        je      move_down
   
    jmp     end_move
   
    move_left:
        mov     al, b.snake[0]
        dec     al
        mov     b.snake[0], al
        cmp     al, -1
            jne     end_move
        mov     al, es:[4ah]
        dec     al
        mov     b.snake[0], al
        jmp     end_move
   
    move_right:
        mov     al, b.snake[0]
        inc     al
        mov     b.snake[0], al
        cmp     al, es:[4ah]
            jb      end_move
        mov     b.snake[0], 0
        jmp     end_move
   
    move_up:
        mov     al, b.snake[1]
        dec     al
        mov     b.snake[1], al
        cmp     al, -1
            jne     end_move
        mov     al, es:[84h]
        mov     b.snake[1], al
        jmp     end_move
   
    move_down:
        mov     al, b.snake[1]
        inc     al
        mov     b.snake[1], al
        cmp     al, es:[84h]
            jbe     end_move
        mov     b.snake[1], 0
        jmp     end_move
   
    end_move:
ret

move_snake endp






snake example zip

thanks to : snake.asm
more code examples at : assembler source code

Time Display

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Convert netStream.time (or seconds) into String format HH:MM:SS
 * @param   seconds
 * @return formated string HH:MM:SS
 */

public static function formatTime(time:Number):String {
    if (time < 0 || isNaN(time)) {
        return "00:00";
    }
   
    const hours:Number = Math.floor(time / 3600 % 24);
    const minutes:Number = Math.floor(time / 60 % 60);
    const seconds:Number = Math.floor(time % 60);
   
    const hString:String = hours < 10? "0" + hours: "" + hours;
    const mString:String = minutes < 10? "0" + minutes: "" + minutes;
    const sString:String = seconds < 10? "0" + seconds: "" + seconds;
   
    return hours > 0 ? hString + ":" + mString + ":" + sString : mString + ":" + sString;
}

Example:

1
2
3
4
5
6
7
8
trace(formatTime(103));
//01:43

trace(formatTime(3));
//00:03

trace(formatTime(3653));
//01:00:53