Actionscript 3 使用接口编写UI组件树
我正在使用基本接口(而不是基类)编写UI组件树。目前它没有太多的代码。UI条目是一个Actionscript 3 使用接口编写UI组件树,actionscript-3,Actionscript 3,我正在使用基本接口(而不是基类)编写UI组件树。目前它没有太多的代码。UI条目是一个UIConfig对象。出于某种原因,在运行(而不是构建)代码时,创建组件会产生一个VerifyError,就像使用UICollection: VerifyError:错误#1053:gingerbreadui.UICollection中非法重写UICollection ⨽ 基本上 ⨽ 运行时::ContentPlayer/loadInitialContent() ⨽ 运行时::ContentPlayer/play
UIConfig
对象。出于某种原因,在运行(而不是构建)代码时,创建组件会产生一个VerifyError
,就像使用UICollection
:
VerifyError:错误#1053:gingerbreadui.UICollection中非法重写UICollection
⨽ 基本上
⨽ 运行时::ContentPlayer/loadInitialContent()
⨽ 运行时::ContentPlayer/playRawContent()
⨽ 运行时::ContentPlayer/playContent()
⨽ 运行时::AppRunner/run()
⨽ 在adlapentry/run()时
⨽ 全局/运行时::ADLEntry()
组件
是UI组件的基本接口。。。删除implements
子句时,似乎出现了错误stop,这似乎是一个bug
容器。作为
package gingerbreadui {
import flash.display.Sprite
public final class UIMenu {
public const top: UICollection = new UICollection
internal const _root: Sprite = new Sprite
internal var _cfg: UIConfig
public function UIMenu() {
_root.addChild(top.sprite)
}
// ...
}
}
package gingerbreadui {
import flash.display.Sprite
public final class UIConfig {
internal var _root: Sprite;
static public function fromSprite
(root: Sprite) : UIConfig
{
var cfg: UIConfig = new UIConfig
cfg._root = root
return cfg
}
public function createMenu() : UIMenu {
var menu: UIMenu = new UIMenu
menu._cfg = this
return menu
}
}
}
UICollection
定义了一些方法,但没有构造函数
package gingerbreadui {
import flash.display.Sprite
public final class UICollection implements Component {
public const children: Vector.<Component> = new <Component> [];
public var width: Object
, height: Object
, direction: String = 'horizontal'
, itemMargin: Number = 0;
private const _root: Sprite = new Sprite;
private var _width: Number = 0
, _height: Number = 0;
// ...
}
}
配置为
package gingerbreadui {
import flash.display.Sprite
public final class UIMenu {
public const top: UICollection = new UICollection
internal const _root: Sprite = new Sprite
internal var _cfg: UIConfig
public function UIMenu() {
_root.addChild(top.sprite)
}
// ...
}
}
package gingerbreadui {
import flash.display.Sprite
public final class UIConfig {
internal var _root: Sprite;
static public function fromSprite
(root: Sprite) : UIConfig
{
var cfg: UIConfig = new UIConfig
cfg._root = root
return cfg
}
public function createMenu() : UIMenu {
var menu: UIMenu = new UIMenu
menu._cfg = this
return menu
}
}
}
实际上,我在实现接口时犯了一个错误,但是编译器没有发出警告,因此我在运行时愚蠢地遇到了这个VerifyError 接口有一个getter,但我的类定义了一个常规方法。只是猜测:宽度和高度是在DisplayObject或更高版本中定义的getter/setter属性。这种错误可以通过注释所有内容,然后逐个取消注释以捕获麻烦的错误来解决。