Object Oriented Design Patterns in Flash

web front end eight thousand seven hundred and five 13 years ago (2011-12-07)

Someone asked me FLASH I can responsibly tell him how to write as, because the internal composition mode of as and flash determines its high degree of liberalization. In theory, using the on event of the button, plus stop(), play(), gotoAndStop(), gotoAndPlay(), you can realize most of the logical relationships in a flash, and the source code is simple and easy to understand. But most people will not do this because this method is so admirable. Programmers with a little common sense will know the difference between facing objects and facing processes. Flash programming is based on script The form of OOP has appeared and is not perfect. For example, there is no multi inheritance, but it has initially reflected the idea of OOP. This article now summarizes the object oriented design pattern in flash, as well as some self created ideas.

The design pattern was first proposed by Christian Alexander, an American architect (also an information engineer, painter, mechanical engineer, etc.). It was soon accepted and promoted by technicians in the software industry, and became one of the supreme principles in software engineering. (Those who are interested can look at his book The Eternal Way of Architecture, and I believe it will benefit a lot.) To put it simply, on the basis of facing objects, including facing objects, we should model, hierarchical, fine-grained, highly reusable, controllable and humanized all parts of the whole to be designed. The supreme principle is based on requirements, that is, no matter what you do, people's needs should be the first consideration. From this perspective, consider whether the whole system is reasonable enough. This knowledge is very interesting. Especially in flash, it can be applied to many interesting examples. Here are some examples of common design patterns. Please correct the mistakes:
--------------------------------------------------------------------------------

1. Abstract Factory
There are a lot of things to eat in the canteen, but I only want to eat one thing. So the concept of the canteen is an abstract factory for me, and each window can be seen as a specific implementation of it. What I need to do is to go to the canteen, find the window, and buy the things I want to eat from the window.

For example: flash front desk and ASP Background interaction, access a dynamic page data base The usual way to retrieve the required data is to parse the dataset into an xml string in the background and send it to SWF. For each business logic module, the data structure, that is, the structure of xml, is different. We need to parse the corresponding xml string for each specific business logic and convert it into an array for display. It is also necessary to convert the text input content in flash into an xml string and submit it to the background

AbstractFactory.as
//Interface of abstract factory
Interface AbstractFactory{
//Concrete implementation of generating xml parsing factory
function createXmlParseFactory();
}

XMLParserGetFactory.as
//Generate a factory that parses the read in xml object
class XMLParserGetFactory implements AbstractFactory. {
var xmlParser;
function XMLParserGetFactory(str:String){
//The specific implementation of the generated parser will be mentioned later
}
function createXmlParser(){
return xmlParser;
}
}
XMLParserPostFactory.as
//The factory that generates the object of parsed output xml
class XMLParserPostFactory implements AbstractFactory. {
var xmlParser;
function XMLParserPostFactory(str:String){
//The concrete implementation of the generated parser
}
function createXmlParser(){
return xmlParser;
}
}

In this way, when we read an xml string, we add an
//Generate the factory that parses the message list of message board
var xmlParser=new XMLParserGetFactory(“xmlParseGuestbookList”)
xmlParser= XMLParserGetFactory. createXmlParser()

Note: Abstract factory pattern is one of the most commonly used design patterns in software engineering. The implementation process is that when an instance of a class is needed, it is created through a factory, rather than directly. Frankly speaking, it increases the development workload, but it greatly helps to clarify the hierarchy of the program and reduce the coupling.
--------------------------------------------------------------------------------

2. Builder mode
Again, if I want to eat, I will go to the corresponding canteen window, but I can't eat the canteen window. There may be a lot of things in the window. I will tell the master that I want this, this, and this.

For example: I have established the factory of the XML parser. Now, if you want to return the parser itself, let the factory create it and return it to me.

XMLParserGetFactory.as
//Generate a factory that parses the read in xml object
class XMLParserGetFactory implements AbstractFactory. {
var xmlParser;
function XMLParserGetFactory(str:String){
//If the message board list parser is required, a
if(str==” xmlParseGuestbookList”){
xmlParser=new xmlParserGuestbookList();
}
}
function createXmlParser(){
//Return the required parser
return xmlParser;
}
}

