Re: [Flashcoders] Displaying objects

2006-03-29 Thread John Grden
This will give you what you're looking for:

var cols:Number = 3;
var rows:Number = 3;

for(var i:Number=0;irows;i++)
{
for(var j:Number=0;jcols;j++)
{
 var gridLocation:Number = (i+j) + ((rows-1)*i);
 trace(grid location =  + gridLocation);
 // create your moviecilp
}
}

row by row, create a movieclip per column.

hth,

John

On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:

 Ok, since my email got through this morning, I'm hoping this one gets
 through.  Here is the question I've emailed four times now.  Doesn't
 show up in the threads.

 Here we go:



 Here is what I have so far:

 import mx.transitions.Tween;
 import mx.transitions.easing.*;

 m = 0;
 numTiles = 112;

 function placeTiles() {
 if (m == numTiles){
 m = 0;
  clearInterval(buildTiles);
 } else {
 _root.attachMovie(square, tile + m + _mc, m, {_x:m % 14
 * 50, _y:Math.floor(m / 14) * 50});
 myObj = tile + m + _mc;
 new Tween(_root[myObj], _alpha, Regular.easeInOut, 0, 100, 35,
 false);
 _root[myObj].number_text.text = m;
 m++;
 }
 }

 buildTiles = setInterval(placeTiles, 30);

 This works fine.  Builds the rows one after another.  But what I am
 trying to do is build one row across and one down.  Make sense?

 In essence, the final display and position of the objects will be:

 123
 456
 789

 The sequence I am after:

 1

 then

 12
 4

 then

 123
 45
 7

 and so on

 123
 456
 78

 Help?!
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com




--
John Grden - Blitz
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Displaying objects

2006-03-29 Thread John Grden
also, i released this in the red5 repository - it's a GridManager class that
you can use to draw a grid (literally or not) and gives you methods like:

1.  calcGridLocation() - based on where you mouse is over the grid, you get
back a zero based grid number.  So if i you have a 3x3 grid, you might get
back 4 if you're in the center piece.
2.  getColRow() - based on the gridLocation number you pass in, you can get
back the column/row numbers that correspond - if you're in 4, you'd get back
2,2 (not zero based)
3.  calcCenterSpot() - gives you the pixels x/y of the center of a
particular piece based on col/row you send in.

if you already have a movieclip that has your grid graphic, you just pass
that movieclip reference to initGrid() and all the calculations will be
based on that movieclip.  You still have to pass in the grid's width and
height as this isn't always the size of the movieclip etc ;)

http://mirror1.cvsdude.com/trac/osflash/red5/browser/java/server/trunk/swf/DEV_Source/classes/org/red5/utils/GridManager.as

don't know if it's applicable to your scenario, but it works well for grid
based games.

hth,

On 3/29/06, John Grden [EMAIL PROTECTED] wrote:

 This will give you what you're looking for:

 var cols:Number = 3;
 var rows:Number = 3;

 for(var i:Number=0;irows;i++)
 {
 for(var j:Number=0;jcols;j++)
 {
  var gridLocation:Number = (i+j) + ((rows-1)*i);
  trace(grid location =  + gridLocation);
  // create your moviecilp
 }
 }

 row by row, create a movieclip per column.

 hth,

 John


 On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:
 
  Ok, since my email got through this morning, I'm hoping this one gets
  through.  Here is the question I've emailed four times now.  Doesn't
  show up in the threads.
 
  Here we go:
 
 
 
  Here is what I have so far:
 
  import mx.transitions.Tween;
  import mx.transitions.easing.*;
 
  m = 0;
  numTiles = 112;
 
  function placeTiles() {
  if (m == numTiles){
  m = 0;
   clearInterval(buildTiles);
  } else {
  _root.attachMovie(square, tile + m + _mc, m, {_x:m % 14
  * 50, _y:Math.floor(m / 14) * 50});
  myObj = tile + m + _mc;
  new Tween(_root[myObj], _alpha, Regular.easeInOut, 0, 100, 35,
  false);
  _root[myObj].number_text.text = m;
  m++;
  }
  }
 
  buildTiles = setInterval(placeTiles, 30);
 
  This works fine.  Builds the rows one after another.  But what I am
  trying to do is build one row across and one down.  Make sense?
 
  In essence, the final display and position of the objects will be:
 
  123
  456
  789
 
  The sequence I am after:
 
  1
 
  then
 
  12
  4
 
  then
 
  123
  45
  7
 
  and so on
 
  123
  456
  78
 
  Help?!
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf Software
  Premier Authorized Adobe Consulting and Training
  http://www.figleaf.com
  http://training.figleaf.com
 



 --
 John Grden - Blitz




