A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Parameter Child must be Non Null - Scope problem?

Threaded View

  1. #1
    Confounded Flash User
    Join Date
    Apr 2001
    Location
    Chicago
    Posts
    39

    Parameter Child must be Non Null - Scope problem?

    I'm working on a sliding gallery like Hulu.com. Got some help here in setting it up and the sliding slides in and out is working fine. However, I need to add and then remove a button to each slide as it comes in and goes out. (I initially tried including the button on each slide, a mc, but this proved problematic for the event listeners).

    So when the file loads up, I add a mc to the first slide of the group like so (features[] is an array of movie clips - my slides):

    Code:
    var goBtn:MovieClip = new FeatureButton();
    features[0].addChild(goBtn);
    goBtn.x = 350;
    goBtn.y = 230;
    So I add the button/mc to the first slide - works just fine.

    So there are two handlers, next and previous. So I started with the next handler. The first thing I have to do is kill the button on the panel that is sliding out, so I do that like so:

    Code:
    features[featureCount].removeChild(goBtn);
    goBtn = null;
    (featureCount is a counter keeping track of the slides). This works fine. I click the next button, and the button on the slide disappears and we move to the next slide - perfect.

    So then I add the following next - exactly like I did in the beginning:

    Code:
    var goBtn:MovieClip = new FeatureButton();
    features[featureCount].addChild(goBtn);
    goBtn.x = 350;
    goBtn.y = 230;
    This time adding it to the current slide coming in - but this generates the following error:

    Code:
    TypeError: Error #2007: Parameter child must be non-null.
    	at flash.display::DisplayObjectContainer/removeChild()
    	at featuregallery_fla::MainTimeline/nextFeature()
    Confusing - not sure how I'm getting an error on the removeChild() when that is already gone. I assume "parameter child" means goBtn - yes it is null because it's been removed. But I'm not trying to do something with that.

    I can only guess this is a variable scoping issue with goBtn - but I'm not seeing how to resolve it. Flash file attached.
    Attached Files Attached Files

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