AbstractXmlParser.as
//Abstract xml parser
Interface AbstractXmlParser{
function ParseXml();
}
xmlParserGuestBookList.as
//Message board list parser
Class xmlParserGuestBookList implements AbstractXmlParser{
//Parse the contents of the xml string into a stack of arrays
function ParseXml(xml:XML,arrayID:Array,arrayTitle:Array){
//Specific cycle operation
}
}

When using:
var xmlParser=new XMLParserGetFactory(“xmlParseGuestbookList”)
xmlParser= XMLParserGetFactory. createXmlParser(xml,arrayID,arrayTitle);
--------------------------------------------------------------------------------

3. Factory Method
When I get to the canteen window, if the master smokes with me, I still can't eat. I said: Master, cook! The master will finish the action of cooking. This is the factory method pattern, and the implementation of abstract factories is usually completed by the factory method pattern.

For example, as mentioned above, I originally wanted to implement a specific xml parser with one parameter in one sentence, but the constructor has no return value, so I must use
xmlParser= XMLParserGetFactory. createXmlParser(xml,arrayID,arrayTitle);
realization.

Note: Abstract factory pattern, generator pattern and factory method pattern need flexible application.
--------------------------------------------------------------------------------

4. Singleton mode
A man in front of me bought a huge chicken leg. I said I would like one, too. The master said, just this one

For example, the singleton mode is widely used. It ensures that each instance is created only once in the global scope. Most of our flash MCs are singletons. The core components in the kernel are also single pieces, such as my message mapping list (see below).
According to the strict definition of the singleton pattern, the class should be responsible for saving its unique instance. But I can't think of how to achieve this in Flash, or what is the significance of implementing it. But another thing we can do is to provide only the unique access point of the object in the global scope. This can be achieved by the hierarchical relationship, which encapsulates the specific access implementation of the object in the lower layer, and only provides the upper layer with a unique access point (because the upper layer does not know the specific information of the single piece, such as the path).
Look at part of my kernel file:
Core.as
//Kernel
class Core {
var strucGlobalParam:ConfigVariables;
//Site Information
var xmlConfig:XML;
//Xml object of site information
var ArrayStructureInitial:Array;
//Array used to provide to the loadObject object
var ArrayForBtn:Array;
//Array used to initialize navigation bar components
var objInitial:loadObject;
//Object reading movie
var objMessageMap:MessageMap;
//Message mapping component
……
}
This is the data structure of my kernel class, which is the core class of the whole station. The data in it can only be accessed directly through the underlying BasicMovie, OriginalFunctionObject and other classes (see below).

Note: The core idea is to ensure that there is only one.
--------------------------------------------------------------------------------

5. ProtoType
Go to the saute window and see the green pepper saute meat in front of you. "Master, I want to do the same."

For example, flash users can't be more familiar with this. We often use duplicateMovieClip() and
AttachMovie(). Copy the corresponding instance according to a prototype, and execute their own actions. In my blog list, the navigation bar is generated.. Prototype patterns are used almost where multiple data are available.
--------------------------------------------------------------------------------

6. Chain of responsibility mode
7. Intermediary model
8. Observer mode
The farthest window of the kitchen in the canteen has no cabbage to cook. You should tell the kitchen to deliver it quickly.
Responsibility chain mode: the message is delivered window by window until it reaches the canteen. When the canteen sees something bad, it should be sent to it as soon as possible.
Intermediary mode: a person is specially assigned to deliver the message. If there is no food at any window, the person is required to hurry to the kitchen.
Observer mode: send a person in the kitchen to stare at the window and start shouting when there is no food.

For example, the reason why I want to put these three design patterns together is that I have built a fun thing in my website, which can be said to be the core of my website. It solves the communication problem of each MC in my flash.
For example, when movie A is finished, notify movie B to start playing. The direct method is to write the relative path from A to B or the absolute path from B in the last frame of A, and let B play (). In this way, the coupling between A and B is quite high, that is, the degree of interdependence is too high. The solutions for using design patterns are as follows:

