简体   繁体   English

Flex 错误 #1009:无法访问 null object 引用的属性或方法

[英]Flex Error #1009: Cannot access a property or method of a null object reference

I am trying to use a button in my init() method.我想在我的 init() 方法中使用一个按钮。

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="Test"
        creationComplete="init()">

Now when I try to do something with my button I get the error mentioned.现在,当我尝试用我的按钮做一些事情时,我得到了提到的错误。 I am assuming maybe it has not loaded yet?我假设它可能还没有加载?

function init():void{
     myButton.thisorthat == makes the error.
}

* EDIT ** The button is created in MXML btw Not that it matters, but this is for a flex mobile app. *编辑**该按钮是在 MXML 中创建的,顺便说一句,这并不重要,但这是针对 flex 移动应用程序的。

Actually it does matter.其实很重要。 One thing about NavigatorContent (assuming your children are a subset of one of these types of containers) to remember along with their halo counterparts is they all have a content creation policy set to deferred - meaning it creates the parent most layer of the view / viewstack, but not it's children until the user has actually navigated to that particular child.关于 NavigatorContent(假设您的孩子是这些类型容器之一的子集)要记住的一件事是它们的 halo 对应物都将内容创建策略设置为延迟 - 这意味着它创建了视图/视图堆栈的父级最层,但在用户实际导航到该特定孩子之前,它不是孩子。 One cheat is to set the policy to 'ALL', but the better way is to actually listen for the FlexEvent.CONTENT_CREATION_COMPLETE instead (this is broadcast from the child of the navigation container).一种欺骗是将策略设置为“全部”,但更好的方法是实际监听FlexEvent.CONTENT_CREATION_COMPLETE (这是从导航容器的子级广播的)。

Eg:例如:

<halo:ViewStack id="setupStack" width="100%" height="100%">
    <api:FileSelector width="100%" height="100%" owner="{this}" 
                      enumerationMode="{FileSystemEnumerationMode.DIRECTORIES_ONLY}"
                      hint="{networkDbAccessHint}" />
    <!- this is valid, but not it's children until contentCreateComplete is fired -->
    <api:DataImport width="100%" height="100%" owner="{this}" />
</halo:ViewStack>

Both 'FileSelector' and 'DataImport' broadcast the event (extends s:NavigatorContent). “FileSelector”和“DataImport”都广播事件(扩展 s:NavigatorContent)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flex错误#1009:无法访问空对象引用的属性或方法 - Flex Error #1009: Cannot access a property or method of a null object reference AS3-错误#1009:无法访问空对象引用的属性或方法 - AS3 - Error #1009: Cannot access a property or method of a null object reference AS3错误1009:无法访问空对象引用的属性或方法 - AS3 Error 1009 : Cannot access a property or method of a null object reference 动作3错误1009:无法访问空对象引用的属性或方法 - Actionscript 3 error 1009: Cannot access a property or method of a null object reference AS3-错误#1009:无法访问空对象引用的属性或方法 - AS3 - Error #1009: Cannot access a property or method of a null object reference TypeError:错误#1009:无法访问空对象引用的属性或方法 - TypeError: Error #1009: Cannot access a property or method of a null object reference 类型错误:错误 #1009:无法访问空对象引用的属性或方法 - TypeError: Error #1009: Cannot access a property or method of a null object reference 语法错误:错误#1009:无法访问空对象引用的属性或方法 - SyntaxError: Error #1009: Cannot access a property or method of a null object reference TypeError:错误#1009:无法访问空对象引用的属性或方法 - TypeError: Error #1009: Cannot access a property or method of a null object reference 错误#1009无法访问空对象引用的属性或方法 - Error #1009 Cannot access a property or method of a null object reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM