;

PDA

Click to See Complete Forum and Search --> : [RESOLVED] [as3]adding child


sybershot
12-10-2008, 04:50 PM
I'm failing to add 2 dynamic created movie clips "sb and contents" to dynamic created movie clip "scrollbox" any assistance would be greatly apreciated thanks sincerly sybershot

var scrollbox:MovieClip = new MovieClip();
this.scrollbox.x = 50;
this.scrollbox.y =50;
this.scrollbox.width = 340;
this.scrollbox.height =520;
this.scrollbox.addChild(sb);
this.scrollbox.addChild(contents);
this.addChild(scrollbox);

tacroy
12-10-2008, 05:14 PM
I don't believe that you can add a symbol straight out of the library.
You have to give the symbol a linkage (class name) then create a new instance of the class, then add that instance as child.

IE.
var scrollbox:MovieClip = new MovieClip();
this.scrollbox.x = 50;
this.scrollbox.y =50;
this.scrollbox.width = 340;
this.scrollbox.height =520;

var sb1 = new sb(); // sb being the linkage name in the library
this.scrollbox.addChild(sb1); // you then reference it by the "new" name
this.addChild(scrollbox)

sybershot
12-10-2008, 06:40 PM
thank you very much tacroy
what I'm trying to do still is not working,
broken down code below is what I have sofar
again any help will be greatly apreciated thanks sincerly sybershot

var track:MovieClip = new MovieClip();
//a shape is drawn with script but removed to shorten
var thumb:MovieClip = new MovieClip();
//a shape is drawn with script but removed to shorten

var sb:MovieClip = new MovieClip();
// nest "track & thumb" into sb
var sb0 = new track();
this.scrollbox.addChild(sb0);
var sb1 = new thumb();
this.scrollbox.addChild(sb1);

var scrollbox:MovieClip = new MovieClip();
//nest sb into scrollbox and add scrollbox to stage
var sb2 = new sb();
this.scrollbox.addChild(sb2);
this.addChild(scrollbox);

sybershot
12-11-2008, 01:35 AM
I'm all set I had a spelling error in drawig

tacroy
12-11-2008, 01:15 PM
Would you be so kind as to post the final working version for anyone else's future reference?
Thanks!