MessageMap.as
//Message mapping class
class MessageMap extends Object {
var Message:String;
var MessageWatcher:Function;
var Target;
var MessageList:Array;
var Num_Msg:Number;
function MessageMap() {
Num_Msg = 0;
MessageList = new Array();
Message = "HANG_UP";
MessageWatcher = function (prop, oldVar, newVar, Param) {
for (var i = 0; i<Num_Msg+1; i++) {
if (newVar == MessageList[i][0]) {
MessageList[i][1].apply(MessageList[i][3], MessageList[i][2]);
if (!MessageList[i][4]) {
MessageList.splice(i, 1);
Num_Msg--;
i-=1;
}
}
}

};
this.watch("Message", MessageWatcher, "test");
}
function SendMessage(Msg:String, mc:MovieClip) {
Message = Msg;
}
function UpdateMessageMap(Msg:String, objFunction:Function, ArrayParam:Array, objRefer,IsMultiUsed:Boolean) {
MessageList[Num_Msg] = new Array();
MessageList[Num_Msg][0] = new String();
MessageList[Num_Msg][0] = Msg;
MessageList[Num_Msg][1] = new Function();
MessageList[Num_Msg][1] = objFunction;
MessageList[Num_Msg][2] = new Array();
MessageList[Num_Msg][2] = ArrayParam;
MessageList[Num_Msg][3] = objRefer;
MessageList[Num_Msg][4] = IsMultiUsed;
Num_Msg++;
}
function DeleteMessageMap(objRefer) {
for (var i = 0; i<Num_Msg; i++) {
if (MessageList[i][2] == objRefer) {
MessageList.splice(i, 1);
Num_Msg--;
}
}
}
}

class SubTemplateMovie extends BaseMovie {
var MovieRemoveFunction:Function;
function SubTemplateMovie() {
this.stop();
MovieStartFunction = function () {
Lock();
this.play();
};
MovieEndFunction = function () {
Lock();
this.play();
};

MovieRemoveFunction = function () {
this.stop();
SendMsg("SUB_TEMPLATE_REMOVED", this);
_parent.unloadMovie();
};
MovieMainFunction = function () {
stop();
SendMsg("SUB_TEMPLATE_OPEN", this);
};
UpdateMessage("LOADING_BAR_OVER", MovieStartFunction, null, this, false);
UpdateMessage("BACK_TO_INDEX", MovieEndFunction, null, this, false);
}
}

The general mechanism is that the movie submits a data structure in advance and declares that if a movie submits this message, this function will be executed. The principle is that sending messages is actually to assign a value to a variable of the message map. Since the message map inherits from the object class, you can use the watch method to monitor this variable. Once changed, check in the submitted message map list, and execute the corresponding function if any. In fact, this has also resulted in a certain degree of coupling, but we have successfully controlled the coupling in the lower level classes, and the upper level subclasses have completely ignored the implementation process of this set of message mechanisms.

This mechanism allows us to have a deeper understanding of the real purpose of oop. For example, after the film A is played, declare that it is finished. As for what you want to do after I play, it is not my business. I do not control you. The so-called reduction of coupling is a relative concept. Don't forget computer At the bottom, the coupling degree is the same. The CPU always addresses directly or indirectly, but what we need to do is change the topology of the system to control the coupling degree within a certain range.

The whole message mapping class is equivalent to a mediator. An observer is generated internally. Once the message is triggered, it is executed in the way of responsibility chain.
--------------------------------------------------------------------------------

9. Bridge mode
The food was too weak to satisfy some people, so the chef in the canteen was asked to open a special window to add more pepper to the prepared food.

I used the bridge mode in my own website: all movies inherit the self defined BasicMovie class (BasicMovie inherits from MovieClip class), but in the movies of four lower columns, the same methods and events need to be defined to respond to messages. BasicMovie does not have these functions, which does not meet the requirements. At this time, it is foolish to write once in the four movies, I also wrote a SubTemplateMovie class that inherits from BaseMovie, which adds some general methods, and then all four sub template movies inherit it, which greatly simplifies post development.

