dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Error Message when I refer to a movieclip that I can see is there!

  1. #1
    Junior Member
    Join Date
    Aug 2000
    Posts
    18

    Error Message when I refer to a movieclip that I can see is there!

    As usual, once I completed the hard stuff, this thing which should be so simple is kicking my butt. I have a series of panels which contain thumbnails of pictures. When you click an arrow, one container slides off the stage and the next one slides on. That part works great. However, when the new panel slides on, the main picture in the first thumbnail is also supposed to load on the stage. It loads just fine upon startup, but I get the following error message when I try to load it for subsequent panels:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.

    The offending line is this one:
    PHP Code:
    var thumbClip controls.bottomGroup.getChildByName("maskContainer").getChildByName(nextContainer).getChildByName("picClip" firstClip); 
    since when I trace it, I get the same error. Interestingly, if I leave off the final child and just trace the parent, I get "NULL", which I don't know now quite what to think about.

    Anyway, here's the relevant code. Any thoughts would be so helpful:

    PHP Code:
    function moveRight(curPage,nextPage) {
            var 
    curPage controls.bottomGroup.getChildByName("pageControl").selectedPage;
            var 
    nextPage curPage 1;
            var 
    curContainer controls.bottomGroup.getChildByName("maskContainer").getChildByName("container" curPage);
            var 
    nextContainer controls.bottomGroup.getChildByName("maskContainer").getChildByName("container" nextPage);
            var 
    onX curContainer.x;
            var 
    offX curContainer.curContainer.width 1;
            
    selectDot(nextPage);
            
    Tweener.addTween(curContainer, {xoffXtime:.5transition:"linear"});
            
    Tweener.addTween(nextContainer, {xonXtime:.5transition:"linear"});
            var 
    firstClip controls.bottomGroup.getChildByName("pageControl").getChildByName("page" nextPage).firstClipNum;
            var 
    thumbClip controls.bottomGroup.getChildByName("maskContainer").getChildByName(nextContainer).getChildByName("picClip" firstClip);
            
    trace("thumbClip: " thumbClip);
            
    loadMainPic(thumbClip,nextContainer);
        } 

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You are calling getChildByName(nextContainer). Since nextContainer is the result of a getChildByName call, it is either a DisplayObject or null. getChildByName requires a String argument. You cannot pass a DisplayObject to something that expects a String. This is why you should always type your variables.
    Anyway, since you did not get a "could not coerce DisplayObject to String" error, nextContainer is probably null. But then I'm confused as to why Tweener didn't throw a null error since you're trying to tween null.

    Maybe you meant getChildByName("nextContainer")?

    anyway. Type your variables.

  3. #3
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    I did go back and type my variable, but I figured out the problem. The problem is that I'm an idiot.

    I define nextContainer early in the function as this:
    PHP Code:
    var nextContainer controls.bottomGroup.getChildByName("maskContainer").getChildByName("container" nextPage); 
    and then later refer to it as this:
    PHP Code:
    controls.bottomGroup.getChildByName("maskContainer").getChildByName(nextContainer).getChildByName("picClip" firstClip); 
    basically nesting it twice. It couldn't find it because it wasn't there!

    Thanks for your help.

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