Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何在默认包中导入期初组件?_Actionscript 3_Apache Flex_Flash Builder_Flex4.5_Mxml - Fatal编程技术网

Actionscript 3 如何在默认包中导入期初组件?

Actionscript 3 如何在默认包中导入期初组件?,actionscript-3,apache-flex,flash-builder,flex4.5,mxml,Actionscript 3,Apache Flex,Flash Builder,Flex4.5,Mxml,在打开组件(欢迎页面)时有一个按钮,它在开始时不可见。当用户传递到另一个组件时,按钮应该是可见的。但是,我无法访问属性 在(默认包)导入期初组件的方法是什么? 这是按钮: <s:SWFLoader id="btnRepr" x="1790" y="1008.45" source="@Embed('Components/Starter/Assets/Buttons/ButtonReport.swf')" click="ShowReportPage" visible="false"/>

在打开组件(欢迎页面)时有一个按钮,它在开始时不可见。当用户传递到另一个组件时,按钮应该是可见的。但是,我无法访问
属性

在(默认包)导入期初组件的方法是什么?

这是按钮:

<s:SWFLoader id="btnRepr" x="1790" y="1008.45" source="@Embed('Components/Starter/Assets/Buttons/ButtonReport.swf')" click="ShowReportPage" visible="false"/>

这是我改变的部分,可见为真:


btnRepr.visible=true//访问未定义属性“btnRepr”

假设在
SWFComponent
中有
SWFLoader

<s:SWFLoader id="btnRepr" source="@Embed('ButtonReport.swf')"  visible="false"/>

当然,这只是一个非常简单和有限的例子,如果你能做你想做的事情,你应该根据你的具体需求来改进它

编辑:

假设我的两个组件都在
MyComponents
包中,那么为了创建它们的实例,我做了以下工作:

import MyComponents.*;

public var swf_component:SWFComponent;              
public var btn_component:BTNComponent;
例如,在应用程序的创建完成事件处理程序中,我添加了:

swf_component = new SWFComponent();
addElement(swf_component);

btn_component = new BTNComponent();
addElement(btn_component);
然后,当点击
btn_组件
内的按钮时,SWF_组件`内的SWF设置为可见


希望能有所帮助。

您在哪里使用的
btnRepr.visible=true?我在上面提到的第二个组件中调用它。这两行属于两个不同的组件/
mxml
文件
@akmozo I定义了第一个组件的一个实例,并进行了类似于
starter\u instar.btnRepr.visible=true的调用但抛出空对象引用。我不是想把第一个组件导入到第二个组件中,在第二个组件中我做了更改可见性声明吗?我给出了一个答案,看一看……出于某种原因,它无法识别
button\u clickHandler
方法中的实例。如果我直接调用like
mx.core.FlexGlobals.topLevelApplication.btnRepr.visible=true,它就会像预期的那样工作@coner组件的两个实例应处于同一级别(在本例中)。。。在我的示例中,顶级应用程序中有SWFComponent的实例和BTNComponent的实例。您是如何(在哪里)添加组件实例的?src文件夹下有三个包。(默认包)是欢迎页面(Starter.mxml)所在的主包。所有其他页面组件都位于第二个包下。所以我只是在…visible=true之前定义了我的实例;线状
var strtr:Starter=新启动器。还试图在函数上定义它,但相同。@coner抱歉,我不明白你的意思。@coner你应该知道级别问题只涉及实例,而不是它们包中的组件。。。我们不关心组件所在的位置,但我们关心它的实例级别,以了解如何访问它。。。对不起,如果我不是很清楚。。。
import MyComponents.*;

public var swf_component:SWFComponent;              
public var btn_component:BTNComponent;
swf_component = new SWFComponent();
addElement(swf_component);

btn_component = new BTNComponent();
addElement(btn_component);