BasicMovie.as
//Base film
/The original class of all movies. The parent class of all movies inherits from this class
class BaseMovie extends MovieClip {
var isLocked:Boolean;
//Initial class start movie function
var MovieStartFunction:Function;
//Primary movie like main function
var MovieMainFunction:Function;
//Initial Class End Movie Function
var MovieEndFunction:Function;
var GlobalParam
//Initial class constructor
function BaseMovie() {
}
//

//Send message
function SendMsg(Msg:String, Mc:MovieClip) {
_root.objCore.objMessageMap. SendMessage(Msg, Mc);
}
//Add Message Map
function UpdateMessage(Msg:String, MsgMapFunction:Function, ArrayParam, obj, IsMultiUsed) {
_root.objCore.objMessageMap. UpdateMessageMap(Msg, MsgMapFunction, ArrayParam, obj, IsMultiUsed);
}
//Delete Message Map
function DeleteMessage(obj) {
_root.objCore.objMessageMap. DeleteMessageMap(obj);
}
function GetGlobalParam() {
GlobalParam=_root.objCore.strucGlobalParam;
}
}

SubTemplateMovie.as
//Subordinate template movie class
class SubTemplateMovie extends BaseMovie {
var MovieRemoveFunction:Function;
function SubTemplateMovie() {
this.stop();
MovieStartFunction = function () {
Lock();
this.play();
};
MovieEndFunction = function () {
Lock();
this.play();
};

MovieRemoveFunction = function () {
this.stop();
SendMsg("SUB_TEMPLATE_REMOVED", this);
_parent.unloadMovie();
};
MovieMainFunction = function () {
stop();
SendMsg("SUB_TEMPLATE_OPEN", this);
};
UpdateMessage("LOADING_BAR_OVER", MovieStartFunction, null, this, false);
UpdateMessage("BACK_TO_INDEX", MovieEndFunction, null, this, false);
}
}
Note (See the chain of responsibility mode for the message mapping mechanism)
--------------------------------------------------------------------------------

10. Adapter
I want a bowl of soup, but there is only a paper lunch box without a spoon, so the chef in the canteen gave me a disposable soup bowl and spoon, which is called an adapter.

The adapter solves the problem that the external interface of a class is not suitable, which may be caused by the inconsistency of parameters or return value types. At this time, we need to add a layer of indirection between the working object and the class.
I have used this mode in the underlying data exchange layer. As I said, the data exchange between flash and asp. net is all based on xml. There are only three layers of returned xml in the bottom layer: database operation, data operation and data display. The data operation layer returns an xml string to the data display layer. Then I encountered a small problem. On the other hand, I need to submit data to the database, and also submit an xml string, but I need xsd verification of the xml representation of the corresponding table's dataset in the database! (After saying it in one breath, he almost choked to death). That is to say, I need to retrieve at least one record in this table. The problem is that the class I encapsulate always returns xml, not xsd. The solution is the adapter. Create a new project and add a layer dedicated to obtaining the XML validation format. This completes the conversion between different interfaces.

Note: The adapter is very similar to the bridge. When the existing class does not meet the requirements, it adds a layer of indirect elements to achieve the purpose. The difference is that the adapter is used to solve the conversion between incompatible interfaces. Bridging generally does not involve this problem, but only completes one to many conversion.
--------------------------------------------------------------------------------

11. Facade
Every day we have to go to the canteen. Everyone goes to different windows to eat different dishes. We are very tired. Today, the whole dormitory recommends monkeys to eat:
You eat this, three liang rice, I eat that, five liang rice. Everyone talks to the monkey alone, and all the masters in the canteen see the monkey alone.

