A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] [as3]adding child

  1. #1
    Senior Member sybershot's Avatar
    Join Date
    Nov 2007
    Posts
    164

    resolved [RESOLVED] [as3]adding child

    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);

  2. #2
    Member
    Join Date
    Apr 2002
    Posts
    59
    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)

  3. #3
    Senior Member sybershot's Avatar
    Join Date
    Nov 2007
    Posts
    164
    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
    Code:
    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);
    Last edited by sybershot; 12-11-2008 at 01:04 AM.

  4. #4
    Senior Member sybershot's Avatar
    Join Date
    Nov 2007
    Posts
    164
    I'm all set I had a spelling error in drawig

  5. #5
    Member
    Join Date
    Apr 2002
    Posts
    59
    Would you be so kind as to post the final working version for anyone else's future reference?
    Thanks!

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