Skip to content

Instantly share code, notes, and snippets.

@alecmce
Created October 14, 2010 02:59
Show Gist options
  • Save alecmce/625470 to your computer and use it in GitHub Desktop.
Save alecmce/625470 to your computer and use it in GitHub Desktop.
package
{
import com.bit101.components.PushButton;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageDisplayState;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
[SWF(backgroundColor="#FFFFFF", frameRate="31", width="640", height="480")]
public class Main extends Sprite
{
private var tf:TextField;
public function Main()
{
graphics.lineStyle(1, 0);
graphics.drawRect(0, 0, 640, 480);
new PushButton(this, 20, 20, "fullscreen();", goFullscreen);
new PushButton(this, 20, 60, "draw();", drawFullscreen);
tf = new TextField();
tf.x = 140;
tf.y = 20;
tf.width = 500;
tf.height = 440;
tf.multiline = true;
tf.selectable = false;
tf.wordWrap = true;
tf.defaultTextFormat = new TextFormat("_sans", 12, 0);
tf.text = "private function fullscreen():void\n{\n stage.displayState = StageDisplayState.FULL_SCREEN;\n}\n\nprivate function draw():void\n{\n var data:BitmapData = new BitmapData(640, 480, true, 0);\n data.draw(stage);\n}";
addChild(tf);
}
private function goFullscreen(event:MouseEvent):void
{
fullscreen();
}
private function drawFullscreen(event:MouseEvent):void
{
draw();
}
private function fullscreen():void
{
stage.displayState = StageDisplayState.FULL_SCREEN;
}
private function draw():void
{
try
{
var data:BitmapData = new BitmapData(640, 480, true, 0);
data.draw(stage);
}
catch (error:Error)
{
tf.appendText("\n\nERROR:\n\nSecurity Error: Error #2121: Security sandbox violation: BitmapData.draw: ...Main.swf cannot access https://www.macromedia.com/support/flashplayer/sys/. This may be worked around by calling Security.allowDomain");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment