AS3:AddChild 问题 --“TypeError:错误 #2007:参数子项必须为非空。”

发布于 2024-09-13 13:28:19 字数 1979 浏览 4 评论 0原文

我的以下代码给了我 TypeError: 错误 #2007: 参数子项必须为非空运行时错误。 不知道为什么...我希望得到任何帮助...

        mySb = new ScrollBar(); 
        mySb.x = cont.x; //+ cont.width;
        mySb.y = cont.y;
        mySb.height = contMask.height;
        mySb.enabled = true;
        addChild(mySb); 

已更新

package com.search.view

{

import com.search.events.YouTubeSearchEvent;

import fl.controls.ScrollBar;
import fl.controls.Slider;
import fl.controls.UIScrollBar;
import fl.events.ScrollEvent;
import fl.events.SliderEvent;

import flash.display.Shape;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.net.URLLoader;

public class SearchResultContainer extends Sprite
{
    private var cont:videoCont;
    private var contMask:Sprite;
    private var mySb:ScrollBar;


    public function SearchResultContainer()
    {
        super();

        }
    public function get selectedVideoID():String{
        return newVideoID;
    } 

    public function createContainer(_x:Number,_y:Number, videoResult:Array):void{



    cont=new videoCont();
    cont.x=_x;
    cont.y=_y;
    addChild(cont);

    contMask = new Sprite();
    contMask.x = cont.x;
    contMask.y = cont.y;
    createMask(contMask,0x000000,452,88);

    addChild(contMask);     
    cont.mask = contMask;


    mySb = new ScrollBar(); 
            mySb.x = cont.x; //+ cont.width;
            mySb.y = cont.y;
            mySb.height = contMask.height;
            mySb.enabled = true;
            addChild(mySb); //problem code here...




    }


    private function createMask(inSrc:*,inColor:Number=0x999999,inW:Number=80,inH:Number=50):void{
        var rect:Shape=new Shape();
        rect.graphics.clear();
        rect.graphics.beginFill(inColor);
        rect.graphics.drawRect(0,0,inW,inH);
        rect.graphics.endFill();
        inSrc.addChild(rect);
    }



}

}

我在 Flex 环境中...

My following code gave me
TypeError: Error #2007: Parameter child must be non-null runtime error.
not sure why...I would appreciate any help...

        mySb = new ScrollBar(); 
        mySb.x = cont.x; //+ cont.width;
        mySb.y = cont.y;
        mySb.height = contMask.height;
        mySb.enabled = true;
        addChild(mySb); 

Updated

package com.search.view

{

import com.search.events.YouTubeSearchEvent;

import fl.controls.ScrollBar;
import fl.controls.Slider;
import fl.controls.UIScrollBar;
import fl.events.ScrollEvent;
import fl.events.SliderEvent;

import flash.display.Shape;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.net.URLLoader;

public class SearchResultContainer extends Sprite
{
    private var cont:videoCont;
    private var contMask:Sprite;
    private var mySb:ScrollBar;


    public function SearchResultContainer()
    {
        super();

        }
    public function get selectedVideoID():String{
        return newVideoID;
    } 

    public function createContainer(_x:Number,_y:Number, videoResult:Array):void{



    cont=new videoCont();
    cont.x=_x;
    cont.y=_y;
    addChild(cont);

    contMask = new Sprite();
    contMask.x = cont.x;
    contMask.y = cont.y;
    createMask(contMask,0x000000,452,88);

    addChild(contMask);     
    cont.mask = contMask;


    mySb = new ScrollBar(); 
            mySb.x = cont.x; //+ cont.width;
            mySb.y = cont.y;
            mySb.height = contMask.height;
            mySb.enabled = true;
            addChild(mySb); //problem code here...




    }


    private function createMask(inSrc:*,inColor:Number=0x999999,inW:Number=80,inH:Number=50):void{
        var rect:Shape=new Shape();
        rect.graphics.clear();
        rect.graphics.beginFill(inColor);
        rect.graphics.drawRect(0,0,inW,inH);
        rect.graphics.endFill();
        inSrc.addChild(rect);
    }



}

}

I am in Flex environment....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谜泪 2024-09-20 13:28:19

尝试在问题发生之前添加断点并检查 mySb 值,它看起来可能为 null ,如果不是,则必须在您正在使用的 DisplayObjects 或您分配给它们的属性中查找 null 值...如果它是 null ,也许您需要在将 ScrollBar 实例添加到显示列表之前为其设置更多属性...

Try to add a breakpoint before the problem occurs and check the mySb value , it looks like it's probably null , if it's not you'll have to look for null values either in the DisplayObjects you're using or the properties you're assigning them... if it is null , maybe you need to set more properties to your ScrollBar instance before adding it to the display list...

燕归巢 2024-09-20 13:28:19

就我而言,我解决了这个问题,将组件添加到电影库中,但在 Flash CS5.5 环境中工作。

In my case I solved it adding the component to the movie library, but working in Flash CS5.5 environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文