A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: MovieClips array?

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    36

    Question MovieClips array?

    I'm creating multiple movieclips, containing a TextField and an image as a background. In order to keep track of them I'm storing them in an array. The problem is that I can't add the movieclip to the screen >.<

    What I'm doing is
    PHP Code:
    addChild(movieclips[0]); 
    but it's not displaying. I know it's not the movieclip as I can addChild that and it shows, but trying to call it out of the array is not working and it's REALLY frustrating the nark out of me

    How do I add the selected movieclip out of my array?

  2. #2
    Senior Member
    Join Date
    May 2004
    Posts
    226
    If it's not throwing an error then they are being added. Are you sure the container that is calling addChild is actually on the stage?

  3. #3
    Member
    Join Date
    Nov 2007
    Posts
    36
    it is the stage.
    When I addChild(movieclip) it works (it's in a loop so I get all the movieclips on stage at once), but when I try to get just one out of the array I get an empty screen

  4. #4
    Member
    Join Date
    Jul 2002
    Location
    Germany
    Posts
    31
    I'm doing exactly the same in a loop with buttons in an array "addChild(someArray[i]);" and it works perfect. Maybe you should post some more of your code?

  5. #5
    Member
    Join Date
    Nov 2007
    Posts
    36
    I think I sorted it.

    pseudo-code:
    for each page,
    movieclip:MovieClip = new MovieClip
    load page gubbins into movieclip
    save movieclip to array movieclips
    -
    add movieclips[0] to stage.

    The problem, as I can work it out, is that movieclip is a local variable and was being over-written, regardless of being added to the array at the end of each loop. The fix I used was to name the movie clips movieclipn where n is the loop number, and instead of keeping track of it in an array I just added all movieclips to the stage, keeping the ones I didn't want to see off the screen.

    Not the best solution, but it works...

Tags for this Thread

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