Flash Online Development Log

Source: Internet
Author: User
Tags date eval log socket access database
This article is my study FlashThe process of network application, the source code, the description is introduced in succession;
First do a self-introduction, for want to learn a good friend;
Flash MXLearn the theDays, including asgrammar;
Flash CommunicationLearn the TenDays
Flash RemotingRead a little information, did not learn;

C # Learning Grammar ten daysBc, 15 years ago, read 5 days of information, did not study, ah;C and Vc and Bc like 15 years ago, read the data, can't learn vb 15 years ago, read a while, wrote a few very simple procedures, now forget all about it;ASP Learning to apply for a total of 10 years or so, should be said to be quite familiar with; SQL is also OK, the database can not say no, ah;JavaScript is OK, Strong cattle and things do not come, normal things can be written, and some other mapping software will be used, can not say that will do the map;

Computer hardware is very familiar, before doing this line, ah seems to have little to do with this relationship, in fact, because of the operating system and hardware after the performance of the heart, to the development of the user group to use the machine to do an analysis, so since the development of the Flash calculation strength and art intensity, Flash mostly have a very direct relationship, because the machine good people have to play 3D ;

For example, please say:
Flash Games, user-oriented is the general machine, this person's machine will not be very good, so they can play the game screen is general, because the good picture, their machine running, display size, now basically is, Machine General display will not be too good, so on the 1024 should have difficulties, and then, if the Flash Press 1024 do the machine run very hard, so we press 800*600 do.

Introduction

