0
我试图导入一个带滚动条的外部SWF,调用外部.AS到我的主SWF中。有人告诉我,这是一个问题,我的滚动条还没有实例化,但没有帮助我如何解决这个问题。错误#1009无法访问空对象引用的属性或方法
以下是错误: TypeError:错误#1009:无法访问空对象引用的属性或方法。 在滚动条/的init() 在Sample2_fla :: MainTimeline/scInit() 在flash.display使用::级DisplayObjectContainer /的addChild() 在Sample2_fla :: MainTimeline /帧1()
在我的主SWF,我是点击一个按钮并加载我的外部SWF。我想再点击外部SWF中的另一个按钮并显示我的滚动条(alpha = 1;)。滚动条是问题。
这里是我的脚本:
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(外部):
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});
}
我真的很感谢你的帮助。
干杯!