开发者

How do you draw a line from one corner of the stage to the other?

I am completely perplexed. I asked this question and it (any mentioned solution) doesn't seem to be working at all.

All I want is to draw a line from one corner to the other.

Here again is the link to the SWF file I have (it's embedded in an HTML document): test.html

Here is the source:

package 
{
    import flash.display.Sprite;
    import flash.events.Event;

    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, in开发者_StackOverflowit);
            // entry point

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

            graphics.moveTo(0, 0);
            graphics.lineTo(stage.stageWidth, stage.stageHeight);
        }

    }

}

It just doesn't work! The line goes from somewhere offscreen to about the middle of the stage. What on earth am I doing wrong?


You compiled your SWF to be 800x600, while your embed is at 350x350. If you want your code to work anyway, you should set the stage's scaleMode to StageScaleMode.NO_SCALE and the align to StageAlign.TOP_LEFT. By default, they are StageScaleMode.NO_BORDER and StageAlign.TOP, which makes your SWF display at about 466x350 (maintaining 4:3 ratio), thus having its upper left corner at about (-58,0) and it's lower right at about (408, 350) (being horizontally centered (relatively to area of the embed)).


well i'm perplexed too. Copying the EXACT SAME CODE and running the swf WORKS. http://www.swfcabin.com/open/1271209077

so i swear it's something wrong with your embed tag or something.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