Because has been writing ASP, has not written a desktop application, so writing desktop program has always been my dream. Develop games not to mention, because the reason to learn computer is because of playing games, play a lot of feel boring, want to develop for others to play, and later found that a person is not to do, so give up, so that went into the business of programming (more than 10 years ago, ah, think about it is good, at least the right choice, Let's eat this now. Because a little bit VB knowledge, so learn ASP quickly, have been writing this, wrote for more than 10 years.

Developing entertainment programs is the most difficult for small groups and individual development, because it involves a wide range, so want to learn programming best choose this to get started, learning things must be able to mention your interest will stick to it, the development of entertainment projects is my interest, because also involves many aspects, so write, basically finish this language.

Original by:
Previously said my dream, but has not done, everything needs a cause, the company's external site has aFlash, because the company changes need to change, the original change once, because do not understand, so the need to find someone else, I am the most hated to ask, this time to change, so immediately learnFlashWasFlashIt's not difficult, so it's done.
After the change, I found outFlashThe language andJavaScriptIt's like, online.FlashA lot of games, interest came, the company year-end party, need a lottery program, with other language to write a bit of trouble, because the picture effect problem, withFlashIs the simplest answer, so take this studyFlashGrammar, finish writing this, add to do art theGod, it's done.FlashOut.
And then I hadFlashThe interest is very big, want to do the game, I knowFlashCan andASPCommunication, but the effect is not good, online search information, found:
Flash Communication
Flash Remoting

These two things are doneFlashNetwork applications, good to do online games have hope. I'm hereFlash8Send a post, askFlash Communication、Flash RemotingDo it, but here it seems to be doneFlashThe network application is not many people, did not get the answer, continue to find, finally got the answer:

Flash Communicationis to do video conferencing, chatting and other things,Flash Remotingis to do with the database communication and access, know what to do after the use, you can start.
Flash CommunicationPoor online information, the Internet after the search, but also money to buy an ebookFlash Communication Server MX 1.5Reference Encyclopedia, you can begin to write.

Positioning for round games, such as chess, mahjong these, such as QQGame;TenDay put the frame up, the game hall was finished, but found a big problem:
SharedobjectIt doesn't make any use of it.

SharedobjectDescriptionFlashAn Access database that can access relatively simple data,Flash Communicationis with the localSharedobjectCommunication to complete the network application.SharedobjectGrammar is troublesome, plusFlash CommunicationNot mature itself, there are always some inexplicable wonderful questions, maybe one is myFlash CommunicationThe principle of understanding too little, so encountered a lot of problems.

For their own dreams, adhere to theFlash CommunicationThe communication part of the completion of the landing Hall is normal, and then look forward to the database with the communication, the database I set in SQL,Flash Communicationitself cannot manipulate the database, so there is aFlash RemotingSuch a thing;

God, I have to learn Flash Remoting, this network is very small data, look at the information is similar to Java , but I do not understand Java, Learning Java is too exaggerated it, so the development began to hang on.

In order to realize their dreams, so have the time to see things on the Internet, the original in the Empire BBS have seen from the server side of the Flash communication article, but I will only write ASP, other will not, so have been ignored, and then after consideration, if you want to learn Flash Remoting language is better than learning. NET, because there has been no time to learn, two is lazy do not want to learn, good, then positioning for C #, this is more fire, learning more people, more than 10 years ago has been trying to learn C did not study, now finally can force themselves to learn, because found reasons.

This article is original, in fact I am still learning C #, so while writing this thing while learning.

The following is my communication with Flash communication a piece of code, I personally feel too troublesome, so has been written all unhappy Sharedobject, my as language just learn not long, may be the following code looks ugly, anyway, not Flash communication, so we can look at it, but if you want to do video conferencing and other things, but also need to use Flash communication, so learn things will not be white, later use, ah.

Do you want to point game desktop
Table Desktop
Channel Channel
No_play = 0;
No_one = 0;
The number of the table
var table_no;
Desktop around
var table_place;
function Run_program (str, STR2, STR3) {
var game_so = sharedobject.getremote ("Game_room", Client_nc.uri, True);
Game_so.connect (CLIENT_NC);
Game_so.onsync = function () {
<2>
For (A in game_so.data) {
Trace (A + ":" +game_so.data[a]);
//}
Read Game Desktop
For (I=1 i<=4; i++) {
Dot_program (i);
}
Decide whether to point game desktop
if (No_play = = 1) {
Write_data (str, str2, STR3);
No_play = 0;
}
};
<2>
//=========================================================
function Dot_program (str) {
Judge Game Desktop data
if (eval ("Game_so.data.play_name" +str)!= null) {
Eval ("_ROOT.ROOM_TABLE.TABLE_ROOM.P" +str+ "_U1"). Text = eval ("Game_so.data.play_room" +str+ ". play_name1");
Eval ("_ROOT.ROOM_TABLE.TABLE_ROOM.P" +str+ "_U2"). Text = eval ("Game_so.data.play_room" +str+ ". play_name2");
Trace (eval ("Game_so.data.play_room" +str+ ". play_name1"));
} else {
Eval ("Play_user" +str). Text = "";
//}
}
//=========================================================
function Write_data (str, STR2, STR3) {
Write Empty Exit Game
Table_no = str;
Table_place = str2;
if (eval ("Game_so.data.play_room" +str+ ". Play_name" +str2)!= "") {
if (eval ("Game_so.data.play_room" +str+ ". Play_name" +str2) = = myname) {
For (A in game_so.data) {
if (A = = "Play_room" +str) {
if (str2 = = 1) {
game_so.data[a].play_name1 = "";
} else {
Game_so.data[a].play_name2 = "";
}
Break
}
}
}
Goto_list ();
} else {
Write to start the game
Eval ("Game_so.data.play_room" +str+ ". play_name2");
if ((eval ("Game_so.data.play_room" +str+ ". Play_name1")!= myname) && (eval ("Game_so.data.play_room" +str+.) Play_name2 ")!= myname)) {
For (A in game_so.data) {
if (A = = "Play_room" +str) {
if (str2 = = 1) {
game_so.data[a].play_name1 = MyName;
} else {
Game_so.data[a].play_name2 = MyName;
}
Break
}
}
Play ();
}
}
}
}
Run_program ();
SetInterval (Run_program, 2000);
I saw two articles in the Empire BBS FlashDiscussion on the realization of multiplayer network games and video tutorials: using FLASH2004And VBSet up a chat room, left me a lot of strength, here to thank a sound.

Flash The realization of multiplayer network game discussion, the source code in succession open
http://flashempire.net/showthread.php?t=182045

To see how much the flash can withstand network data transfer,
=======================================
After I landed on the server in Flash,
Send a string of 100 characters 100 times every 3 milliseconds 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 "to Flash,
And then in the flash inside the function that receives the data inside the statistic data,
var g_ntotalrecvbyte = 0;
var g_time = new Date ();
var g_nstarttime = G_time.gettime ();
var g_ncounter = 0;

Mysocket.ondata=function (xmldoc)
{
G_ntotalrecvbyte + = Xmldoc.length;
Each receive more than 1k byte of data, output once information,
if (G_ntotalrecvbyte-g_ncounter > 1024)
{
G_time = new Date ();
var npassedtime = G_time.gettime ()-g_nstarttime;
Trace ("Time Spent:" +npassedtime+ "milliseconds");
G_ncounter = G_ntotalrecvbyte;
Trace ("Total Received:" +g_ntotalrecvbyte+ "bytes");
Trace ("Receive rate:" +g_ntotalrecvbyte*1000/npassedtime+ "bytes/sec");

The result was very surprising to me,
This is a piece of debugging information that is intercepted,
//
Time spent: 6953 milliseconds
Total Received: 343212 bytes
Receive rate: 49361.7143678988 Bytes/sec
Time spent: 7109 milliseconds
Total Received: 344323 bytes
Receive rate: 48434.800956534 Bytes/sec
Time spent: 7109 milliseconds
Total Received: 345434 bytes
Receive rate: 48591.0817273878 Bytes/sec
。。。
。。。
。。。
。。。
Time spent: 8125 milliseconds
Total Received: 400984 bytes
Receive rate: 49351.8769230769 Bytes/sec
Time spent: 8125 milliseconds
Total Received: 402095 bytes
Receive rate: 49488.6153846154 Bytes/sec
Time spent: 8125 milliseconds
Total Received: 403206 bytes
Receive rate: 49625.3538461538 Bytes/sec

I checked the source program a few times and found no logical errors,
If the program is not a problem,
Then we conclude that the XML socket for Flash can receive at least 40K of data per second,
This has not yet calculated the triggering of the Xmlsocket.ondata event, the time it takes to debug the code, and the output of the information.

One order of magnitude faster than I thought.
It's enough.

Video Tutorials: Using FLASH2004 and VB Create a chat room (1――7)

http://www.flashempire.com/school/tutorview.php?id=375

It is helpful to have a look at these two articles first.

First determine the few things to be useful:

Flash communication:xmlsocket

This is relatively simple, the operation is also very convenient, at least the data format is very clear, I operate easily.

Note: There are two things to note, this should be noted when writing on the server, or you will get a water, today wasted my big day, I know, but just did not pay attention to.

1. data format flash the end is sent automatically after the code with a 0-byte data, This is very important, otherwise the dead, this is not visible, whether in the receiving or sending should pay attention to.
The server receives the data from the flash and then the last word is segmentation and then the operation you want is returned to flash when you remember to add a "\0 ", so that you can represent a 0-byte data, Otherwise, flash is not received, and remember, the server once received data on the first cut off this 0-byte data, do not go to the place with you to cut, and a cut one, I was the first, in fact, is a person lazy, Give yourself trouble, flash is no matter you so much, he only 0 bytes of data, but only 0 byte of data in the normal display is no problem, and do not change the space, so with this notice.
An example I want to send the data is:
string aaa= "username";
String bbb= "landed";
String ccc=aaa+bbb+ "a";
Socket.send (CCC); > > > You see, the user name is one more \0 flash

2. server-side received data is a data flow, must convert him to Flash the same format, otherwise the Chinese will be garbled, here also pay attention to a place,flash default is UTF8 code, Server-side received to turn to UTF8 on the line, but in the write Flash is, a lot of local articles can see the hope that we add a sentence system.usecodepage = true; This sentence killed me, this sentence I do not know what to do with, because many people say that if you do not add with asp,PHP Dynamic Exchange data will be garbled, I tried many times there is no such situation, in order to insure, so I added, the result hurt me, Added this sentence to the server code changed, I can not turn to UTF8, then deleted this sentence on the normal, faint death ...

server-side C # need to use:

Using System.Net.Sockets; This is winsocket, and flash communication depends on him.

Using System.Text; Encoding conversion.

Using System.Collections; Hash table.

Using System.Threading; Multithreading.

This is what I currently use, C # I have just learned more than 10 days, the current communication is completed, and so I finished the hall, and then write back, because it is self-study, theory I can not say, anyway write to use, hehe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.