views:

51

answers:

2

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, init);
            // 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?

+1  A: 

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.

jonathanasdf
I'm using FlashDevelop. Is this a known issue or what?
George Edison
I'm using FlashDevelop too. I don't know why it's not working for you.... can someone else confirm whether it works for them or not?
jonathanasdf
@jonathanasdf: What would be the command for manually compiling with `mxmlc`?
George Edison
http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.htmljust plain mxmlc filename.as
jonathanasdf
@jonathanasdf: Tried that - I just end up with the same thing... with a blue background now.
George Edison
this is really, really, really weird.
jonathanasdf
+4  A: 

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)).

greetz
back2dos

back2dos
jeez... so it WAS a problem with his embed. But how do you know his SWF was set to be 800x600, not actually 350x350?
jonathanasdf
Thank you everyone - I was beginning to think I had lost it.
George Edison
@jonathanasdf: well, 1. it's the FD default setting, 2. if you download the SWF and open it in the standalone player, it will open at its prefered size. of course there are plenty of other ways to find out. :)
back2dos
ahh.. never thought of downloading the swf! :)
jonathanasdf