gpt4 book ai didi

apache-flex - 如何使用 Parsley MVC IOC 注入(inject)动态连接 Starling View

转载 作者:行者123 更新时间:2023-12-04 02:37:02 27 4
gpt4 key购买 nike

我在 Flex 应用程序中使用 Starling。该应用程序使用 Parsley 框架并在 View 上执行 IOC。

Starling 本质上不是普通的 Flash 显示对象。通常在 Parsley 项目中,如果我想在创建 View 时动态注入(inject),我只需调用 Configure.view(this).execute() 就可以了。

我想知道是否有一种方法可以在不使用 Configure.view 的情况下将数据模型动态地注入(inject)我的 Starling View 中。感觉 Starling View 不是普通 Flash 显示列表中的 DisplayObject。

最佳答案

在我发布这个问题大约一个小时后,我通过与曾经为 powerflasher/FDT 工作并且对 Parsley 了如指掌的 Patrick Kulling 交谈找到了这个解决方案。

基本上你必须得到一个 Parsley Context 的实例,然后像这样调用 context.addDynamicObject 。

            [Inject]
public var context:Context;

[Init]
private function onImagesReady( event : Event = null ) : void
{
//star.root gives us a ref to MainGame witch is our starling view
//that want parsley to do IOC on
context.addDynamicObject(star.root);
}


//here is where we call the starling code and it creates an instance
private function onCC() : void
{
star = new Starling( MainGame, stage );
star.viewPort = new Rectangle(0, 0, width, height);
star.start();
}

关于apache-flex - 如何使用 Parsley MVC IOC 注入(inject)动态连接 Starling View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12849579/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com