Posts Tagged ‘FlashPlayer 10’

  • drawTriangles本质上是来虚拟3D的。
    drawTriangles的第一个参数:vertices:Vector.。这是唯一的一个必要参数,可以指定6个(3对)Number(int不可以),作为Triangle的三个顶点。或者指定6*N个Number,来同时绘出N个Triangles。
    drawTriangles的第二个参数:indices:Vector.。当使用这个参数的时候,drawTriangles的第一个参数vertices的length就不需要为6*N了。Flash会根据第二个参数indices来确定所绘制的Triangles的顶点位置,例如

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponent;
    
    private var UI:UIComponent = new UIComponent();
    
    public function init():void
    {
    addChild(UI);
    
    UI.graphics.beginFill(0xFFFFFF);
    
    UI.graphics.drawTriangles(Vector.<Number>([10,10,  100,100,  100,10,
    110, 110,   200, 200,   200, 110]),
    Vector.<int>([0,1,2, 2,4,5]))
    }
    
    ]]>
    </mx:Script>
    </mx:Application>

    这个例子先在第一个参数中指定了12个(6对)点。
    然后用第二个参数来制定,使用哪三个点,来绘制Triangle。
    当然,第一个参数中,可以只设置4个,或者8个点(非6的倍数)。

    drawTriangles的第三个参数:uvtData:Vector.<Number>。这个参数是对填充的图案进行切割的参数。这个参数有两种取值可能。一:8个(4对)值,指定4个点来确定进行切割的四边形。二:12个(4对)值,指定4个点,以及这四个点的相对比例。如下例所示

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
    <mx:Script>
    <![CDATA[
    import flash.display.BitmapData;
    import mx.core.UIComponent;
    
    private var UI:UIComponent = new UIComponent();
    
    [Embed(source = 'Image.jpg')]
    private var FuturImage:Class;
    
    private var bitmapData:BitmapData = (new FuturImage() as Bitmap).bitmapData;
    
    private var x1:Number = -100,    y1:Number = -100,    z1:Number = 0,    t1:Number = 0;
    private var x2:Number = 100,    y2:Number = -100,    z2:Number = 0,    t2:Number = 0;
    private var x3:Number = 100,    y3:Number = 100,    z3:Number = 0,    t3:Number = 0;
    private var x4:Number = -100,    y4:Number = 100,    z4:Number = 0,    t4:Number = 0;
    
    private var indices:Vector.<int> = new Vector.<int>();
    private var vertices:Vector.<Number> = new Vector.<Number>();
    private var uvtData:Vector.<Number> = new Vector.<Number>();
    
    public function init():void
    {
    vertices.push(x1,y1, x2*0.5,y2*0.5, x3*0.5,y3*0.5, x4,y4);
    indices.push(0, 1, 3, 1, 2, 3);
    uvtData.push(0,0,1, 1,0,.5, 1,1,.5, 0,1,1);
    
    UI.x = 200;
    UI.y = 200;
    addChild(UI);
    
    UI.graphics.beginBitmapFill(bitmapData)
    UI.graphics.drawTriangles(vertices, indices, uvtData);
    }
    ]]>
    </mx:Script>
    </mx:Application>
    

    参考文章:http://www.senocular.com/flash/tutorials/flash10drawingapi/

  • <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponent;
    
    private var UI:UIComponent = new UIComponent();
    
    public function init():void
    {
    var commands:Vector.<int> = new Vector.<int>(5, true);
    commands[0] = GraphicsPathCommand.MOVE_TO;
    commands[1] = GraphicsPathCommand.LINE_TO;
    commands[2] = GraphicsPathCommand.LINE_TO;
    commands[3] = GraphicsPathCommand.LINE_TO;
    commands[4] = GraphicsPathCommand.LINE_TO;
    
    var data:Vector.<Number> = new Vector.<Number>(10, true);
    data[0] = 10; // x
    data[1] = 10; // y
    data[2] = 100;
    data[3] = 10;
    data[4] = 100;
    data[5] = 100;
    data[6] = 10;
    data[7] = 100;
    data[8] = 10;
    data[9] = 10;
    
    addChild(UI);
    
    UI.graphics.beginFill(0xFFFFFF);
    UI.graphics.lineStyle(1);
    UI.graphics.drawPath(commands, data);
    }
    
    ]]>
    </mx:Script>
    </mx:Application>
    

    也可以简写成下面这样

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponent;
    
    private var UI:UIComponent = new UIComponent();
    
    public function init():void
    {
    addChild(UI);
    
    UI.graphics.beginFill(0xFFFFFF);
    UI.graphics.lineStyle(1);
    UI.graphics.drawPath(
    Vector.<int>([1,2,2,2,2]),
    Vector.<Number>([10,10, 100,10, 100,100, 10,100, 10,10]));
    }
    
    ]]>
    </mx:Script>
    </mx:Application>
    
  • 用来确定覆盖区域的填充与否

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponent;
    
    private var UI:UIComponent = new UIComponent();
    private var UIa:UIComponent = new UIComponent();
    
    public function init():void
    {
    addChild(UI);
    addChild(UIa);
    
    UIa.graphics.beginFill(0xFFFFFF);
    UIa.x = 130;
    UI.graphics.beginFill(0xFFFFFF);
    
    UI.graphics.drawPath(
    Vector.<int>([1,2,2,2,2]),
    Vector.<Number>([66,10, 23,127, 122,50, 10,49, 109,127]),
    GraphicsPathWinding.EVEN_ODD);
    
    UIa.graphics.drawPath(
    Vector.<int>([1,2,2,2,2]),
    Vector.<Number>([66,10, 23,127, 122,50, 10,49, 109,127]),
    GraphicsPathWinding.NON_ZERO);
    }
    
    ]]>
    </mx:Script>
    </mx:Application>
    

    EVEN_ODD:无论如何,都会不填充交替部分(与交替部分相邻的部分将填充)
    NON_ZERO:不填充非“0”区域
    PS:顺时针画出的图形记为+1,逆时针记为-1,在交替部分计算机过,得出是否非0

  • 官方地址:
    http://labs.adobe.com/technologies/flashplayer10/

    新特性包括:3D效果,自定义滤镜和效果(Flash真的可以用小巧的文件体积做出Ae的效果?继续观望中…),高级文本排版技术,增强绘图API和优化图像渲染。

    恩,暂时最令人兴奋的是3D效果和Adobe所称的Flash VS AE

    3D Effects - Easily transform and animate any display object through 3D space while retaining full interactivity.  Fast, lightweight, and native 3D effects make motion that was previously reserved for expert users available to everyone.  Complex effects are simple with APIs that extend what you already know.

    Custom Filters and Effects - Create and share your own portable filters, blend modes, and fills using Adobe Pixel Bender™, the same technology used for many After Effects CS3 filters. Shaders in Flash Player are about 1KB and can be scripted and animated at runtime.

    Advanced Text Layout - A new, highly flexible text layout engine, co-existing with TextField, enables innovation in creating new text controls by providing low-level access to text offering right-to-left and vertical text layout, plus support for typographic elements like ligatures.

    Enhanced Drawing API - Runtime drawing is easier and more powerful with re-styleable properties, 3D APIs, and a new way of drawing sophisticated shapes without having to code them line by line.

    Visual Performance Improvements – Applications and videos will run smoother and faster with expanded use of hardware acceleration.  By moving several visual processing tasks to the video card, the CPU is free to do more.