0
votes

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....

2
A little more context might help. Where are you running this? And when in the lifecycle?Robusto
It doesn't look like you're using the Flex Framework as your code extends Sprite. Which specific line threw the error?JeffryHouser
addChild(mySb); //problem code here... I use flex to write my AS3 and run the project....FlyingCat
Where is the createScroll() method that you're calling? I don't see it in your class.Robusto
plz ignore that method...I added it just for testing...FlyingCat

2 Answers

1
votes

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...

0
votes

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