为什么在 (0,0) 处绘制这条线并没有真正在 (0,0) 处绘制? [英] How come drawing this line at (0,0) doesn't really draw it at (0,0)?

查看:31
本文介绍了为什么在 (0,0) 处绘制这条线并没有真正在 (0,0) 处绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新: 一劳永逸,我怎样才能画一条从 (0,0) 到舞台对角的线?

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

这是我所拥有的:

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);
        }

    }

}

请参阅此处,了解文件发生情况的示例.它嵌入在 HTML 页面中.

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

推荐答案

代码有效.只是 SWF 与浏览器窗口的大小不同.如果您直接运行 swf 或者如果您将 swf 嵌入到深色背景中,您将能够看到它的工作原理.

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.

这篇关于为什么在 (0,0) 处绘制这条线并没有真正在 (0,0) 处绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