Collation
You are welcome to love the Six-Degree topology. The six-degree topology should be the first mature work in my Internet experiment.
I am very satisfied with the process from conception to creation to the final product.
Of course, I would like to thank Douban.com for releasing this API by ID to search for friends. Without this API, no such work will be available.
Such a large website uses its own server and bandwidth to open its APIs for use. This dedication is commendable, I think it is very appropriate to release my source code, and it will certainly have many advantages.
I have read the autobiography of Linus Torvalds in college, and I am afraid to talk about how high my programming level is, but like Linus Torvalds, I am enthusiastic about programming activities. For me, the greatest pleasure of programming lies in creation. This is consistent with the singer's song writing, the writer's article writing, and whether the final work can be recognized by everyone, it will be my greatest consolation.
I like Li zongsheng's words: "A piano is basically a waste before it is handed in to a musician. It must be in the hands of a music maker, it has life." ----- Share with all friends who like to create.
-------------------------------------------------------------------
Well, let's talk about the Code:
1. the first thing we should talk about is the program compiling environment. The program is compiled with flash cs3, although there is a file that looks like it is related to flex, but that is just the "by-product" I used flex as the editor. I used flash as the compiler and interface design tool, while flex as the code editor.
Flash cs3
As for the development language used by flash-ActionScript 3, if you have learned OOP languages like JAVA and C ++, you can easily understand the syntax.
2. Program Core
2.1
The most important part of the program is the "track", parameter UIEntity. Orbit class
Track chart
It can be seen that a node is attracted to the track.
The attraction of the track is divided into stages. The first stage is RANDOM_ATTRACT, and the second stage is ARRANGE.
RANDOM_ATTRACT: the number of friends of a friend who has two or more degrees cannot be obtained before searching for all friends who have completed a certain degree. Therefore, in order to ensure that the Avatar can be evenly arranged as much as possible, it depends on the number of friends that have been searched. This stage is called RANDOM_ATTRACT.
ARRANGE: At this stage, it is clear that when all friends of a friend are completed, they can ARRANGE their friends as evenly as possible.
The implementation of the orbit uses DFA (Finite Automation). In fact, the implementation here is very simple. It is to add swith (status) to a function that can be repeatedly executed, such as foo) such a statement, got it?
DFA is something that I like very much in interactive applications. I like it very much. It is really simple and effective.
If I say this is the core of the program, some people will throw the tomato. But in fact, this is the core of the program. Of course, some details of implementing this core are worth discussing.
2.2Orbit attracting
Orbit is only responsible for attracting the action, but who is responsible for pushing the node into an orbit? This requires another automatic machine. For more information, see
EnterFrameFun (evt: Event): void function implementation
The basic idea is to load the first user of the current center point into a queue,
Then, a user F-> is retrieved from the queue (AS3STL. EQueue) Q header every 50 ms (for performance consideration ).
Check whether all of user F's friends have obtained them (because Douban's XML can only request 50 at a time, when the number of friends exceeds 50, multiple requests are required ).
YES: retrieve user F from queue Q to view all of its friend nodes.
IF friend node I is not used
Tail of Q added to the queue
ELSE directly discards this node. To avoid repeated nodes,
For example, a-B is a friend, B-c is a friend, and c-a is a friend.
NO Not All retrieved: waiting
This is a simple but effective algorithm, isn't it?
Because here, as long as the capture is not stopped, the user's friends, friends of friends... is always obtained (ClawMainFun (event: TimerEvent): void in the DouBanFriendTopology class of the capture process), that is, the queue is infinitely extended (unless all the friends of N degrees are caught or everyone has no friends at a certain degree). For such a dynamic data situation, it was a hassle, but here I am very satisfied with this situation when I use "check whether all friends of user F have been obtained.
3OK. The key part is introduced here first. Let's talk about the program organization:
Douban_Fri_Topology.fla is the main file of the program. Edit it to view the 6-degree topology.
The main class of the DouBanFriendTopology. as program.
The file where the prototype diagram of OriginalGraph. fla program is located for preliminary design.
About.swf
Click the flash file that is played after "About" and use the background sound of my favorite us draft final <apprenticeship>.
Happy. (The first frame is set to paused and must be controlled by the program)
------------------------------------------------------------------
Package
AS3STL
The self-written AS3 STL package currently has only one queue (there was previously a comprehensive AS2STL with stacks, trees, and graphs, which was rewritten for a while ).
ComuEntity
Communication entity class, used to request XML and return corresponding results,
Fetch_Friend.as is used to obtain friend data.
Fetch_People.as is used to obtain personal information (ID) in the search, mainly used in such as http://www.6dtop.com/search.asp? Id = ahbei.
EventCenter
CEventCenter,
This is an effective mechanism for self-writing messages. When you send a message to obj100 from a "Deep down", for example, obj1.obj2. obj3.xxx
-The dispatch mechanism effectively solves this problem. This function-based message can be used no matter whether the language carries a custom message mechanism such as dispatch.
CGData
Used to store some global data. UserList is a globally heterogeneous (that is, there will be no duplicates) User List.
Model
Used to define some data-related models, such as the UserModel.
UIEffect
Result package: dragcomptvm is a very common management class for self-writing and mouse dragging. It brings great convenience and flexibility.
UIEntity
UI
Entity package, among which Orbit and UserNode are the most important, while the ToolBar includes ScaleToolBar (left deformation tool ),
Upline (upper tool), ButtomLine (Lower tool), some components made in flash are used here. In FLEX, an error is reported because they cannot be identified (because they are not compiled ).
Into. swc), ignore it, because flash is used for compilation here.
Utils
Helper class package, ArrayUtil, array auxiliary method.
WebService
The WebService package and SWebService include the request address.
------------------------------------------------------------------
The about_swf folder contains the source file of about flash.
Because the first frame of about.swfis set to bytes, you can use loader.swf.
------------------------------------------------------------------
After talking about it for a long time, I finally got some benefits. 6 DTOP source code 1.0 has been shared with you.
Http://www.6dtop.com/open/v1.0/6dtop.source.1.0.rar
Remember to stick to it ;)