[haXe] AS3 Embed in Haxe?
Johannes Strömberg
johannes.stromberg at strusoft.com
Fri Jan 5 11:00:32 CET 2007
No, I am not on Linux. Below I have included a small sample:
MyStage.hx
import flash.Stage;
import flash.MovieClip;
class MyStage implements Stage {
static function main() {
var img = new MyStage();
}
var mc : flash.MovieClip;
var textField : flash.TextField;
function new() {
mc = flash.Lib.current;
textField = mc.createTextField("textField",
mc.getNextHighestDepth(), 10, 40, 100, 120);
flash.Stage.scaleMode = "noScale";
flash.Stage.addListener( this);
draw();
}
function onResize() {
mc.clear();
draw();
}
function draw() {
mc.beginFill(0xFF0000);
mc.lineStyle( 0, 0x0000FF, 100);
var size = Math.min( Stage.height, Stage.width);
drawCircle( mc, Stage.width / 2, Stage.height / 2, size / 2 - 20);
mc.endFill();
textField.border = true;
textField.text = getTime();
textField.autoSize = true;
textField._x = Stage.width / 2 - textField._width / 2;
textField._y = Stage.height / 2 - textField._height / 2;
}
static var DEGTORAD:Float = Math.PI/180;
static var a:Float = Math.tan( 22.5 * DEGTORAD);
static function drawCircle( mc:MovieClip, x:Float, y:Float, r:Float) {
mc.moveTo( x + r, y);
for (i in 0...8) {
var endX = x + r * Math.cos( (i + 1) * 45 * DEGTORAD);
var endY = y + r * Math.sin( (i + 1) * 45 * DEGTORAD);
var controlX = endX + r * a * Math.cos( ((i + 1) * 45 - 90)
* DEGTORAD);
var controlY = endY + r * a * Math.sin( ((i + 1) * 45 - 90)
* DEGTORAD);
mc.curveTo( controlX, controlY, endX, endY);
}
}
private function getTime () {
var time:Date = Date.now();
return time.toString();
}
}
MyStage.hxml
-swf MyStage.swf
-swf-lib resource.swf
-swf-version 8
-main MyStage
If I remove the -swf-lib resource.swf line the text is displayed. What
am I doing wrong?
/Johannes
Nicolas Cannasse skrev:
>> Thanks,
>>
>> I was able to add an image using SWFMill and -swf-lib but when I add the
>> -swf-lib statement textfields added with
>> createTextField are not displayed anymore. Manually drawn rectangles and
>> circles do however get displayed correctly.
>>
>> What am I doing wrong?
>>
>> /Johannes
>>
>
> If you are on Linux, try installing fonts.
> Try also setting -swf-version 8
>
> Nicolas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070105/2d9794a1/attachment.htm
More information about the Haxe
mailing list