[RESOLVED] Despartely need help with NULL ERROR
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] Despartely need help with NULL ERROR

  1. #1
    Senior Member
    Join Date
    Mar 2008
    Posts
    168

    resolved [RESOLVED] Despartely need help with NULL ERROR

    I have one SWF loading two external SWFs (CORE loads PE and RE swfs). Separately the PE and RE run pefectly fine. However when I try to load into the CORE SWF I get:

    Actionscript Code:
    TypeError: Error #2007: Parameter child must be non-null.
     

    I have been looking at this for three days and cannot see where I am going wrong. Please Help

    Here is the CORE Code:

    Code:
    //* MAKE BUTTONS STAY ACTIVE WHEN CLICKED *//
    
    var aClip:MovieClip = this.getChildByName("a_mc") as MovieClip;
    var bClip:MovieClip = this.getChildByName("b_mc") as MovieClip;
    var hash:Dictionary = new Dictionary();
    
    aClip.addEventListener(MouseEvent.CLICK, handleClick);
    bClip.addEventListener(MouseEvent.CLICK, handleClick);
    
    var selected:MovieClip = aClip; 
    selected.gotoAndStop(10); 
    /*
    trace("selected");*/
    
    function handleClick(e:MouseEvent):void 
    {     
    	var target:MovieClip = e.currentTarget as MovieClip;     
    	if (target != selected) 
    	{         
    		selected.gotoAndStop(1);         
    		selected = target;         
    		selected.gotoAndStop(5);     
    	 } 
    }
    
    //* ALL ABOUT LOADERS *//
    
    var swfholder:Loader=new Loader();
    a_mc.addEventListener(MouseEvent.CLICK, loadLeg);
    b_mc.addEventListener(MouseEvent.CLICK, loadHouse);
    
    swfholder.load(new URLRequest("04_23_pensions_pe.swf")); //starts movie with Pensions loaded
    
    swfholder.contentLoaderInfo.addEventListener(Event.COMPLETE, onSwfLoaded)
    
    
    function onSwfLoaded(event:Event):void  //prepares Retirees loader, removes Pensions 
    {
       this.addChild(swfholder);
       swfholder.x =5; 
       swfholder.y =125; 
       swfholder.width =885;
       swfholder.height =430;
       b_mc.addEventListener(MouseEvent.CLICK, loadHouse);
       a_mc.removeEventListener(MouseEvent.CLICK, unloadthis);
    }
    
    function loadLeg(event:MouseEvent):void
    {
    	this.addChild(swfholder);
    	swfholder.load(new URLRequest("04_23_pensions_pe.swf")); //loads Legislature swf
    	swfholder.x =0; 
    	swfholder.y =0;
    	swfholder.width =880;
        swfholder.height =308;
    	b_mc.addEventListener(MouseEvent.CLICK, unloadthis);
    	a_mc.removeEventListener(MouseEvent.CLICK, loadLeg);
    }
    
    function loadHouse(event:MouseEvent):void
    { 
    	this.addChild(swfholder);
    	swfholder.load(new URLRequest("04_23_pensions_re.swf")); //loads House swf
    	swfholder.x =0; 
    	swfholder.y =0; 
    	swfholder.width =880;
        swfholder.height =308;
    	b_mc.removeEventListener(MouseEvent.CLICK, loadHouse);
    	a_mc.addEventListener(MouseEvent.CLICK, unloadthis);
    }
    
    function unloadthis(event:Event):void
    {
    	removeChild(swfholder);
    	a_mc.addEventListener(MouseEvent.CLICK, loadLeg);
    	b_mc.addEventListener(MouseEvent.CLICK, loadHouse);
    }

  2. #2
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    HERE is the first half of the AS3 code for the first External I am trying to load into the above: (second half is not relative to the error just some button handling) These two externals involve DataGrids:
    Code:
    //* DATA GRID developed by ADVaughn *//
    
    import fl.controls.DataGrid;
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.controls.ScrollPolicy;
    
    var dp:DataProvider = new DataProvider();
    dp.addItem({State:"Alabama",Liability:41634554, Funded:074, Arc:1214983, Contributed:100})
    dp.addItem({State:"Alaska",Liability:15347768, Funded:061, Arc:268127, Contributed:110})
    dp.addItem({State:"Arizona",Liability:44078394, Funded:078, Arc:1141602, Contributed:101})
    dp.addItem({State:"Arkansas",Liability:22698906, Funded:078, Arc:534954, Contributed:103})
    
    
    
    var nameCol:DataGridColumn = new DataGridColumn("State");
    nameCol.headerText = "State";
    nameCol.width = 85;
    nameCol.cellRenderer = LeftAlignCell;
    
    
    var LiabilityCol:DataGridColumn = new DataGridColumn("Liability");
    LiabilityCol.headerText = "Liability";
    LiabilityCol.sortOptions = Array.NUMERIC;
    LiabilityCol.labelFunction = dollar1LabelFunction;
    LiabilityCol.cellRenderer = RightAlignCell;
    LiabilityCol.width = 85;
    
    var FundedCol:DataGridColumn = new DataGridColumn("Funded");
    FundedCol.headerText = "% Funded";
    FundedCol.sortOptions = Array.NUMERIC;
    FundedCol.labelFunction = percent1LabelFunction;
    FundedCol.cellRenderer = RightAlignCell;
    FundedCol.width = 55;
    
    var ArcCol:DataGridColumn = new DataGridColumn("Arc");
    ArcCol.headerText = "ARC";
    ArcCol.sortOptions = Array.NUMERIC;
    ArcCol.labelFunction = dollar2LabelFunction;
    ArcCol.cellRenderer = RightAlignCell;
    ArcCol.width = 75;
    
    var ContributedCol:DataGridColumn = new DataGridColumn("Contributed");
    ContributedCol.headerText = "% Contributed";
    ContributedCol.sortOptions = Array.NUMERIC;
    ContributedCol.labelFunction = percent2LabelFunction;
    ContributedCol.cellRenderer = RightAlignCell;
    ContributedCol.width = 65;
    
    var myDataGrid:DataGrid = new DataGrid();
    myDataGrid.addColumn(nameCol);
    myDataGrid.addColumn(LiabilityCol);
    myDataGrid.addColumn(FundedCol);
    myDataGrid.addColumn(ArcCol);
    myDataGrid.addColumn(ContributedCol);
    myDataGrid.dataProvider = dp;
    
    /* Format text*/
    var myTextFormat:TextFormat = new TextFormat();
    myTextFormat.font = "Arial";
    myTextFormat.align = "right";
    myTextFormat.color = 00000000;
    myTextFormat.size = 13;
    myDataGrid.setRendererStyle("textFormat",myTextFormat);
    myDataGrid.verticalScrollPolicy = ScrollPolicy.ON; 
    myDataGrid.width = 500;
    myDataGrid.height = 164;
    /*myDataGrid.rowCount = myDataGrid.length;*/
    myDataGrid.move(570, 102);
    
    function dollar1LabelFunction(item:Object):String {
        var myformatNumber=formatNumber(Number(Number(item.Liability).toFixed(0)));
    	return "$ " + myformatNumber;
    }
    function dollar2LabelFunction(item:Object):String {
    	var myformatNumber=formatNumber(Number(Number(item.Arc).toFixed(0)));
    	return "$ " + myformatNumber;
    }
    function percent1LabelFunction(item:Object):String {                                 
    return Number(item.Funded) + "%";                         
    } 
    
    function percent2LabelFunction(item:Object):String {                                 
    return Number(item.Contributed) + "%";                         
    }
    
    function formatNumber(number:Number):String
    {
    	var numString:String = number.toString() 
    	var result:String = '' 
    
    	while (numString.length > 3) 
    	{ 
    			var chunk:String = numString.substr(-3) 
    			numString = numString.substr(0, numString.length - 3) 
    			result = ',' + chunk + result 
    	} 
    
    	if (numString.length > 0) 
    	{ 
    			result = numString + result 
    	} 
    
    	return result 
    }
    
    
    addChild(myDataGrid);
    Last edited by ADVaughn; 04-23-2012 at 03:51 PM.

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    Maybe you should look at the details of the error, like what line it occurred on and the stack of function calls that led up to it. Since the error says "parameter CHILD", I'm educationally guessing that it's one of those functions, like addChild/removeChild/getChildByName.

    Also it would help to do a trace before each of those child functions so you'll know at which of those calls the variable is holding null instead of an object.

  4. #4
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    Here is the full error I get:

    Actionscript Code:
    TypeError: Error #2007: Parameter child must be non-null.
        at flash.display::DisplayObjectContainer/addChildAt()
        at fl.controls::BaseButton/drawBackground()
        at fl.controls::LabelButton/draw()
        at fl.core::UIComponent/drawNow()
        at fl.controls::DataGrid/drawList()
        at fl.controls::DataGrid/draw()
        at fl.core::UIComponent/callLaterDispatcher()

  5. #5
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    it craps out on this line in the CORE SWF:

    Code:
    swfholder.load(new URLRequest("04_23_pensions_pe.swf"));

  6. #6
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    Well unfortunately I have little experience with external swfs and the built in components. I don't know if external swfs have their own stage property or if they use the main swf's stage. Maybe you could check if swfholder has been added to the stage before it calls the load function.

  7. #7
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    Instantiation problem... fixed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com