Roy*_*ich 6 flash components actionscript actionscript-3
我正在构建一组Flash组件,能够用库中的另一个替换组件的外观.
目前,我可以在运行应用程序后访问该库,但在实时预览期间不能访问该库,我想知道在实时预览模式下运行时组件是否可以访问库(可以拖动的模式)舞台周围的组件并在"组件参数"窗口中更改其属性)
Here is a simplified code that just looks to see if there is a symbol of the name specified and than instantiates it and adds it as a child.
package
{
import fl.core.UIComponent;
import flash.display.MovieClip;
import flash.system.ApplicationDomain;
/**
* ...
* @author Roy Lazarovich
*/
public class CompTest extends UIComponent
{
private var customfile :String;
public function CompTest()
{
}
override protected function configUI():void
{
}
override protected function draw():void
{
super.draw();
}
private function setCustomFile():void
{
if (ApplicationDomain.currentDomain.hasDefinition(customfile))
{
var c:Class = Class(ApplicationDomain.currentDomain.getDefinition(customfile));
var mc:MovieClip = new c();
addChild(mc);
}
}
[Inspectable(name = "_Custom File", defaultValue = "")]
public function set _customfile(value:String):void
{
customfile = value;
setCustomFile();
drawNow();
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
小智 0
我不完全确定您已经尝试过什么来解决这种情况。但希望这可能有所帮助。
右键单击库中的 MovieClip,选择 Linkage 并为其指定一个类名称,即。我的东西。
在你的代码中,
newMyThing = new MyThing();
this.addChild(newMyThing);
trace("tada!");
Run Code Online (Sandbox Code Playgroud)
希望能帮助您或让您更接近解决方案。