A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: addChild multiple mcs

  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    38

    addChild multiple mcs

    Previously the below worked for AS2

    Code:
    for(var i=0; i< rankArray.length; i++) {
    		var item:Object = this.itemMain.attachMovie("item", "item"+i, i);
    		item.alpha = 60;
    		item.ranked = false;
    		item.indexValue = (randomArray[i]+1)*2;
    Simply adding addChild comes back with 2 errors:

    Scene 1, Layer 'as', Frame 1, Line 47 1067: Implicit coercion of a value of type String to an unrelated type flash.displayisplayObject.

    and

    Scene 1, Layer 'as', Frame 1, Line 47 1137: Incorrect number of arguments. Expected no more than 1.

    How do I get this working with the addChild function?

    Thanks

    Eddie

  2. #2
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    where is your code that show you using addChild()?
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  3. #3
    Member
    Join Date
    Jan 2008
    Posts
    38
    Thats the problem, I am unable to successfully use addchild with this with my lack of AS3 knowledge, so when I do:

    Code:
    var item:Object = this.itemMain.addChild("item", "item"+i, i);
    I get the errors. Do I need to re structure the way I call my movie clips to get this to work?

    Thanks

    Eddie

  4. #4
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    You should check the flash doc's about how to use addChild()
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  5. #5
    Member
    Join Date
    Jan 2008
    Posts
    38
    I have used addchild successfully many times calling 1movie.clip but not in a loop as shown in code, I couldn't find help in a book which or through Google which is why I came on here to learn how to do this

    Eddie

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You have not had success using addChild while passing it two Strings and a number. addChild takes a DisplayObject.

    Read the docs
    http://help.adobe.com/en_US/FlashPla...addChild%28%29

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