How come drawing this line at (0,0) doesn't really draw it at (0,0)?

。_饼干妹妹 提交于 2019-12-12 03:09:35

问题


Update: Once and for all, how can I draw a line that goes from (0,0) to the opposite corner of the stage?

Here is what I have:

package 
{
    import flash.display.Sprite;

    import flash.display.LineScaleMode;
    import flash.display.CapsStyle;
    import flash.display.JointStyle;

    import flash.display.Shape;
    import flash.events.Event;

    public class Main extends Sprite 
    {

        private var lines:Shape;

        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);
            // entry point

            lines = new Shape();
            addChild(lines);

            lines.graphics.clear();
            lines.graphics.lineStyle(10, 0x000000);

            lines.graphics.moveTo(0, 0);

            lines.graphics.lineTo(stage.stageWidth, stage.stageHeight);
        }

    }

}

See here for an example of what happens with the file. It's embedded in an HTML page.


回答1:


The code works. It's just that the SWF is not the same size as the browser window. If you run the swf directly or if you embed the swf onto a dark colored background you will be able to see that it works.



来源:https://stackoverflow.com/questions/2627187/how-come-drawing-this-line-at-0-0-doesnt-really-draw-it-at-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!