我打了IDE和读取整天足够的学习,在AS3中,一个lib象征事项的出口类名。
I fought with the IDE and read around all day enough to learn that in AS3, the exported class name of a lib symbol matters.
我有hello.fla。在这里面我创建了一个简单的文本框带有字符串('你好') - coverted到一个符号(影片剪辑),并做了以下内容:
I have hello.fla. In it I created a simple textfield with a string ('hello') - coverted it to a symbol (movieclip) and did the following:
提出的类名你好。 导出为AS检查 在第一帧导出检查。在我所做的一切,我核爆实例在舞台上。我想我可能会添加一些额外的功能,所以后来我居然还内置了Hello.as类,它扩展MovieClip和它生活在默认PKG *和整个FLA精细建立:
Once i did all that i nuked the instance on the stage. I thought I might add some extra functionality later so I actually also built a Hello.as class, which extends MovieClip, and which lives in the default pkg* and the whole fla builds fine:
package
{
import flash.display.MovieClip;
public class Hello extends MovieClip
{
public function Hello()
{
}
}
}
现在我main.fla,同一个文件夹,使用文档类主要和Main.as执行以下操作:
Now my main.fla, same folder, uses document class Main, and Main.as does the following:
private var h:MovieClip;
//...
h = new Hello();
this.addChild(h); //no joy
*的直到我得到这个工作,没有什么是在文件夹中:所有的文件都在根文件夹的
假设库元件住的.fla文件,如Hello.fla里面:
Suppose that the library symbol lives inside an .fla such as Hello.fla:
package
{
import flash.display.MovieClip;
import flash.text.TextField;
/**
* empty mc (blank stage) with a single library symbol containing whatever the hell you want (eg a shape). with settings:
* class = Hello <=== this refers to a specific library symbol, not the entire Hello.fla and whatever else is on the stage when you build it.
* export for AS : checked
* export for runtime sharing (as Hello.swf) : checked <==== This was the step I'd missed
* export in 1st frame : checked
*/
public class Hello extends MovieClip
{
public function Hello()
{
}
}
}
主时间轴/文档类:
The main timeline / document class :
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.Event;
import Hello;
/**
* this is the document class.
*/
public class Main extends MovieClip
{
public function Main()
{
this.h = new Hello();
this.l= new Loader();
this.l.load( new URLRequest("Hello.swf") );
this.l.contentLoaderInfo.addEventListener(Event.COMPLETE, this.test);
}
public function test(e:Event)
{
this.h = new Hello();
h.x = 100;
h.y = 100;
this.addChild(this.h); //shows up on stage. Finally!
}
private var h:MovieClip;
private var l:Loader;
}
}
希望它可以帮助一些其他的newbs像我这样的新AS3。
Hope it helps some other newbs like me new to AS3.