zoukankan      html  css  js  c++  java
  • MVC模式

    1.modle

    package
    {
    	import flash.events.Event;
    	import flash.events.EventDispatcher;
    
    	public class modle extends EventDispatcher
    	{
    		private var mint;
    		private var mheight:int;
    		public function modle()
    		{
    			
    		}
    		public function get Mwidth():int
    		{
    			return mwidth;
    		}
    		public function set Mwidth(value:int):void
    		{
    			mwidth = value;
    		}
    		
    		public function get Mheight():int
    		{
    			return mheight;
    		}
    		public function set Mheight(value:int):void
    		{
    			mheight = value;
    		}
    		
    		public function ChangeModel(_int,_height:int):void
    		{
    			Mwidth = _width;
    			Mheight = _height;
    			dispatchEvent(new Event("change"));
    		}
    	}
    }
    

    2.view 

    package
    {
    	import flash.display.Shape;
    	import flash.display.Sprite;
    	import flash.events.Event;
    
    	public class view extends Sprite
    	{
    		private var theModle:modle;
    		private var theController:controller;
    		private var shape:Shape
    		public function view(_model:modle, _controller:controller)
    		{
    			shape = new Shape();
    			shape.graphics.beginFill(0xffff00);
    			shape.graphics.drawRect(0,0,100,100);
    			shape.graphics.endFill();
    			addChild(shape);
    			theModle = _model;
    			theController = _controller;
    			theModle.addEventListener("change", HandleDraw);
    		}
    		private function HandleDraw(evt:Event):void
    		{
    			shape.width = theModle.Mwidth;
    			shape.height = theModle.Mheight;
    		}
    		//添加按钮,调用这个方法刷新Model
    		public function RefreshModel():void
    		{
    			theController.changeModle();
    		}
    	}
    }
    

    3.controller

    package
    {
    	public class controller
    	{
    		private var theModle:modle
    		public function controller(_modle:modle)
    		{
    			theModle = _modle;
    		}
    		public function changeModle():void
    		{
    			theModle.ChangeModel(200,200);
    		}
    	}
    }
    

    4.运行

    var mo:modle = new modle();
    var col:controller = new controller(mo);
    var vi:view = new view(mo,col);
    addChild(vi);
    vi.RefreshModel();
    
  • 相关阅读:
    Apache日志分析
    iptables日志探秘
    php与其他一些相关工具的安装步骤分享
    ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_830_0.MYI' (Errcode: 13)
    一些可能需要的正则
    restful api的简单理解
    认识MySQL Replication
    如何处理缓存失效、缓存穿透、缓存并发等问题
    经典算法mark
    php常用的一些代码
  • 原文地址:https://www.cnblogs.com/mzbdadou/p/2101302.html
Copyright © 2011-2022 走看看