简体   繁体   English

错误#1009无法访问空对象引用的属性或方法

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

I'm trying to import an external SWF with a scrollbar, calling out to an external .AS, into my main SWF. 我正在尝试使用滚动条导入外部SWF,并调用外部.AS到我的主SWF中。 Someone told me, it's an issue that my scrollbar isn't instantiated yet, but stopped short of helping me how to fix the problem. 有人告诉我,这是一个问题,我的滚动条尚未实例化,但是没有帮助我解决问题。

Here's the error below: 这是以下错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference. TypeError:错误#1009:无法访问空对象引用的属性或方法。 at Scrollbar/init() at Sample2_fla::MainTimeline/scInit() at flash.display::DisplayObjectContainer/addChild() at Sample2_fla::MainTimeline/frame1() 在滚动条/ init()在Sample2_fla :: MainTimeline / scInit()在flash.display :: DisplayObjectContainer / addChild()在Sample2_fla :: MainTimeline / frame1()

On my main SWF, I was to click a button and load my external SWF. 在主SWF上,我单击了一个按钮并加载了外部SWF。 I want to then click another button in the external SWF and reveal my scrollbar (alpha=1;). 然后,我想单击外部SWF中的另一个按钮并显示我的滚动条(alpha = 1;)。 The scrollbar is the issue. 滚动条是问题。

Here's my script: 这是我的脚本:

Sample1.swf (main) Sample1.swf(主)

this.addEventListener(MouseEvent.CLICK, clickListener);

var oldSection=null;
function clickListener(evt:Event) {
    if (evt.target.name=="button_btn") {
        loadSection("Sample2.swf");
    }
}

function loadSection(filePath:String) {
    var url:URLRequest=new URLRequest(filePath);

    var ldr:Loader = new Loader();
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, sectionLoadedListener);
    ldr.load(url);
}

function sectionLoadedListener(evt:Event) {
    var section=evt.target.content;

    if (oldSection) {
        removeChild(oldSection);
    }

    oldSection=section;
    addChild(section);
    section.x=0;
    section.y=0;

}

Sample2.SWF (external): Sample2.SWF(外部):

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;


scroll_mc.alpha=0;

import Scrollbar;

var sc:Scrollbar=new Scrollbar(scroll_mc.text,scroll_mc.maskmc,scroll_mc.scrollbar.ruler,scroll_mc.scrollbar.background,scroll_mc.area,true,6);
sc.addEventListener(Event.ADDED, scInit);
addChild(sc);

function scInit(e:Event):void {
    sc.init();
}

button2_btn.addEventListener(MouseEvent.CLICK, clickListener);
function clickListener(evt:MouseEvent){
    TweenMax.to(this.scroll_mc, 1,{alpha:1});
    }

I really appreciate your help. 非常感谢您的帮助。

Cheers! 干杯!

You're using var sc:Scrollbar. 您正在使用var sc:Scrollbar。 I think you want that to be a property of the class. 我认为您希望将其作为班级的财产。 scInit doesn't have access to sc and it's null. scInit无权访问sc,它为null。

暂无
暂无

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

相关问题 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 Flex错误#1009:无法访问空对象引用的属性或方法 - Flex 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 TypeError:错误#1009:无法访问空对象引用的属性或方法 - TypeError: Error #1009: Cannot access a property or method of a null object reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM