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):
So I add the button/mc to the first slide - works just fine.Code:var goBtn:MovieClip = new FeatureButton(); features[0].addChild(goBtn); goBtn.x = 350; goBtn.y = 230;
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:
(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.Code:features[featureCount].removeChild(goBtn); goBtn = null;
So then I add the following next - exactly like I did in the beginning:
This time adding it to the current slide coming in - but this generates the following error:Code:var goBtn:MovieClip = new FeatureButton(); features[featureCount].addChild(goBtn); goBtn.x = 350; goBtn.y = 230;
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.Code:TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/removeChild() at featuregallery_fla::MainTimeline/nextFeature()
I can only guess this is a variable scoping issue with goBtn - but I'm not seeing how to resolve it. Flash file attached.




Reply With Quote