For example, this mode can be widely used in the communication between the upper and lower layers of the program. Each module of Asp needs to access different data and different tables of the database, so it has to deal with different underlying data access components. That is, each mc module must know which specific data access component I want to go to to fetch data. Each module should maintain its own, at least a string.
If appearance mode is applied. We can let all mcs that need data interaction access the same aspx page, such as getStrXml.aspx. As long as an identifier is transmitted, this unique data fetching leaf can be notified which lower level component is accessed to obtain data. The lower level components do not know which mc requires data, and the mc does not know the specific source of the data, so the upper and lower levels do not appear to be mutually exclusive transparent This reduces the coupling.
--------------------------------------------------------------------------------

12. Proxy mode
Maybe not everyone wants to eat every day, so we require the monkey to be in the dormitory at noon every day. If we want to eat, he will go. If we don't eat, he will do what he likes.

For example: I'm afraid that this is the mode that everyone will unintentionally use in flash. For example, for a website, its subordinate columns do not need to be read in at the beginning of the whole website initialization, but we need to ensure that the corresponding movie files can be read correctly when the viewer wants to see and clicks a button on the navigation bar. The premise is that we must keep an index internally, which can be called an agent. Usually an empty mc
--------------------------------------------------------------------------------

13. Strategy
I find a seat in the canteen every day, and then I eat, eat, and buy a cup of yogurt. This has been modelled. If there is a waiter in the canteen, I will ask him to do the same.

For example, the policy pattern encapsulates a series of algorithms to form a class. This mode can be integrated into other modes almost anywhere at any time. My stack of xml parsers is actually the application of the policy mode, and this mode is also applied to the lower layer of my website, because the data submitted by flash to the aspx page is also an xml string, and the lower layer modules also need corresponding parsing algorithms. Similarly, I encapsulated the parsing of XML into a class.

//Analytic function in Cs file

Class DataModel. BlogMsgs{

Public DataSet parseXML(string strXml){
DataSet ds=new DataSet();
//。。 Load xml into DataSet
Return ds
}

}
--------------------------------------------------------------------------------

14. Flyweight mode
Not enough food? 20 mirrors for you~
Master, there is only one thing...

I'm sorry about this mode, but I haven't thought of implementing it in flash yet. For example, browser The mechanism is that in English documents with a large number of words, the same letter shares a Flyweight, which takes up only one space in memory, and then displays it in different parts of the document. This can save a lot of resources for a large number of fine-grained effects. Please let me know if any comrade has thought of it. Thank you very much.
--------------------------------------------------------------------------------

15. Visitor mode
As long as I want, I can go to any window to get something to eat at any time, on the premise that I must go this time.

