A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 41

Thread: random movie clip placement

  1. #21
    hmmm.... I wouldn't think that that script would take over fifteen seconds to execute unless you had a huge number of clips on the stage.

    What are you doing to make sure that your bee and buzzard and everything else clips each have there own depth range? you know what I mean? I assume you are doing something to ensure something like the following happens

    bees get produced at a depth of 1-100
    buzzards get produced at a depth of 101-200
    and so on...

    I have an inkling that it might have something to do with that. Let me know, and by the way this looks like it is going to be a pretty complex thing in the end. Quite a thing to take on for someone who is not already an actionscripting guru, but you are doing well so far, and there is no better way to learn in my opinion then to force yourself to build something you don't really know how to... I just hope I haven't impaired your learning with any of my help.

    Miitchell

  2. #22
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    50 clips.

    Miitchell:

    In my movie, there is potential for 310 clip instances total. There are 6 groups with a maximum of 50 clips available by clicking. (You'd be in pain clicking that much though.) There's one group with 10 available. But when I ran the movie, I only had maybe 25 buzzards and 25 bees on the stage. And the error pointed directly at the script. (It must have been the checkHits script because I haven't seen such an error previously.)

    Maybe optimizing my code will help? I could decrease the available number of clips, but this wasn't a problem before...and at this point I'm only hitTesting the birds and the bees. (two groups...one of 10 clips, one of 50 max).

    You're definetely not doing me any harm by helping me with this. In fact, it's a great help. Thanks.

    -cl




  3. #23
    so what are you doing to ensure that the different types of clips (bees,birds,flowers) are not ending up in the same depth? Do you understand my question?

    Miitchell

  4. #24
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    no problem with the levels

    They are staggered. 5-50,51-100,101-150,151-200, etc...up to 351.

    -cl

  5. #25
    the thing I am trying to find out is that when I first gave you the example function for generating the bees it was using the beeCount added to the end of "bee_animation" to set the name of each instance. So I am guessing that they way you used the same basic function but with the necessary changes to generate the birds and whatever else. so you would have had a beeCount, birdCount, flowerOneCount and so on... and you would have had a function generateBees(), generateBirds, generateFlowers(), and so on with that. I am just taking a guess at all of this, so am I right?

    now if you did do that then the easiest way to make sure they are staggered depths would to have been to start your beeCount off at 0, and then start birdCount off at 50, flowerCount off at 100. Like I said, I don't know, just trying to find out. But if you did do this it would mess up the checkHits() function I gave you. Hey i could be way off here But I have checked all the code that I have given you and it works for me. Let me know...

    Miitchell

  6. #26
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    you're right

    You just described exactly what I did.

    I understand that the checkHits code that you gave me will not check all of those groups of duplicated characters, but why would it mess things up?

    -cl

    Check it out:

    http://jellybean.parsons.edu/~ntaylo...face_demo.html

    (The checkHits code isn't in there because as I said, it crashed the Flash Player.)

  7. #27
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    you got it

    You just described exactly what I did.

    I understand that the checkHits code that you gave me will not check all of those groups of duplicated characters, but why would it mess things up?

    -cl

    Check it out:

    http://jellybean.parsons.edu/~ntaylo...face_demo.html

    (The checkHits code isn't in there because as I said, it crashed the Flash Player.)

  8. #28
    well you said that it was giving you the error that a script was taking over 15 seconds to execute and that if you continued to let it run then it might bog your system down, right?

    I am getting at this because it shouldn't take over fifteen seconds to execute the script unless you have quite a lot of instances on the screen. The checkHits function I gave loops a certain number of times based on the bee and bird counts. So if you ,to get the depth staggered, simply start the birdCount off at 50 then the checkHit function will right of the bat think that there are at least 50 birds generated and will be doing a lot more processing then it needs to. You can find out how many times it will loop each time it is called with simple multiplication. If you have 10 bees out and 3 birds out then it loops 30 times each frame (3 * 10) so you can see that if from the very start the bird count is 50 then as soon as you ad one bee the script will loop 50 times every frame. Like I said originally this could get boggy if you had a lot of clips generated. But it should at least work. I suggest you try this. Instead of initially setting the birdCount to 50 and flowerCount to 100 make an depthOffset variable for each of them. so you would start things out more like this:

    beeCount = 0;
    beeDepthOffset = 0;
    birdCount = 0;
    birdDepthOffset = 51;
    flowerCount = 0;
    flowerDepthOffset = 101;

    and then modify your generate functions so that when they set the depth of whatever they are generating it offsets it with the offset value, like so...

    _root.attachMovie("bird",currentBird, birdCount+birdDepthOffset);

    see what I am saying, this way your beeCount and birdCount and all the other counts will actually correspond to how many instances there are, but the depths will still be staggered. This should hopefully make the the checkHits function work, as long as you don't put a dung load of clips out on the stage. Give it a try and let me know how it goes.

    Miitchell

  9. #29
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    Whew. That works.

    The bees disappear when the birds fly over them. Thanks. That makes alot of sense. Set the count to 0 and then create another variable that holds your level for you. Add the two together. Very logical. Thank you. These aren't hard concepts, it just a question of being shown how to execute them.

    I have another question.

    My menus are weird. When I double click on the bird menu, I get the flower menu. When I double click on the flower menu I get the help menu. When I double click on the help menu, the help menu closes itself.

    How can I get all of them to close themselves when double clicked on. I'd like to make them uniform, not so whacky.

    -cl

  10. #30
    I think that last question should be within your ability, so I'm gonna leave that to you. Good luck...
    Miitchell

  11. #31
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    actually i got it already...

    thanks so much.

    -cL

  12. #32
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    function checkHits array code optimization

    Miitchell:

    With a little help, I've changed the checkHits function to a 2D array. I'm not getting errors, but it's also not working. Do you mind giving it a quick look to see if anything glaring stands out?

    (No rush...you've already been such a help, I feel like I'm stretching it to ask another question.)

    -cL



    myInteractions = new Array();

    myInteractions[0] = new Array("buzzard","bee_animation","eat");
    myInteractions[1] = new Array("spider1","bee_animation","eat");
    myInteractions[2] = new Array("aster","bee_animation","happy");
    myInteractions[3] = new Array("blackberry","bee_animation","happy");
    myInteractions[4] = new Array("rose","bee_animation","happy");
    myInteractions[5] = new Array("buzzard","spider1","eat");
    myInteractions[6] = new Array("poison_ivy1","bee_animation","happy");

    function checkHits(){
    //for each interaction

    //loop through the list
    counter = 0;
    countermax = myInteractions.length;
    while (counter < countermax){
    critterA = myInteractions[counter][0];
    critterB = myInteractions[counter][1];
    myRelationship = myInteractions[counter][2];

    for (var i=_root[critterA+"Count"]; i>0; i--){
    for(var j=_root[critterB+"Count"]; j>0; j--){
    if(_root[critterA+i].hitTest(_root[critterB+j])){
    if (myRelationship == "eat"){
    removeMovieClip(_root[critterB+j]);
    if (_root[critterA+i]._xscale < 2000){
    _root[critterA+i]._xscale = _root[critterA+i]._xscale*1.2;
    _root[critterA+i]._yscale = _root[critterA+i]._yscale*1.2;
    }
    } else if(myRelationship == "happy"){
    if (_root[critterA+i]._xscale < 2000){
    _root[critterA+i]._xscale = _root[critterA+i]._xscale*1.2;
    _root[critterA+i]._yscale = _root[critterA+i]._yscale*1.2;
    }
    if (_root[critterB+j]._xscale < 2000){
    _root[critterB+j]._xscale = _root[critterB+j]._xscale*1.2;
    _root[critterB+j]._yscale = _root[critterB+j]._yscale*1.2;
    }
    }
    }
    }
    }
    counter++;
    }

    }

  13. #33
    hmmm... it all looks pretty clean to me. maybe i'll check it out again later, but I don't see anything for now.

  14. #34
    Hey cheeky, I was wondering if you could do me a quick favor and check this thing I just built. I have built a smart clip that I want to use for loading external swfs, now as you may know you cannot uses the bandwith profiler to test a movie when you are loading external swfs. I think it is working but I am not sure, basically you should see three little boxes and an upside down L. the three little boxes are my button/swf loader smartclips. they should show a little progress meter that builds up and when it is done you can click on it and it will show the swf it loaded. and they should take turns, meaning that the you should see the first one fill up then the second then the third. If you could check this out for me I would really appreciate it. Also if you want to try at test it again you will need to clear your temporary internet files and then refresh the page. here is the address

    http://209.219.12.200/dev/mitchell/swfLoader/main.html

    Let me know how it goes,
    Miitchell

  15. #35
    oh and let me know what kind of connection you are on too...

  16. #36
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    56k

    Miitchell:

    I'm on a 56k. And...as far as I can see, it's working. There are three squares. One fills up with lines and then I clicked. The first chic came up. Then the second box filled with lines. And I clicked and that chic pic came up. Then the other box filled with lines....same deal.

    You have to click on the boxes to get the chic pics.

    I hope that this answers your question. (?)

    Cheers.

    -cL

  17. #37
    hey, thanks a lot, sounds like they are working just fine. sorry I couldn't see anything wrong with that code of yours, any luck lately?

    Miitchell

  18. #38
    well, actually could you give me some details on the thing I had you check... did they boxes fill up bit by bit or did they all of a sudden snap to full?

  19. #39
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    the boxes...

    snapped to full...

    The code is fine (the code I optimized) but I think another part of the movie is tweeking it. Some kind of crossed-purpose thing. I can't look at it right now. I've been looking at it too much!

    Let me know if you need me to check anything else for ya.

    -cL

  20. #40
    Senior Member
    Join Date
    Dec 2000
    Posts
    200

    ok.

    I need to change this code. As it is, my movie clips enlarge endlessly if their realtionship is "happy". I need to have a limit to it. I need to have them be removed once they enlarge to a reasonable size.

    Could you give me some advice about how I should add to this code to achieve that?

    I have a general idea, but I slouch through the code.

    -cL

    p.s. let me know if I can check anymore stuff for you...i'd like to repay all the code suggestion favors you've done.



    myInteractions = new Array();

    myInteractions[0] = new Array("buzzard","bee_animation","eat");
    myInteractions[1] = new Array("spider1","bee_animation","eat");
    myInteractions[2] = new Array("aster","bee_animation","happy");
    myInteractions[3] = new Array("blackberry","bee_animation","happy");
    myInteractions[4] = new Array("rose","bee_animation","happy");
    myInteractions[5] = new Array("buzzard","spider1","eat");
    myInteractions[6] = new Array("poison_ivy1","bee_animation","happy");

    function checkHits(){
    //for each interaction

    //loop through the list
    counter = 0;
    countermax = myInteractions.length;
    while (counter < countermax){
    critterA = myInteractions[counter][0];
    critterB = myInteractions[counter][1];
    myRelationship = myInteractions[counter][2];

    for (var i=_root[critterA+"Count"]; i>0; i--){
    for(var j=_root[critterB+"Count"]; j>0; j--){
    if(_root[critterA+i].hitTest(_root[critterB+j])){
    if (myRelationship == "eat"){
    removeMovieClip(_root[critterB+j]);
    if (_root[critterA+i]._xscale < 200){
    _root[critterA+i]._xscale = _root[critterA+i]._xscale*1.01;
    _root[critterA+i]._yscale = _root[critterA+i]._yscale*1.01;
    }
    } else if(myRelationship == "happy"){
    if (_root[critterA+i]._xscale < 200){
    _root[critterA+i]._xscale = _root[critterA+i]._xscale*1.01;
    _root[critterA+i]._yscale = _root[critterA+i]._yscale*1.01;
    }
    if (_root[critterB+j]._xscale < 200){
    _root[critterB+j]._xscale = _root[critterB+j]._xscale*1.01;
    _root[critterB+j]._yscale = _root[critterB+j]._yscale*1.01;
    }
    }
    }
    }
    }
    counter++;
    }

    }

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