# Pipeline

**URL:** <https://forum.kirupa.com/t/pipeline/261321>\
**Category:** Uncategorized\
**Created:** [May 26, 2008, 11:46am UTC](https://forum.kirupa.com/t/pipeline/261321 "2008-05-26T11:46:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 26, 2008, 11:46am UTC](https://forum.kirupa.com/t/pipeline/261321/1 "2008-05-26T11:46:19Z")

</div>

[http://www.flash-game.net/game/2267/balloon-parky.html](http://www.flash-game.net/game/2267/balloon-parky.html)  
i am trying to develop this type of game so i dont want

to write hitTest on every clips , is ther any other logic which can help to connect the pipes and change their color when they are connected with each other , pipes can be randomly placed within tiles…any help

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [May 26, 2008, 12:08pm UTC](https://forum.kirupa.com/t/pipeline/261321/2 "2008-05-26T12:08:55Z")

</div>

i’d say use an array

for eg;

```auto
var pipes:Array = [
[0, 0, 0, 1, 0, 0, 1, 0, 1],
[0, 0, 0, 1, 1, 1, 1, 0, 1],
[0, 0, 0, 0, 0, 1, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 1]
];

```

Where the value 1 will represent a block of pipe; then check if there’s a value of 1 before or after, or in the corresponding items in the previous or following arrays.

---

<div class="post-metadata">

**Author:** ![rrh](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rrh](https://forum.kirupa.com/u/rrh)\
**Post date:** [May 26, 2008, 3:41pm UTC](https://forum.kirupa.com/t/pipeline/261321/3 "2008-05-26T15:41:36Z")

</div>

Hittest? I wouldn’t have even thought of using hittest for this, so I really don’t grok how you’re approaching this.

I would have a square array of pipes, but not just numbers like nathan did. I would make a pipe class, with a rotate method, and four methods that return values for top, bottom, right, left. And also a change colour method, which is passed a direction and a colour value. If it is open in that direction and it is not already that colour, it changes colour and calls the change colour method on all tiles it is connected to.

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [May 27, 2008, 12:20am UTC](https://forum.kirupa.com/t/pipeline/261321/4 "2008-05-27T00:20:46Z")

</div>

O I didn’t look at the link - so it’s different to what I originally thought - If I get time I’ll make a demo

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 27, 2008, 6:16am UTC](https://forum.kirupa.com/t/pipeline/261321/5 "2008-05-27T06:16:17Z")

</div>

[quote=rrh;2331317]Hittest? I wouldn’t have even thought of using hittest for this, so I really don’t grok how you’re approaching this.

I would have a square array of pipes, but not just numbers like nathan did. I would make a pipe class, with a rotate method, and four methods that return values for top, bottom, right, left. And also a change colour method, which is passed a direction and a colour value. If it is open in that direction and it is not already that colour, it changes colour and calls the change colour method on all tiles it is connected to.[/quote]

can you show me the demo …

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 27, 2008, 6:37am UTC](https://forum.kirupa.com/t/pipeline/261321/6 "2008-05-27T06:37:22Z")

</div>

[quote=nathan99;2331258]i’d say use an array

for eg;  
ActionScript Code:  
[LEFT][COLOR=#000000] **var** [/COLOR] pipes:[COLOR=#0000FF]Array[/COLOR] = [COLOR=#000000][[/COLOR]  
[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR],  
[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR],  
[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR],  
[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR],  
[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR],  
[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR]  
[COLOR=#000000]][/COLOR];

[/LEFT]

Where the value 1 will represent a block of pipe; then check if there’s a value of 1 before or after, or in the corresponding items in the previous or following arrays.[/quote]

but i want to rotate the pipe when user click on that, 1 shows the existence of pipe now how to rotate with diff shapes…

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 27, 2008, 10:16am UTC](https://forum.kirupa.com/t/pipeline/261321/7 "2008-05-27T10:16:25Z")

</div>

> [@rahul\_7star;2331550](#):
>
> but i want to rotate the pipe when user click on that, 1 shows the existence of pipe now how to rotate with diff shapes…

here is my fla

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 28, 2008, 5:32am UTC](https://forum.kirupa.com/t/pipeline/261321/8 "2008-05-28T05:32:11Z")

</div>

> [@rahul\_7star;2331602](#):
>
> here is my fla

i got the solutions .

---

<div class="post-metadata">

**Author:** ![ArmoredSandwich](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ArmoredSandwich](https://forum.kirupa.com/u/ArmoredSandwich)\
**Post date:** [May 28, 2008, 4:50pm UTC](https://forum.kirupa.com/t/pipeline/261321/9 "2008-05-28T16:50:09Z")

</div>

> [@rahul\_7star;2332157](#):
>
> i got the solutions .

That’s a pretty cool monologue you have there.

I think you should post the “solutions” you have for people that might find this topic in a search, looking for the same problem.

---

<div class="post-metadata">

**Author:** ![neilmmm](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@neilmmm](https://forum.kirupa.com/u/neilmmm)\
**Post date:** [May 28, 2008, 8:41pm UTC](https://forum.kirupa.com/t/pipeline/261321/10 "2008-05-28T20:41:48Z")

</div>

**rahul\_7star** is there any chance you could post your file in flash 8

thanks

neil

---

<div class="post-metadata">

**Author:** ![misterooga](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@misterooga](https://forum.kirupa.com/u/misterooga)\
**Post date:** [May 28, 2008, 9:03pm UTC](https://forum.kirupa.com/t/pipeline/261321/11 "2008-05-28T21:03:06Z")

</div>

> [@rahul\_7star;2331550](#):
>
> but i want to rotate the pipe when user click on that, 1 shows the existence of pipe now how to rotate with diff shapes…

That’s if you are only talking about binary array… You can use rest of whatever is flash’s integer values.

Considering the pipes rotate in one direction, this is very easy.

You can say,

0 = empty space  
1 = horizontal pipe  
10 = elbow pipe  
20 = cross pipe

then,

2 = horizontal pipe in vertical position  
11 = elbow pipe from top to left  
12 = elbow pipe from left to down  
13 = elbow pipe from down to right  
14 = elbow pipe from right to top

and you can even make use of other numbers…

111 = elbow pipe from top to left in blue color  
211 = elbow pipe from top to left in yellow colour.

… so in the end, it’s all how you set the convention.

When you are checking if a path exist, you just have to check if one of the gas outlet is linked with, say, any pipe line with values greater than 100 or 200…etc.

So to use the array example above, following will be a winning combo

```auto

pipes:Array = [
[101, 0, 0, 1, 0, 0, 1, 0, 201],
[0, 0, 0, 1, 1, 1, 1, 0, 201],
[0, 0, 113, 101, 101, 101, 101, 101, 201],
[101, 101, 111, 1, 1, 1, 1, 1, 201],
[0, 0, 0, 0, 0, 0, 0, 0, 201],
[0, 0, 0, 0, 0, 0, 0, 0, 201]
];

```

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 29, 2008, 10:19am UTC](https://forum.kirupa.com/t/pipeline/261321/12 "2008-05-29T10:19:51Z")

</div>

[quote=misterooga;2332646]That’s if you are only talking about binary array… You can use rest of whatever is flash’s integer values.

Considering the pipes rotate in one direction, this is very easy.

You can say,

0 = empty space  
1 = horizontal pipe  
10 = elbow pipe  
20 = cross pipe

then,

2 = horizontal pipe in vertical position  
11 = elbow pipe from top to left  
12 = elbow pipe from left to down  
13 = elbow pipe from down to right  
14 = elbow pipe from right to top

and you can even make use of other numbers…

111 = elbow pipe from top to left in blue color  
211 = elbow pipe from top to left in yellow colour.

… so in the end, it’s all how you set the convention.

When you are checking if a path exist, you just have to check if one of the gas outlet is linked with, say, any pipe line with values greater than 100 or 200…etc.

So to use the array example above, following will be a winning combo

```auto

pipes:Array = [
[101, 0, 0, 1, 0, 0, 1, 0, 201],
[0, 0, 0, 1, 1, 1, 1, 0, 201],
[0, 0, 113, 101, 101, 101, 101, 101, 201],
[101, 101, 111, 1, 1, 1, 1, 1, 201],
[0, 0, 0, 0, 0, 0, 0, 0, 201],
[0, 0, 0, 0, 0, 0, 0, 0, 201]
];

```

[/quote]

Thanks for this reply , but its ok that you can place pipe of any size either “L” shape or “U"shape , but the problem is that whenevr you click on 'U” shape U should move and should not call “L” shape, here is my fla …chk it.

whenver you click on “I” shape “I” should move in corresponding direction and it should not call U shape …

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 29, 2008, 10:36am UTC](https://forum.kirupa.com/t/pipeline/261321/13 "2008-05-29T10:36:44Z")

</div>

a

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 29, 2008, 4:46pm UTC](https://forum.kirupa.com/t/pipeline/261321/14 "2008-05-29T16:46:23Z")

</div>

[quote=neilmmm;2332628] **rahul\_7star** is there any chance you could post your file in flash 8

thanks

neil[/quote]

HI here is flash 8 fla

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 30, 2008, 5:28pm UTC](https://forum.kirupa.com/t/pipeline/261321/15 "2008-05-30T17:28:27Z")

</div>

[quote=misterooga;2332646]That’s if you are only talking about binary array… You can use rest of whatever is flash’s integer values.

Considering the pipes rotate in one direction, this is very easy.

You can say,

0 = empty space  
1 = horizontal pipe  
10 = elbow pipe  
20 = cross pipe

then,

2 = horizontal pipe in vertical position  
11 = elbow pipe from top to left  
12 = elbow pipe from left to down  
13 = elbow pipe from down to right  
14 = elbow pipe from right to top

and you can even make use of other numbers…

111 = elbow pipe from top to left in blue color  
211 = elbow pipe from top to left in yellow colour.

… so in the end, it’s all how you set the convention.

When you are checking if a path exist, you just have to check if one of the gas outlet is linked with, say, any pipe line with values greater than 100 or 200…etc.

So to use the array example above, following will be a winning combo

```auto

pipes:Array = [
[101, 0, 0, 1, 0, 0, 1, 0, 201],
[0, 0, 0, 1, 1, 1, 1, 0, 201],
[0, 0, 113, 101, 101, 101, 101, 101, 201],
[101, 101, 111, 1, 1, 1, 1, 1, 201],
[0, 0, 0, 0, 0, 0, 0, 0, 201],
[0, 0, 0, 0, 0, 0, 0, 0, 201]
];

```

[/quote]

2 = horizontal pipe in vertical position  
11 = elbow pipe from top to left  
12 = elbow pipe from left to down  
13 = elbow pipe from down to right  
14 = elbow pipe from right to top

these are just frame number i thnk…is it…!

---

<div class="post-metadata">

**Author:** ![neilmmm](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@neilmmm](https://forum.kirupa.com/u/neilmmm)\
**Post date:** [May 30, 2008, 5:31pm UTC](https://forum.kirupa.com/t/pipeline/261321/16 "2008-05-30T17:31:38Z")

</div>

ty for the file

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 30, 2008, 5:43pm UTC](https://forum.kirupa.com/t/pipeline/261321/17 "2008-05-30T17:43:45Z")

</div>

what is that[quote=neilmmm;2333711]ty for the file[/quote]

---

<div class="post-metadata">

**Author:** ![misterooga](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@misterooga](https://forum.kirupa.com/u/misterooga)\
**Post date:** [May 30, 2008, 5:55pm UTC](https://forum.kirupa.com/t/pipeline/261321/18 "2008-05-30T17:55:42Z")

</div>

[quote=rahul\_7star;2333705]2 = horizontal pipe in vertical position  
11 = elbow pipe from top to left  
12 = elbow pipe from left to down  
13 = elbow pipe from down to right  
14 = elbow pipe from right to top

these are just frame number i thnk…is it…![/quote]

Yes, I have been thinking in copyPixel too much lately… haha.

---

<div class="post-metadata">

**Author:** ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)\
**Post date:** [May 30, 2008, 5:57pm UTC](https://forum.kirupa.com/t/pipeline/261321/19 "2008-05-30T17:57:36Z")

</div>

plz see my Fla , i need help ,[quote=misterooga;2333734]Yes, I have been thinking in copyPixel too much lately… haha.[/quote]

---

<div class="post-metadata">

**Author:** ![neilmmm](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@neilmmm](https://forum.kirupa.com/u/neilmmm)\
**Post date:** [May 30, 2008, 9:11pm UTC](https://forum.kirupa.com/t/pipeline/261321/20 "2008-05-30T21:11:28Z")

</div>

i like the game and have had a go … gone in a completely different direction … i don’t think it is the right direction

but here is my code … perhaps someone will respnd to help move it on

```auto
var counter:Number = 0;
var mc_id:Number;
var mcConnectionArray:Array=new Array();
var tempArray:Array=newArray();
var mc_type:String;
var empty:MovieClip=this.createEmptyMovieClip("holder",this.getNextHighestDepth());
var target_mc:MovieClip;
function checkleft (target) {
 //trace("checkleft called");
 //trace (empty["pipe"+target]._name)
 //trace ("target array ="+empty["pipe"+target].mcConnectionArray.length)
 /*for (k=0;k<empty["pipe"+target].mcConnectionArray.length;k++) {
  trace(empty["pipe"+target].mcConnectionArray[k])
}
for (i=0;i<tempArray.length;i++) {
 trace (" checking left fornd tempArray = "+tempArray*);
}*/
//if (empty["pipe"+target].mc_type=="straight") {
 if (empty["pipe"+target].mcConnectionArray[1]=="right"&&empty["pipe"+(target+1)].mcConnectionArray[3]=="left") {
  trace("yep");
  trace ("cuurent frame ="+empty["pipe"+(target+1)]._currentframe);
  empty["pipe"+(target+1)].gotoAndStop(2);
}else{
 trace("no");
 empty["pipe"+(target+1)].gotoAndStop(1);
}

//}
}
 
function spinPipe () {
 
 for (k=0;k<this.mcConnectionArray.length;k++) {
  //trace(this.mcConnectionArray[k])
}
 this._rotation+=90;
 
 if (this._rotation==0) {
  //trace ("rotation =0");
  this.mcConnectionArray=["top","right","no","no"];
}else if(this._rotation==90){
 //trace ("rotation =90");
 this.mcConnectionArray=["no","right","bottom","no"];
}else if(this._rotation==180){
 //trace ("rotation =180");
 this.mcConnectionArray=["no","no","bottom","left"];
}else{
 //trace ("rotation =-90");
 this.mcConnectionArray=["top","no","no","left"];
}
 tempArray=[];
 
 //trace(this.mc_id);
 //trace(this._rotation);
 for (k=0;k<this.mcConnectionArray.length;k++) {
  //trace(this.mcConnectionArray[k])
  tempArray.push(this.mcConnectionArray[k]);
  //trace("tempArray "+k+" = "+tempArray[k]);
}
trace("");
trace(this._name);
trace (this.mc_id-1)
checkleft(this.mc_id-1);
 
 
}
for (i=0; i<10; i++) {
 for (j=0; j<10; j++) {
  counter++;
  if (j==0) {
   var mc:MovieClip = empty.attachMovie("straightPipe", "pipe"+counter, counter);
  mc._x = mc._width*j;
  mc._y = mc._height*i;
  mc.mc_type="straight";
  mc.gotoAndStop(2);
mc.mcConnectionArray=["no","right","no","left"];
  
  mc._rotation=90;
  mc.mc_id=counter;
  //mc.onRelease=spinPipe;
   
   
}else if (j==9){
var mc:MovieClip = empty.attachMovie("straightPipe", "pipe"+counter, counter);
  mc._x = mc._width*j;
  mc._y = mc._height*i;
  mc.mc_type="straight";
  mc.gotoAndStop(3);
mc.mcConnectionArray=["no","right","no","left"];;
  
  mc._rotation=90;
  mc.mc_id=counter;
}else{
  var mc:MovieClip = empty.attachMovie("elbowPipe", "pipe"+counter, counter);
  mc._x = mc._width*j;
  mc._y = mc._height*i;
  mc.mc_type="elbow";
  mc._rotation=(Math.floor(Math.random()*4)*90);
  mc.mc_id=counter;
  //// add rotatio id
  if (mc._rotation==0) {
  
  mc.mcConnectionArray=["top","right","no","no"];
}else if(mc._rotation==90){
 
 mc.mcConnectionArray=["no","right","bottom","no"];
}else if(mc._rotation==180){
 
 mc.mcConnectionArray=["no","no","bottom","left"];
}else{
 
 mc.mcConnectionArray=["top","no","no","left"];
}
  
  
  /// end rotation id
  mc.onRelease=spinPipe;
}
 }
 
}
empty._xscale=empty._yscale=130
0;
 empty._x=(Stage.width- empty._width)/2;
 empty._y=(Stage.height- empty._height)/2;

```

if you look at the attach file

a pipe will change colour if it connects to the one on the left but not dependent on touching one on the left or right

to check right is roughly the asme code but target is +1, to check up is target -10, to below is target +10

i might do more at a later date …if i feel i am going in the right direction

[Next page](https://forum.kirupa.com/t/pipeline/261321.md?page=2)
