Dear Friends,
Iam new to Haxe, iam a Actionscript3 programmer, i have some elearning lessons as swf&fla. I want to convert it as html5 and run in the browser. i followed the instruction and created one sample. My swf loads fine as html. But when there is a simple action script it throgh the eror as below:
[swf.exporters.animate.AnimateTimeline] Error evaluating frame script
TypeError: Cannot read property ‘addEventListener’ of undefined
[FilePos(null,null,4,11),FilePos(null,http://127.0.0.1:3000/SimpleSWFLayout.js,78063,19),
function(){
this.stop();
console.log(this.btn1);
this.btn2.addEventListener(openfl_events_MouseEvent.CLICK, this.btn1Clicked);}
Actually i just copy and pasted my moviecps elements all in side layout.fla.
my code in animate is (timeline inside a movieclip):
stop();
import flash.events.MouseEvent;
btn2.addEventListener(MouseEvent.CLICK, btn1Clicked);
function btn1Clicked(event:MouseEvent){
play();
}
my code in prject.xml:
<?xml version="1.0" encoding="utf-8"?><meta title="Simple SWF Layout" package="org.openfl.samples.simpleswflayout" version="1.0.0" company="OpenFL" />
<app main="Main" path="Export" file="SimpleSWFLayout" />
<source path="Source" />
<haxelib name="openfl" />
<haxelib name="layout" />
<haxelib name="swf"/>
<library path="Assets/layout.swf" generate="true" preload="true" />
my code in Main.hx:
package;
import layout.Layout;
import layout.LayoutItem;
import openfl.display.MovieClip;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.utils.ByteArray;
import openfl.Assets;
class Main extends Sprite {
private var clip:MovieClip;
private var layout:Layout;
public function new () {
super ();
var timeline = Assets.getMovieClip("layout:");
clip = Assets.getMovieClip ("layout:Layout");
addChild (clip);
trace(clip);
layout = new Layout ();
layout.addItem (new LayoutItem (clip.getChildByName ("Background"), STRETCH, STRETCH, false, false));
layout.addItem (new LayoutItem (clip.getChildByName ("Header"), TOP, STRETCH, true, false));
layout.addItem (new LayoutItem (clip.getChildByName ("Column"), STRETCH, LEFT, false, true));
layout.resize (stage.stageWidth, stage.stageHeight);
stage.addEventListener (Event.RESIZE, stage_onResize);
}
private function stage_onResize (event:Event):Void {
layout.resize (stage.stageWidth, stage.stageHeight);
}
}
i just tried to stop, when we click on a button it should play… Please help me to do this. i have more swf files to convert as html5.
I have voice over in my flash file, its not playing in HTML5 after compile. i did openfl test html5.
please help me to solve this.
Thanks in advance,
Syed Abdul Rahim