Scope and Adding Children

Hey guys, ok I have been trying to learn AS3 recently and I think I’m finally getting the hang of it. BUT… there’s one thing of which I’m unsure that I’m doing correctly and that’s adding children to the correct scope and obtaining it.

Here’s my example. I’m adding instances of a “Thumbnail” class which adds the library item “PhotoThumb” to the stage. So here’s part of my document class…
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]var[/COLOR] thisThumb:Thumbnail = [COLOR=#000000]new[/COLOR] Thumbnail[COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR], xPos, yPos[COLOR=#000000])[/COLOR];
[/LEFT]
[/FONT]

And here’s the Thumbnail class:
ActionScript Code:
[FONT=Courier New][LEFT]package com[COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]import[/COLOR] flash.[COLOR=#000080]events[/COLOR].[COLOR=#000080]Event[/COLOR];
[COLOR=#0000FF]import[/COLOR] flash.[COLOR=#000080]display[/COLOR].[COLOR=#000080]Sprite[/COLOR];

[COLOR=#0000FF]public[/COLOR] [COLOR=#000000]**class**[/COLOR] Thumbnail [COLOR=#0000FF]extends[/COLOR] Sprite [COLOR=#000000]{[/COLOR]
    [COLOR=#0000FF]public[/COLOR] [COLOR=#000000]**var**[/COLOR] _rootNode:[COLOR=#0000FF]Object[/COLOR];
    
    [COLOR=#0000FF]public[/COLOR] [COLOR=#000000]**function**[/COLOR] Thumbnail[COLOR=#000000]([/COLOR]rootNode:[COLOR=#0000FF]Object[/COLOR], xPos:[COLOR=#0000FF]int[/COLOR], yPos:[COLOR=#0000FF]int[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000FF]void[/COLOR] [COLOR=#000000]{[/COLOR]
        _rootNode = rootNode;
        
        [COLOR=#000000]**var**[/COLOR] thumb:PhotoThumb = [COLOR=#000000]**new**[/COLOR] PhotoThumb[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
        thumb.[COLOR=#000080]x[/COLOR] = xPos;
        thumb.[COLOR=#000080]y[/COLOR] = yPos;
        thumb.[COLOR=#000080]alpha[/COLOR] = [COLOR=#000080]0[/COLOR];
        thumb.[COLOR=#000080]mouseChildren[/COLOR] = [COLOR=#000000]**false**[/COLOR];
        thumb.[COLOR=#000080]buttonMode[/COLOR] = [COLOR=#000000]**true**[/COLOR];
        
        rootNode.[COLOR=#000080]addChild[/COLOR][COLOR=#000000]([/COLOR]thumb[COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]

So do you see the way I’m telling it where to add the object to? I pass “this” to the Thumbnail class and then create _rootNode from that and add the child to it. My main question is… is this the best way to do it? It seems like every time I want to add something to the stage, I’m using this method of sending a reference of “this” and using that as the place to “addChild”. It just seems a tad strange…

Second thing is, I just tried to do a quick test and put a dynamic textfield (without AS, just using the text tool and drawing onto the stage) and doing this alone without any code altering it caused the error…

“Property imageHolder not found on flash.text.TextField and there is no default value.” (PS: imageHolder is a movieclip inside the PhotoThumb mc). This made me think that I’m adding my thumbnails to the wrong place :frowning: Or maybe I’m doing ok and I just shouldn’t be textfields inside Flash? I don’t know! And slightly worried that I’m learning bad practices…

Please help!