SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maine
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trouble with attachMovie

    I've been working with flash and action script for about 2 weeks now. Having a decent c++ background has really helped the learning curve but I'm having some difficulty working with the attachMovie method. Below is a cut of code that isn't working the way I thought it would.

    Here's the deal. I'm trying to place 10 movie clips accross the screen in my main movie. Here's the code that I thought would do that.
    Code:
    function layBoxes(){
    	for(var i = 0; i < 10; i++){
    		var boxName = "box" + i;
    		boxArray[i] = attachMovie( "box", boxName, 3, {_x: 40 + 40 * i, _y: 30});
    	}
    }
    box is the exported symbol name of the movie clip I'd like to tile accross the top of the screen.
    boxArray[10] holds my referances to each box for easier hitTesting.
    This is basically being used for a "brickout" type game and these are the boxes I'm planning on hitting.

    Now, when I run this code, it displays the last movie I attached (box9) and the rest are missing. Where did they go?? only box9 appears in the debug tool under _level0.box9. There are no removeMovieClip statements in my code so how could they all dissapear?

    I've looked for answers in "Actionscript for Flash MX, The definitive Guide" but maybe I'm overlooking somthing. The flash F1 help pages are usually a half-way decent source of info and tid-bits but I couldn't find anything there either.

    Thanks in advance for any help you can offer.
    -Jason

  2. #2
    SitePoint Guru MG315's Avatar
    Join Date
    Mar 2003
    Location
    Houston, Texas
    Posts
    758
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you tried making the depth (in this case 3) i? maybe because theyre loading into the same level its somehow messing it up. if you made it i, they would load on a layer above each time (unless you didnt want them separated like that for some reason)

    i dont see any problems in your code though. if that doesnt work, you might try using a while() condition


    function layBoxes(){
    i=0;
    while(i<10){
    var boxName = "box" + i;
    boxArray[i] = attachMovie( "box", boxName, i, {_x: 40 + 40 * i, _y: 30});
    i++
    }
    }

  3. #3
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maine
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    putting each clip on its own depth level seems to work. I thought Flash allowed as many movie clips on each level as you want. well, putting each on a seporate level works for now I guess.

    Thanks for the help MG315
    -Jason


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •