Hi guys. Could someone explain this to me please.
var gfxStroke:GraphicsStroke = new GraphicsStroke(1);
var gfxFill:GraphicsSolidFill = new GraphicsSolidFill(0x00FFFF, 1);
takesAnyStrokeAndAnyFill(gfxStroke, gfxFill);
function takesAnyStrokeAndAnyFill(stroke:IGraphicsStroke, fill:IGraphicsFill):void {
var style:Vector.<IGraphicsData> = new Vector.<IGraphicsData>(2, true);
style[0] = stroke;//Implicit coercion of a value of type flash.display:IGraphicsStroke to an unrelated type flash.display:IGraphicsData
style[1] = fill;//Implicit coercion of a value of type flash.display:IGraphicsFill to an unrelated type flash.display:IGraphicsData
}
Here’s the full code for quick testing:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.*;
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
};
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
var gfxStroke:GraphicsStroke = new GraphicsStroke(1);
var gfxFill:GraphicsSolidFill = new GraphicsSolidFill(0x00FFFF, 1);
takesAnyStrokeAndAnyFill(gfxStroke, gfxFill);
function takesAnyStrokeAndAnyFill(stroke:IGraphicsStroke = null, fill:IGraphicsFill = null):void
{
var style:Vector.<IGraphicsData> = new Vector.<IGraphicsData>(2, true);
style[0] = stroke;//Implicit coercion of a value of type flash.display:IGraphicsStroke to an unrelated type flash.display:IGraphicsData
style[1] = fill;//Implicit coercion of a value of type flash.display:IGraphicsFill to an unrelated type flash.display:IGraphicsData
};
};
};
};