For example: I said that all my mcs inherit from the BasicMovie class, but not all my mcs need to obtain database data later. Obtain the information needed to access database data, such as IP address, path, and file. Save them in the configuration file. When initializing, read them into the kernel, and only the kernel has a copy. It is inappropriate to add references to these global variables in BasicMovie, because only a few mcs need to use it, and for some reasons I can no longer use the bridge mode (I have SubTemplateMovie, and can't inherit more), so I use the visitor mode.

BasicMovie.as

//Get global variables
function GetGlobalParam() {
GlobalParam=_root.objCore.strucGlobalParam;
}

If the superior mc does not execute this function, the global variable cannot be obtained. If it is needed, execute it.
In other words, I visit it when necessary.

Note: Declare a visit operation so that visitors can access the required classes correctly.
--------------------------------------------------------------------------------

16. State
I want to eat noodles today. The master asked me: What kind of ingredients do you want? Tomatoes and eggs, ribs or beef?

For example, state mode refers to localizing some current states of an object. When an object changes its state, it looks like it has changed its class. The example is my scroll bar. If you want to scroll a text box, you need to refer to the Scroll and maxscroll attributes of a TextField. If you want to scroll a mc, you need to refer to the __y and _height attributes. I use a parameter to distinguish them, which is controlled by an if statement, so that the scroll bar can freely distinguish between states.
Another solution is to define different subclasses of ScrollBar. There is no essential difference between the two. When there are many states, it may be necessary to maintain a huge if algorithm, so it is better to generate subclasses.

ScrollBar.as
//Scroll bar assembly
function BindTo(mc,type:String,intMcHeight:Number,yinitial:Number){
ScrollType=type;
if(type=="TXT"){
scrollTxt=mc;
}
if(type=="MC"){
initialY=yinitial;
McHeight=intMcHeight;
scrollMc=mc;
}
}
function Scroll() {
if(ScrollType=="TXT")
this.onEnterFrame = function() {
scrollTxt.scroll = scrollTxt.maxscroll*mcBlock._ y/(BgLength-BlockLength*3/2)
};
if(ScrollType=="MC"){
this.onEnterFrame=function(){
if(scrollMc._height>McHeight){
scrollMc._ y=initialY-(scrollMc._height-McHeight)*mcBlock._ y/(BgLength-BlockLength*3/2)}
}
}
}

Note: This is also a common mode, especially in flash logic control
--------------------------------------------------------------------------------

17. Decorator
How can I eat in the canteen without chopsticks? I never bring a rice bowl. The teacher is very humanistic, and there is a large set of chopsticks in each window.

If this mode is used well, it can save effort in some places. For example, the scroll bar on my website:

ScrollBar.as
//Scroll bar assembly
class ScrollBar extends BaseMovie {
var BgLength:Number;
var BlockLength:Number;
var mcBlock:MovieClip
var Width:Number;
var ScrollType;
var scrollTxt:TextField;
var scrollMc:MovieClip;
var McHeight:Number
var initialY:Number
function ScrollBar() {
}
function InitialScrollBar(BgLength, BlockLength) {
this. BlockLength = BlockLength;
this. BgLength = BgLength;
}
function BindTo(mc,type:String,intMcHeight:Number,yinitial:Number){
ScrollType=type;
if(type=="TXT"){
scrollTxt=mc;
}
if(type=="MC"){
initialY=yinitial;
McHeight=intMcHeight;
scrollMc=mc;
}
}
function Scroll() {
if(ScrollType=="TXT")
this.onEnterFrame = function() {
scrollTxt.scroll = scrollTxt.maxscroll*mcBlock._ y/(BgLength-BlockLength*3/2)
};
if(ScrollType=="MC"){
this.onEnterFrame=function(){
if(scrollMc._height>McHeight){
scrollMc._ y=initialY-(scrollMc._height-McHeight)*mcBlock._ y/(BgLength-BlockLength*3/2)}
}
}
}
function ScrollMc() {

}
function StopScroll() {
this.onEnterFrame=null;
}
function Reset(){
mcBlock._ y=0;
}
}

The core function is BindTo(). By binding the instance of this scroll bar to a dynamic text box or a mc, you can achieve scrolling.

Note: The idea of decoration mode is to add responsibilities to a single object in a dynamic and transparent way without affecting other objects.
--------------------------------------------------------------------------------

18. Composite mode
I have six liang rice for lunch, pork stewed noodles, spicy chicken, fish balls, salted duck eggs, plus two cups of yogurt (pig!)
These things are all objects, and they together make up my lunch.

For example: It should be said that the composite mode is ubiquitous in Flash, because as long as there is mc nesting, there is a composite mode. Several mcs are installed in one mc. The mcs used for loading are called containers.
But I'm afraid no one will pay attention to this model, because we all use it without management and understanding. He does have many ways to achieve it, and one of my ways is like this.

//blog.as
My Blog
class Blog extends BaseMovie {
//The first interface of blog, including diary list, calendar and recent messages
var mcBlogList: mcBlogList;
//The second interface of blog includes the full text of the diary, replies, and comments on the diary.
var mcBlogDairy:MovieClip;
var currentState:String;
var currentDairyID:Number;
function blog(){
}
}

mcBlogList.as
//Blog first interface
class mcBlogList extends BaseMovie {
//Recent comments
var recentMsgs:blogMsgsSC;
//Journal list
var blogList:BlogList;
//Calendar
var calendar:CalenderForBlog;


mcblogDairy.as
//Blog second interface
class mcBlogDairy extends BaseMovie {
//Journal full text display
var BlogDairy:BlogDairy;
//Message board
var GuestBook:BlogInputMsg;
//Message list display
var BlogMsgs:BlogMsgs;
}

Each component also contains other components, such as scroll bars, dynamic text boxes, etc. What I want to say is that the mc nesting mode I wrote in as does not necessarily conform to the specific physical nesting mode in the fla file. There are many decorative mc that do not need to be included, and there are many specific reasons, and the path needs to be rewritten. For example, under BlogDairy, the actual path of the scroll bar is BlogDairy.mc1.ScrollBar, not BlogDairy ScrollBar may be because I need mc1 animation, or it may be other specific reasons. But we can add a sentence to the timeline of mc1
_parent. ScrollBar =This. ScrollBar
Point the path to rewrite to achieve the mode we want to use. ScrollBar is a direct member of BlogDay. In addition, I have no statement to initialize the mc. I am used to setting the linkage of the mc in the library.

Note: Although the combination mode is indispensable for everyone, because of this, we can think of more, better and more flexible ways to achieve it
--------------------------------------------------------------------------------

19. Memo mode (memento)
Master, the chicken legs at night are not as fresh as those at noon.
~Nonsense! This is the noon.

For example: just kidding, the above two sentences are not the original intention of the memo mode. In fact, I can't figure out what the memo looks like in the canteen at the moment. Memo means to save the current state of the object without destroying the object encapsulation, and restore or extract the state when necessary.

Memos are widely used in logical relations. It seems to be the only time related model I mentioned at present. In cybernetics, causal systems can be involved. Memos are widely used. The most common one is the browser or website's back function, which returns to the previous interface, but it is not used in my site, because my site is a tree topology, and each column can only enter or return to the main interface from the main interface. For those sites with mesh topology, each column can lead to any other column, It is likely that such a function is needed, and its implementation method is often to maintain a stack type array.

Another thing I want to achieve is the automatic recording within the website. For some reasons, I haven't added it to the website for the time being. It is very simple. It is to monitor each step of the browser's operation, in which column, for how long, and what he has done. If he leaves, the next time he visits the website, he will be asked to choose whether to directly enter the last browsing interface (for example, he was reading my novel last time but did not finish it). This can be implemented through sharedObject, which is almost the internal cookie of flash.

Note: The implementation requirements of memos are very high. Do not break the encapsulation of objects when extracting object states. The ideal memo needs two excuses as an object. One is for the manager, who doesn't know what state is encapsulated in the memo, but is responsible for transferring the state to the object he needs. The other is for the originator, who can only understand and operate the state encapsulated in the memo, and can't do anything else.
--------------------------------------------------------------------------------

Summary:
I will supplement this article at any time. But some examples I want to give have been finished for the time being. In fact, there are far more than these design patterns. There are 23 classic design patterns, 41 of which I know, and only 19 of them. I haven't written about command patterns, interpreter patterns, iterator patterns, and template method patterns. My site also uses some design patterns that I haven't mentioned and haven't thought about in detail. However, it is of little significance to list them one by one. What interested comrades need to do is to touch the details and ideas of these design patterns, and then forget them all. It is the same as Zhang Wuji who learns Taijiquan first and then forgets. Moves should be seen and learned, but they should be understood, flexibly, creatively, combined with each other, and comprehended. They should not be confined to moves, let alone used for the purpose of using them. As an important part of UML, design patterns can greatly promote our development efficiency, enable us to develop good writing habits, and create works that are more humane, harmonious, clear, reusable and controllable.
Don't say you are not a programmer. You can follow your heart and do whatever you want. Of course, we have no right to interfere. I also said that as can write as you want, but it is your freedom to learn advanced thinking mode. Not to mention that you are engaged in art, and your mind is too sensitive to touch these things. The reason why I want to take the canteen as an example is to illustrate that what I want to say is actually the eternal way of architecture, whether it is the architecture itself, or any software engineering, or Flash as, or even Flash vector drawing, art, graphic design, All the way to the world as a whole, they follow a structured, eternal way composed of patterns, with a surprising high degree of similarity and similarity. Understanding this, not only for Flash, but also for the whole life There will be new views. The difference only lies in where to start thinking. Here, you can start from Flash. Author: Blue Ideal