Bài đăng

Hiển thị các bài đăng có nhãn CodeFlash

Dispatching Custom Events in AS3 with data or object

detail here to send custom information or data to the listener object when a custom Event is going to be dispatched. So here is what i have done to achieve the same The flash new Event mechanism provides you a facility to create a new event and the default constructor call is something like this Event(type:String, bubbles:Boolean = false, cancelable:Boolean = false) so there is no by default parameter to send information across the dispatcher and listener objects ( Other than using event.target.*** method on listener end). Following is the code i have done for overcome this Create a CustomEvent.as Class as following package eventsSystem { import flash.events.Event; public class CustomEvent extends Event { public static const ONLOADED:String = “OnLoaded”; //———– Define your custom Event string constant public var data:*; //————- Define a data variable of * type to hold any kind of data object //———— Constructor public function CustomEvent(type:String, data:*) { this.data= dat...

The Model-View-Controller Design Pattern in Actionscript 3

Hình ảnh
The-Model-View-Controller http://en.wikipedia.org/wiki/Model_view_controller The MVC Design Pattern Creates a separation of Class roles Adds a clear and logical communication structure Increases flexibility in larger applications Model Handles data storage and retrieval (eg. Store character x position) View Handles the display/communication (eg. Position character on stage) Controller Handles most the of the application logic (eg. Get current x position) MVC – basic structure Each model can have multiple views Each view has at least one matching controller Creates a separation between form, content and action The model becomes the base of the application Communication Model MVC planning example - Pacman Game Here is a simple application to show MVC in action Application abstract: A circle which changes colour randomly every time a button is pressed Designing the simple application Broken down into the MVC pattern this would look like: Download a basic Actionscri...

Link học flash

Tính băng thông: ở đây nè http://infolab.stanford.edu/stream/code/ http://infolab.stanford.edu/stream/code/#download http://en.pudn.com/downloads163/ebook/detail740529_en.html http://www.communitymx.com/content/article.cfm?page=5&cid=4E1D8

simple flash example

http://www.kennybellew.com/tutorial/ http://www.justskins.com/forums/live-stream-24730.html http://www.vnfx.com/vb/forumdisplay.php?s=69e88d4fefb4d4dd0fba5a0053be3ca3&f=28 for example: var client_nc:NetConnection; var out_ns:NetStream; var in_ns:NetStream; emisor_cam = Camera.get(); emisor_video.attachVideo(_root.emisor_cam); function doConnect() { client_nc = new NetConnection(); client_nc.onStatus = function(info) { trace("Level: " + info.level + " Code: " + info.code); } client_nc.connect("rtmp://loca lhost/videochat/" + _level0.sid); } function publishMe() { out_ns = new NetStream(_root.client_nc); out_ns.attachVideo(_root.emiso r_video); out_ns.publish(_level0.eid); } function playMe() { in_ns = new NetStream(_root.client_nc); receptor_video.attachVideo(in_ ns); in_ns.play(_level0.rid); } // Connect to the server doConnect(); // Publish the live stream publishMe(); // Play back the stream from the server playMe();
Start and stop the server in Linux Start, stop, or restart Flash Media Server 1. Log in as a root user. 2. Change to the directory where the server is installed. 3. Open a shell window and type one of the following: •./fmsmgr server start •./fmsmgr server stop •./fmsmgr server restart Start, stop, or restart the Administration Server 1. Log in as a root user. 2. Change to the directory where the server is installed. 3. Open a shell window and type one of the following: •./fmsmgr adminserver start •./fmsmgr adminserver stop •./fmsmgr adminserver restart Start, stop, or restart Flash Media Server using the command line 1. * cd / . 2. Enter ./server [start | stop | restart]. Start, stop, or restart the Administration Server using the command line 1. * cd / . 2. Enter ./adminserver [start | stop | restart]. So I SSH’ed into the server … and I run the Linux commands. The fmsmgr adminserver restart command worked. I therefore ...

Shared object & Other information

Shared object Shared object that you are probably English ha ~ SharedObject, there are two types of flash en sharedObject, local sharedobject (LSO) and remote sharedobject (RSO), which is the local share and remote sharing, remotediscussion, But before you go to learn the best understanding of local, good for you ... RSO initialization with the server need to establish a connection, continued the previous section, we first establish a connection with the server // Initialize to use a remote shared-channel nc var myNC = new NetConnection(); myNC.onStatus = function(info) { if (info.code == "NetConnection.Connect.Success") { // Success using this nc initialization rso initRSO(this); } }; Like with the previous code, just connect a number of successful initRSO () function, can not read the back to re-take a look at the first... function initRSO (NC){ /* On the server to establish myRSO.fso paper, the first two parameters specify nc channel, the first three...

Sample FMS: Online list for FMS

Hình ảnh
application.onAppStart=function(){ trace("------onAppStart----"); /* Khởi tạo danh sách người dùng online. */ application.onlineList=[]; } application.onConnect=function(newClient,IDNUM,IDPASS){ trace("------user onconnected------"); newClient.IDNUM=IDNUM; /* Thêm người dùng này vào danh sách người online */ application.onlineList.push(IDNUM); application.acceptConnection(newClient); for(var i=0;i /* Gửi danh sách người online bằng cách gọi hàm onlineList và truyền danh sách đến từng người. */ application.clients[i].call("onlineList",null,application.onlineList); } } application.onDisconnect = function (newClient){ trace("------user disconnected------"); for(var i=0;i /* Gửi danh sách người online bằng cách gọi hàm onlineList và truyền danh sách đến từng người. */ application.clients[i].call("onlineList",null,application.onlineList); } };

server side Authoricator

server side Authoricator: file: main.asc load("N2Authoricator.asc") application.onAppStart = function() { this.authoricator = new N2Authoricator("allowedHTMLdomains.txt","allowedSWFdomains.txt"); } application.onConnect = function(p_client) { this.authoricator.checkClient(p_client) ? this.acceptConnection(p_client) : this.rejectConnection(p_client) } N2Authoricator.asc /* ------------------------------------------ allowedHTMLdomains.txt and allowedSWFdomains.txt ------------------------------------------ # This configuration file can be used to specify the domains which are # allowed to host an HTML file which can possibly embed a client .swf file # for Live (out of the box) application. By default, this authentication is # disabled # # - There can be at most one domain entry per line e.g. to add domains # http://myhost1.com and https://www.abc.myhost2.com the corresponding entries should be: # # myhost1.com # www.abc.myhost2.com # # NOTE: The...

Following is the netstatus handler for one net stream

Following is the netstatus handler for one net stream private function nsStatus(e:NetStatusEvent):void { trace("ns status : ", e.info.code); switch (e.info.code) { case "NetStream.Play.Start" : ns.pause(); trace("ns started playing"); break; case "NetStream.Buffer.Full" : nsBuffered = true; if (ns2Buffered == true) { ns.resume(); ns2.resume(); } else { ns.pause(); } trace("NS Buffer Full"); //ns.bufferTime=expandedBufferLength; break; case "NetStream.Buffer.Empty": nsBuffered = false; ns.pause(); //ns.bufferTime=startBufferLength; break; case "NetStream.Buffer.Flush": break; } } similarly, i am doing for other stream. Also, i am running one timer to update the seek bar. in the timer event handler, i have used one condition to check both nsBuffered and ns2Buffered flag to resume t...

SharedObject.mark()

http://fmsguru.com/forum/messages.cfm?threadid=B9D09A82-C160-6409-743D4D599CF927B6 I am trying to restart a pending project and it is a bit hard ;) So I want to implement the SharedObject.mark() functionnality to synchronize several properties in a single call, but I am missing something on the client side: Here is the example of the fms doc: Example The following example calls the mark() method twice to group two sets of shared object property updates for clients: var myShared = SharedObject.get("foo", true); myShared.lock(); myShared.setProperty("name", "Stephen"); myShared.setProperty("address", "Xyz lane"); myShared.setProperty("city", "SF"); myShared.mark("onAdrChange", "name"); myShared.setProperty("account", 12345); myShared.mark("onActChange"); myShared.unlock(); The following example shows the receiving client-side script: connection = new NetConnection(); connection.c...

source code of based on the live app for FME

http://www.flashcomguru.co.uk/forum/forum_posts.asp?TID=4008&PN=965&get=last application.onAppStart = function() { // Logging trace("Starting Live Service..."); // Turning on the Authentication by default this.HTMLDomainsAuth = true; this.SWFDomainsAuth = true; // Populating the list of domains which are allowed to host HTML file // which in turn may embed a SWF that connects to this application this.allowedHTMLDomains = this.readValidDomains("allowedHTMLdomains.txt","HTMLDomains" ); // Populating the list of domains which are allowed to host a SWF file // which may connect to this application this.allowedSWFDomains = this.readValidDomains("allowedSWFdomains.txt","SWFDomains"); // Logging if(this.HTMLDomainsAuth){ trace("Authentication of HTML page URL domains is enabled"); } if(this.SWFDomainsAuth){ t...

FME + FMS + record

Hello. I am creating program based on this site's Article. http://www.fmsguru.com/showarticle.cfm?articleID=34 In similar way I create, but a warning dialog appears when starting record. warning say that "publishing aborted.publishing to server aborted. continuing encoding to file." Probably Because of two streams from client's same video source, Error happen. I call record() method like following. -------------------------------------------- application.onConnect = function(){ client.onRecordStart = function( streamname ){ stream = Stream.get("XXX"); stream.play("sample", -1, -1 ); stream.record(); } } -------------------------------------------- In the Article, record() method is called like this. application.recordStream.record(); How do I call recor...

server side Authoricator

http://nshen.net/blog/article.asp?id=595 USE: load("N2Authoricator.asc") application.onAppStart = function() { this.authoricator = new N2Authoricator("allowedHTMLdomains.txt","allowedSWFdomains.txt"); } application.onConnect = function(p_client) { this.authoricator.checkClient(p_client) ? this.acceptConnection(p_client) : this.rejectConnection(p_client) } N2Authoricator.asc /* ------------------------------------------------------------------------------------------------------------------- allowedHTMLdomains.txt and allowedSWFdomains.txt ------------------------------------------------------------------------------------------------------------------- # This configuration file can be used to specify the domains which are # allowed to host an HTML file which can possibly embed a client .swf file # fo...

To disconnect the client I go through the clients array backwards

I'm only using netservices.asc. load("netservices.asc"); To disconnect the client I go through the clients array backwards, find the client to disconnect, and disconnect it. (logInfo is a custom function I added to client objects. It gets called but some clients stay alive) for ( var i=application.clients.length-1; i>=0; i--){ var difference = nowTimestamp - application.clients[i].lastHeartbeat; if( difference >= 10*1000 ) { if( application.clients[i] ){ application.clients[i].logInfo("Timeout: ("+difference/1000+") s" ); application.disconnect(applica tion.clients[i]); } } } I'd be just too happy if you can find an error in this way of disconnecting clients. When I test stuff, I also can't reproduce the problem. My software is in production, and there it happens. There seem to be two different kinds of dead client connections. One of them can be disconnected and the...

I record a stream from Flash Media Encoder

How can I record a stream from Flash Media Encoder on Flash Media Server 2? I actually get a lot of questions concerning FME but since I don't use it much myself (it crashes on my main computer and won't start) I usually don't have much of an answer. This also tells me two things about this piece of software that Adobe has pushed out, that is that it's getting attention because it encodes video with on2's vp6 codec and people like that because the quality is better. The second is that if I'm getting so many questions, there must be a lack of docs out there. Oh well, gives me something to write I guess. Anyways, the deal here is that a lot of people want to record on FMS2 instead of just saving the FLV locally and then uploading some huge honking file to their server. The way to do that is actually relatively simple. Surprisingly enough. In this case we need to have the server side of the application watch for when a certain stream is published. The only dr...

Về Flash media server

cài đặt Flash media server cài đặt Flash media encoder mở các công trên máy cài flash media server nếu trước đó nó khó các cổng này. cài đặt virtual web cam (manycam new version) cho thực hành nếu không có webcam thật bắt đầu thực hành: download sách và demo: http://www.box.net/shared/kkkge43yhd http://www.box.net/shared/4oia79c7j0 http://www.box.net/shared/yvgm5e84od

Open window, Resize it after 1 second, then Close it after 6 seconds

on (release) { getURL ("javascript:NewWindow=window.open('ShowPopup.php','newWin','width=400,height=300,left=0,top=0, toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); setTimeout('NewWindow.resizeTo(500,500)',1000); setTimeout('NewWindow.close()',6000); void(0);"); } http://www.flash-db.com/PopUp/JavaScriptPopUp.php?page=1 http://www.flash-db.com/PopUp/JavaScriptPopUp.php?page=2 http://www.flash-db.com/PopUp/JavaScriptPopUp.php?page=3 http://www.flash-db.com/PopUp/JavaScriptPopUp.php?page=4 http://www.flash-db.com/PopUp/JavaScriptPopUp.php?page=5

using popup in flash

on (release) { getURL ("javascript:NewWindow=window.open('ShowPopup.php','newWin','width=400,height=300,left=0,top=0, toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);"); } The first part (Green) tells the browser that we will be sending it some JavaScript code. Then we define a new window object called 'NewWindow' This name is important because it will allow us to reference the popup window at later times. This does not have to have the name 'NewWindow' it can be anything as long as you keep it consistent. Then we use the window.open JavaScript command to open up a new window. This function contains a couple of options. The first is the target URL to the Page that you want to open inside the pop-up window. In this case that's 'ShowPopup.php'. The next option is to give the window a Name, the name of the window in this example will be 'newWin'. Then we hav...

Play next movie after FLV movie is complete

if stream is your NetStream class, at some point you need to hook up an onStatus event handler. Code: ****************************************************************** stream.notify = this; stream.onStatus = function( s ) { notify.onStatus( s ); }; ****************************************************************** this being our video "component", the class that contained the NetStream object. Then our onStatus handler was: Code: ****************************************************************** function onStatus( status ) { switch( status.code ) { case "NetStream.Buffer.Empty": onEmpty(); break; case "NetStream.Buffer.Full": onFull(); break; case "NetStream.Buffer.Flush": onFlush(); break; case "NetStream.Play.Start": onStart(); break; case "NetStream.Play.Stop": onStop(); break; case ...

Three things in order to run video flv:

1. Create blank new flash file. Open library, add "New video" object to library, then add it to stage with the instance name "my_video". 2. Create new layer with a multy-line input text field w/ a border that lies above the "blank video object". The instance name of the txt object must be: "status_txt" 3. Add script written below to the first frame of the flash movie. Save flash movie with the name you want + put following FLV file (videoFile.flv) in the same directory where you're going to execute SWF for streaming. ****************************Code************************************ status_txt.text += "initialize streaming engine" + newline; // Create a NetConnection object var netConn:NetConnection = new NetConnection(); status_txt.text += "creating net connection object..." + newline; // Create a local streaming connection netConn.connect(null); var netStreamStatus = ""; var videoStatus = "loading";...