Q - problem using setProperty

  • hzane
  • Newbie
  • Newbie
  • hzane
  • Posts: 9

Post 3+ Months Ago

let me lay out the code first off:
Code: [ Select ]
on (release) {
//top class
pieces = ["white", "black"];
pieces.white = ["whitePawns", "whiteBack"];
pieces.black = ["blackPawns", "blackBack"];

//white pieces
pieces.white.whitePawns =["wpa", "wpb", "wpc", "wpd", "wpe", "wpf", "wpg", "wph"];
pieces.white.whiteBack = ["wra", "wnb", "wbc","wq","wk","wbf", "wng", "wrh"];

//black pieces
pieces.black.blackPawns= ["bpa","bpb","bpc","bpd","bpe","bpf","bpg","bph"];
pieces.black.blackBack = ["bra","bnb","bbc","bq","bk","bbf","bng","brh"];

//_x adjustment var
right = 31.25;

//runs through setting pieces x,y
for (i=0; i<=7; i++) {
    setProperty(pieces.white.whitePawns[i], _y, 406.25);
    setProperty(pieces.white.whitePawns[i], _x, right);
    setProperty(pieces.white.whiteBack[i], _y, 468.75);
    setProperty(pieces.white.whiteBack[i], _x, right);
    setProperty(pieces.black.blackPawns[i], _y, 93.75);
    setProperty(pieces.black.blackPawns[i], _x, right);
    setProperty(pieces.black.blackBack[i], _y, 31.25);
    setProperty(pieces.black.blackBack[i], _x, right);
right += 62.5;
  1. on (release) {
  2. //top class
  3. pieces = ["white", "black"];
  4. pieces.white = ["whitePawns", "whiteBack"];
  5. pieces.black = ["blackPawns", "blackBack"];
  6. //white pieces
  7. pieces.white.whitePawns =["wpa", "wpb", "wpc", "wpd", "wpe", "wpf", "wpg", "wph"];
  8. pieces.white.whiteBack = ["wra", "wnb", "wbc","wq","wk","wbf", "wng", "wrh"];
  9. //black pieces
  10. pieces.black.blackPawns= ["bpa","bpb","bpc","bpd","bpe","bpf","bpg","bph"];
  11. pieces.black.blackBack = ["bra","bnb","bbc","bq","bk","bbf","bng","brh"];
  12. //_x adjustment var
  13. right = 31.25;
  14. //runs through setting pieces x,y
  15. for (i=0; i<=7; i++) {
  16.     setProperty(pieces.white.whitePawns[i], _y, 406.25);
  17.     setProperty(pieces.white.whitePawns[i], _x, right);
  19.     setProperty(pieces.white.whiteBack[i], _y, 468.75);
  20.     setProperty(pieces.white.whiteBack[i], _x, right);
  22.     setProperty(pieces.black.blackPawns[i], _y, 93.75);
  23.     setProperty(pieces.black.blackPawns[i], _x, right);
  25.     setProperty(pieces.black.blackBack[i], _y, 31.25);
  26.     setProperty(pieces.black.blackBack[i], _x, right);
  27. right += 62.5;
  30. }}

This is attached to a button.

The problem is with the black king and bishops - bk, bbc and bbf.
Those 3 jump out of position in a wierd way.

I think it's because the x,y of those 3 movie clips is kindof stuck on the upper left of the mc and it's relatively centered on the other 29 mcs. You know what I mean?
How the heck do you control that in Flash MX?
I could have just asked that and not posted the code, but maybe cause I'm new at this I wanted to show my code to someone and hear thoughts bout how I'm controlling these chess pieces here.

So thanks for checking out the post - and stay up!

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

First... please don't use setProperty... it's Flash 4 syntax, and makes the code a pain to read and write. Flash 5 started the wonderful world of dot syntax in Flash, so let's explore that...
Code: [ Select ]
clipInstance._x = value;
clipInstance._y = value;
  1. clipInstance._x = value;
  2. clipInstance._y = value;

Second, I noticed your positioning from a value of a variable called "right"... but that means all these clips are getting set to the same value (31.25)... did you mean to position the clip from it's current point but put it 31.25 px further to the right? If so use
Code: [ Select ]
clipInstance._x += right;
  • hzane
  • Newbie
  • Newbie
  • hzane
  • Posts: 9

Post 3+ Months Ago

gotcha - I like the clip._x idea but I must not be using it correctly.
basically inside my for loop I changed it to:

Code: [ Select ]
for (i=0; i<=7; i++) {
    pieces.white.whitePawns[i]._y = 406.25;
    pieces.white.whitePawns[i]._x = right;

//the .x increments from 31.25
  1. for (i=0; i<=7; i++) {
  2.     pieces.white.whitePawns[i]._y = 406.25;
  3.     pieces.white.whitePawns[i]._x = right;
  4.         right+=62.5
  5. //the .x increments from 31.25

With this nothing happens either inside of a buton (on(release)) - or frame1 of the main movie.
setPropety works but the .notation method is much nicer and preferable.

I will tool w/ it more tommorow.

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You may need to use associative array referencing to target your clips correctly... I don't know your exact setup, but try something like this...

Code: [ Select ]
pieces.white[whitePawns[i]]._x = whatever;
Notice how the whitePawns[i] is in within square brackets? That is what is known as associative array referencing... you can read more about it here...

http://www.kirupaforum.com/forums/showt ... adid=12082

Now i'm not entirely sure this is your issue, but I don't really have a way to troubleshoot and see without seeing a .fla file. Is it possible for you to upload to a server and send me a link where I can download it and scope it out?

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.