--
John Grden - Blitz
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Displaying objects

2006-03-29 Thread Flash Mel
Ok, since my email got through this morning, I'm hoping this one gets
through.  Here is the question I've emailed four times now.  Doesn't show up
in the threads.

Here we go:



Here is what I have so far:

import mx.transitions.Tween;
import mx.transitions.easing.*;

m = 0;
numTiles = 112;

function placeTiles() {
if (m == numTiles){
m = 0;
clearInterval(buildTiles);
} else {
_root.attachMovie(square, tile + m + _mc, m, {_x:m % 14 * 50,
_y:Math.floor(m / 14) * 50});
myObj = tile + m + _mc;
new Tween(_root[myObj], _alpha, Regular.easeInOut, 0, 100, 35,
false);
_root[myObj].number_text.text = m;
m++;
}
}

buildTiles = setInterval(placeTiles, 30);

This works fine.  Builds the rows one after another.  But what I am trying
to do is build one row across and one down.  Make sense?

In essence, the final display and position of the objects will be:

123
456
789

The sequence I am after:

1

then

12
4

then

123
45
7

and so on

123
456
78

Help?!
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Displaying objects

2006-03-29 Thread Flash Mel
Thanks John,

This is great!  When I trace this, it works.  I've applied it to my code,
and I think I have added something wrong.  What happens is that all the
elements just build in a single area.

Here is what I had in the previous code:
http://www.apt11.com/test/test.html

Essentially, I need 0 to display, then 1, 14 then 2, 15, 28 and
so on.

Am I not applying your code correctly?  My apologies for the bumbling and
thanks for the help.

fM.



On 3/29/06, John Grden [EMAIL PROTECTED] wrote:

 This will give you what you're looking for:

 var cols:Number = 3;
 var rows:Number = 3;

 for(var i:Number=0;irows;i++)
 {
 for(var j:Number=0;jcols;j++)
 {
  var gridLocation:Number = (i+j) + ((rows-1)*i);
  trace(grid location =  + gridLocation);
  // create your moviecilp
 }
 }

 row by row, create a movieclip per column.

 hth,

 John

 On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:
 
  Ok, since my email got through this morning, I'm hoping this one gets
  through.  Here is the question I've emailed four times now.  Doesn't
  show up in the threads.
 
  Here we go:
 
 
 
  Here is what I have so far:
 
  import mx.transitions.Tween;
  import mx.transitions.easing.*;
 
  m = 0;
  numTiles = 112;
 
  function placeTiles() {
  if (m == numTiles){
  m = 0;
   clearInterval(buildTiles);
  } else {
  _root.attachMovie(square, tile + m + _mc, m, {_x:m % 14
  * 50, _y:Math.floor(m / 14) * 50});
  myObj = tile + m + _mc;
  new Tween(_root[myObj], _alpha, Regular.easeInOut, 0, 100, 35,
  false);
  _root[myObj].number_text.text = m;
  m++;
  }
  }
 
  buildTiles = setInterval(placeTiles, 30);
 
  This works fine.  Builds the rows one after another.  But what I am
  trying to do is build one row across and one down.  Make sense?
 
  In essence, the final display and position of the objects will be:
 
  123
  456
  789
 
  The sequence I am after:
 
  1
 
  then
 
  12
  4
 
  then
 
  123
  45
  7
 
  and so on
 
  123
  456
  78
 
  Help?!
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf Software
  Premier Authorized Adobe Consulting and Training
  http://www.figleaf.com
  http://training.figleaf.com
 



 --
 John Grden - Blitz
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Displaying objects

