易截截图软件、单文件、免安装、纯绿色、仅160KB

工厂设计模式【Flash】

  工厂模式在设计模式中可以说是最简单的一个模式了!我们平常写程序的时候工厂模式用的非常的广泛!这里我们就来详细的探讨一下工厂模式。
   工厂模式是怎样诞生的呢?在实际的编程过程当中我们经常要碰到一个问题,就是类的封装,也可以说是隐藏产品类!这样我们就出现了工厂模式!这个模式就是专门用来隐藏产品类的!平常我们要是创建一个Sprite类的实例我们会这样写:
var my:Sprite = new Sprite();
addChild(my);
   这样写看似简单明了!但事实上不符合我们隐藏产品类的目的!设想一下!这样写之后,在类中任意一个方法都可以访问到这个对象,这是我们不希望的。所以,我们就要想办法隐藏这个Sprite(在实际编程的时候一般都是比较复杂的对象)类。那么我们怎么做呢?首先我们要有一个思路!就是使用“中介”(这个名字是我自己起的)。这个中介是产品类与客户中间的一座桥梁,我们通过中介来生成产品。这样就可以来隐藏产品类了!
 那么好了,我们来看一个简单的实例吧!这里我们的产品类使用的是接口!那么我们这个产品做什么呢?为了简单起见,我们的产品一个画一个正方形,另一个画一个圆形。这样来区分2个产品。
IShape接口:
package{
public interface IShape{
function moveshape(X:int,Y:int):void;
function drawshape():void;
}
}  
Round类:
package{
import flash.display.Shape;
public class Round extends Shape implements IShape{
public function drawshape():void{
graphics.beginFill(0x00ff00);
graphics.drawCircle(0,0,100);
graphics.endFill();
}
public function moveshape(X:int,Y:int):void{
this.x = X;
this.y = Y;
}
}
}  
Rectshape类:
package {
import flash.display.Shape;
public class Rectshape extends Shape implements IShape{
public function drawshape():void{
graphics.beginFill(0xff00ff);
graphics.drawRect(0,0,100,100);
graphics.endFill();
}
public function moveshape(X:int,Y:int):void{
this.x = X;
this.y = Y;
}
}
}  
DrawshapeObject类:
package{
import flash.errors.IllegalOperationError;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
public clas


相关文档:

Flex——Flash Player Not Found

Are you running your Flex Application and continually getting the error below?
"Flex Builder cannot locate the required version of the Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder. Do you want to try to run your application with the current version?"
Description ......

声音冲突及firefox中flash中汉字显示问题解决


声音冲突:
    调试好计算机以后发现自己的播放器播放音乐的时候打开优酷没有声音,而打开优酷的时候自己的播放器竟然也没有了声音,从网上查到是因为声音冲突抢占声卡的问题。
    从首选项中选择音效,把所有的输入模式都改为ALSA就可以把问题解决了。不错吧!
    u ......

flash import mx.transitions.Tweens;使用

flash mx.transitions.Tween;可以实现类似于补间动画的效果;导入该类:
import mx.transitions.Tween;
然后用new Tween()方法即可实现。New Tween()方法格式:
new Tween(要应用补间的MC,要应用补间的MC的属性,缓动效果,属性的初始值,属性的结束值,补间的长度,补间长度的类型)
下面介绍一下new Tween()方 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号