Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd a movieclip but make sure it isn't in the same place as another movieclip. (as3)
    primarykey
    data
    text
    <p>So I have <a href="http://www.fastswf.com/cq_200M" rel="nofollow">this</a> where you add movieclips by clicking, but it is unefficient and doesn't have some functionality that I want, I need to only add the movieclip if no other movieclip is in the same place. </p> <pre><code>private function onClick():void { if(placesound==false) { placepixel.play(); placesound = true; } if(erasetrue==false) { var pixel = new Pixel(); pixel.x = 0; pixel.y = 0; } if(mouseY&gt;30 &amp;&amp; irontrue==true) { //var pixel = new Pixel(); pixel.x=(Math.round(mouseX/5)*5)-2.5; pixel.y=(Math.round(mouseY/5)*5)-2.5; pixel.graphics.beginFill(0x999999); pixel.graphics.drawRect(0, 0, 5, 5); pixel.graphics.endFill(); pixel.type=0; pix.push(pixel); //addChild(pixel); } if(mouseY&gt;30 &amp;&amp; woodtrue==true) { //var pixel = new Pixel(); pixel.x=(Math.round(mouseX/5)*5)-2.5; pixel.y=(Math.round(mouseY/5)*5)-2.5; pixel.graphics.beginFill(0x996600); pixel.graphics.drawRect(0, 0, 5, 5); pixel.graphics.endFill(); pixel.type=3; pix.push(pixel); //addChild(pixel); } if(erasetrue==true) { for (i=pix.length-1; i&gt;=0; i--) { if(pix[i].x==(Math.round(mouseX/5)*5)-2.5 &amp;&amp; pix[i].y==(Math.round(mouseY/5)*5)-2.5) { removeChild(pix[i]); pix.splice(i, 1); } } } if(mouseY&gt;30 &amp;&amp; springtrue==true) { //var pixel = new Pixel(); pixel.x=(Math.round(mouseX/5)*5)-2.5; pixel.y=(Math.round(mouseY/5)*5)-2.5; pixel.graphics.beginFill(0x000000); pixel.graphics.drawRect(0, 0, 5, 5); pixel.graphics.endFill(); pixel.type=1; pix.push(pixel); //addChild(pixel); } if(mouseY&gt;30 &amp;&amp; portaltrue==true) { //var pixel = new Pixel(); pixel.x=(Math.round(mouseX/5)*5)-2.5; pixel.y=(Math.round(mouseY/5)*5)-2.5; pixel.graphics.beginFill(0x9999FF); pixel.graphics.drawRect(0, 0, 5, 5); pixel.graphics.endFill(); pixel.type=2; pix.push(pixel); //addChild(pixel); } if(erasetrue==false) { addChild(pixel); } } </code></pre> <p>I want to somehow only run the last if (the one that addChilds the pixel.) only if no other movieclip (see the array "pix") has is already in the spot it would be placed in. (I round the mouse before placing it.</p> <p>Thanks for any help.</p> <p>Edit: Spoilers failed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload