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?
You compiled your SWF to be 800×600, while your embed is at 350×350. If you want your code to work anyway, you should set the stage’s
scaleModetoStageScaleMode.NO_SCALEand thealigntoStageAlign.TOP_LEFT. By default, they areStageScaleMode.NO_BORDERandStageAlign.TOP, which makes your SWF display at about 466×350 (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)).