2006-03-29 Thread John Grden
well, if you're using my code, then it would essentially build all pieces
the way you show it happening in that link.

to do it diagonaly the way you specify, there's 2 ways:

1.  come up with an algorithm to calculate that type of movement based on
the number of rows/cols you have (ouch)
2.  create the grid first, hide all pieces.  Create an array by hand with
those values, and loop that array displaying the correct pieces:

var pieceList:Array ({pieces:[0]}, {pieces: [1,14]}, {pieces:[2,15,28]});

for(var i:Number=0;ipieceList.length;i++)
{
for(var j:Number=0;jpieceList[i].pieces.length;j++)
{
this[piece_ + pieceList[i].pieces[j]._visible = true;
}
}

Either set visible to true of tell it to gotoAndPlay(transitionIn) or
whatever you have in frame lables etc.

Make sense?

JG

On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:

 Thanks John,

 This is great!  When I trace this, it works.  I've applied it to my code,
 and I think I have added something wrong.  What happens is that all the
 elements just build in a single area.

 Here is what I had in the previous code:
 http://www.apt11.com/test/test.html

 Essentially, I need 0 to display, then 1, 14 then 2, 15, 28
 and
 so on.

 Am I not applying your code correctly?  My apologies for the bumbling and
 thanks for the help.

 fM.



 On 3/29/06, John Grden [EMAIL PROTECTED] wrote:
 
  This will give you what you're looking for:
 
  var cols:Number = 3;
  var rows:Number = 3;
 
  for(var i:Number=0;irows;i++)
  {
  for(var j:Number=0;jcols;j++)
  {
   var gridLocation:Number = (i+j) + ((rows-1)*i);
   trace(grid location =  + gridLocation);
   // create your moviecilp
  }
  }
 
  row by row, create a movieclip per column.
 
  hth,
 
  John
 
  On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:
  
   Ok, since my email got through this morning, I'm hoping this one gets
   through.  Here is the question I've emailed four times now.  Doesn't
   show up in the threads.
  
   Here we go:
  
  
  
   Here is what I have so far:
  
   import mx.transitions.Tween;
   import mx.transitions.easing.*;
  
   m = 0;
   numTiles = 112;
  
   function placeTiles() {
   if (m == numTiles){
   m = 0;
clearInterval(buildTiles);
   } else {
   _root.attachMovie(square, tile + m + _mc, m, {_x:m % 14
   * 50, _y:Math.floor(m / 14) * 50});
   myObj = tile + m + _mc;
   new Tween(_root[myObj], _alpha, Regular.easeInOut, 0, 100,
 35,
   false);
   _root[myObj].number_text.text = m;
   m++;
   }
   }
  
   buildTiles = setInterval(placeTiles, 30);
  
   This works fine.  Builds the rows one after another.  But what I am
   trying to do is build one row across and one down.  Make sense?
  
   In essence, the final display and position of the objects will be:
  
   123
   456
   789
  
   The sequence I am after:
  
   1
  
   then
  
   12
   4
  
   then
  
   123
   45
   7
  
   and so on
  
   123
   456
   78
  
   Help?!
   ___
   Flashcoders@chattyfig.figleaf.com
   To change your subscription options or search the archive:
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
   Brought to you by Fig Leaf Software
   Premier Authorized Adobe Consulting and Training
   http://www.figleaf.com
   http://training.figleaf.com
  
 
 
 
  --
  John Grden - Blitz
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf Software
  Premier Authorized Adobe Consulting and Training
  http://www.figleaf.com
  http://training.figleaf.com
 
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com




--
John Grden - Blitz
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Displaying objects

2006-03-29 Thread John Grden
Sorry, code correction - LOL, on code that's not been tested ...

for(var i:Number=0;ipieceList.length;i++)
{
for(var j:Number=0;jpieceList[i].pieces.length;j++)
{
this[piece_ + pieceList[i].pieces[j]]._visible = true;
}
}


On 3/29/06, John Grden [EMAIL PROTECTED] wrote:

 well, if you're using my code, then it would essentially build all pieces
 the way you show it happening in that link.

 to do it diagonaly the way you specify, there's 2 ways:

 1.  come up with an algorithm to calculate that type of movement based on
 the number of rows/cols you have (ouch)
 2.  create the grid first, hide all pieces.  Create an array by hand with
 those values, and loop that array displaying the correct pieces:

 var pieceList:Array ({pieces:[0]}, {pieces: [1,14]}, {pieces:[2,15,28]});

 for(var i:Number=0;ipieceList.length;i++)
 {
 for(var j:Number=0;jpieceList[i].pieces.length;j++)
 {
 this[piece_ + pieceList[i].pieces[j]._visible = true;
 }
 }

 Either set visible to true of tell it to gotoAndPlay(transitionIn) or
 whatever you have in frame lables etc.

 Make sense?

 JG


 On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:
 
  Thanks John,
 
  This is great!  When I trace this, it works.  I've applied it to my
  code,
  and I think I have added something wrong.  What happens is that all the
  elements just build in a single area.
 
  Here is what I had in the previous code:
  http://www.apt11.com/test/test.html
 
  Essentially, I need 0 to display, then 1, 14 then 2, 15, 28
  and
  so on.
 
  Am I not applying your code correctly?  My apologies for the bumbling
  and
  thanks for the help.
 
  fM.
 
 
 
  On 3/29/06, John Grden [EMAIL PROTECTED]  wrote:
  
   This will give you what you're looking for:
  
   var cols:Number = 3;
   var rows:Number = 3;
  
   for(var i:Number=0;irows;i++)
   {
   for(var j:Number=0;jcols;j++)
   {
var gridLocation:Number = (i+j) + ((rows-1)*i);
trace(grid location =  + gridLocation);
// create your moviecilp
   }
   }
  
   row by row, create a movieclip per column.
  
   hth,
  
   John
  
   On 3/29/06, Flash Mel [EMAIL PROTECTED] wrote:
   
Ok, since my email got through this morning, I'm hoping this one
  gets
through.  Here is the question I've emailed four times now.  Doesn't
show up in the threads.
   
Here we go:
   
   
   
Here is what I have so far:
   
import mx.transitions.Tween;
import mx.transitions.easing.*;
   
m = 0;
numTiles = 112;
   
function placeTiles() {
if (m == numTiles){
m = 0;
 clearInterval(buildTiles);
} else {
_root.attachMovie(square, tile + m + _mc, m, {_x:m %
  14
* 50, _y:Math.floor(m / 14) * 50});
myObj = tile + m + _mc;
new Tween(_root[myObj], _alpha, Regular.easeInOut, 0, 100,
  35,
false);
_root[myObj].number_text.text = m;
m++;
}
}
   
buildTiles = setInterval(placeTiles, 30);
   
This works fine.  Builds the rows one after another.  But what I am
trying to do is build one row across and one down.  Make sense?
   
In essence, the final display and position of the objects will be:
   
123
456
789
   
The sequence I am after:
   
1
   
then
   
12
4
   
then
   
123
45
7
   
and so on
   
123
456
78
   
Help?!
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
   
  
  
  
   --
   John Grden - Blitz
   ___
   Flashcoders@chattyfig.figleaf.com
   To change your subscription options or search the archive:
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
   Brought to you by Fig Leaf Software
   Premier Authorized Adobe Consulting and Training
   http://www.figleaf.com
   http://training.figleaf.com
  
  ___
  Flashcoders@chattyfig.figleaf.com
  To change your subscription options or search the archive:
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
  Brought to you by Fig Leaf Software
  Premier Authorized Adobe Consulting and Training
  http://www.figleaf.com
  http://training.figleaf.com
 



 --
 John Grden - Blitz




--
John Grden - Blitz
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com