pset3

20 views
Skip to first unread message

Nora

unread,
Mar 12, 2010, 2:08:39 AM3/12/10
to 6.813
When you say that the StrokeCheckerboard cannot have child components,
does that mean that we can't use this.rawChildren.addChild(x) in
addition to just not calling this.addChild(x)?

Steven Bartel

unread,
Mar 12, 2010, 2:13:48 AM3/12/10
to 68...@googlegroups.com, Nora
I'm pretty sure they just want you to draw circles with certain radii,
at certain x,y positions. It's done almost exactly the same as
drawing the squares for checkers. There are a few constants that tell
you how many pixels per square, the colors, and the radius for the
circles. You should be able to use those to figure out a position,
color, and radius, for a given checker and draw it.

-Steve

--
Steven Bartel
Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology 2010
Phone: (617) 312-7225

Nora Mallory

unread,
Mar 12, 2010, 2:26:13 AM3/12/10
to Steven Bartel, 68...@googlegroups.com
Yeah, I can see how to use all the constants that they gave us.  However, I'm looking all over teh interwebs, and everything I see about drawing things in Flex involves using addChild.  I did beginFill and drawCircle and nothing shows up unless I then call addChild.

--
Eleanor Mallory

Massachusetts Institute of Technology

Department of Electrical Engineering and Computer Science
Class of 2011

(773) 980-6672
el...@mit.edu | emall...@gmail.com

Jennifer Chan

unread,
Mar 12, 2010, 2:55:12 AM3/12/10
to 68...@googlegroups.com, Steven Bartel, emall...@gmail.com
It depends on which object's graphic object you are using.  For example, if you make a new shape and call beginFill (like shape.grapihcs.beginFill(color)), in order for it to show up, you have to add the shape object to the parent with addChild.  Make sure the beginFill, drawCircle, and any other drawing operations are applied to the graphics object of the checkerboard itself.

Hope that helps...
Jenny
--
Jennifer Chan
MIT Class of 2011

Department of Electrical Engineering and Computer Science

Nora Mallory

unread,
Mar 12, 2010, 2:55:55 AM3/12/10
to Jennifer Chan, 68...@googlegroups.com, Steven Bartel
Got it! Thanks!


--
Eleanor Mallory

Massachusetts Institute of Technology
Department of Electrical Engineering and Computer Science
Class of 2011

(773) 980-6672
el...@mit.edu | emall...@gmail.com


Sean Liu (MIT)

unread,
Mar 12, 2010, 6:02:55 PM3/12/10
to 68...@googlegroups.com, Jennifer Chan, Steven Bartel
How do we register for events in StrokeCheckerboard?

I'm trying to bind to the "BoardEvent"s like "add", "remove", etc.  I overrode the "onLoad", and was going to put a board.addEventListener, except board is still null when the onLoad is called...

Any help?

Thanks!
Sean
--
Sean Liu
Massachusetts Institute of Technology
Department of Electrical Engineering & Computer Science '10
(916) 220-4326 | sean...@mit.edu

Steven Bartel

unread,
Mar 12, 2010, 6:09:29 PM3/12/10
to Sean Liu (MIT), 68...@googlegroups.com, Jennifer Chan
If you look at Checkerboard.mxml, it shows you how to handle this.  You have to add a ChangeListener, that listens changes in board (i.e. when it is set).  Your change listener can call a function that adds the listeners for your events.  Alternatively, override Checkerboard's version of paint, which gets called once or twice, depending on whether the board has been initialized.  In both cases, make sure to check if (!board) to see if it's null.

Good luck,

-Steve

--
Steven Bartel
Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology 2010


Peter Nga

unread,
Mar 12, 2010, 9:37:45 PM3/12/10
to 68...@googlegroups.com, Sean Liu (MIT), Jennifer Chan
Does anybody know if we're supposed to support different board sizes
when using "Different models" (i.e. have the strokes board of size 4 and
have the pixels board of size 8)?

>> el...@mit.edu <mailto:el...@mit.edu> | emall...@gmail.com
>> <mailto:emall...@gmail.com>


>>
>>
>> On Fri, Mar 12, 2010 at 2:55 AM, Jennifer Chan <jpc...@mit.edu
>> <mailto:jpc...@mit.edu>> wrote:
>>
>> It depends on which object's graphic object you are using.
>> For example, if you make a new shape and call beginFill
>> (like shape.grapihcs.beginFill(color)), in order for it to
>> show up, you have to add the shape object to the parent with
>> addChild. Make sure the beginFill, drawCircle, and any other
>> drawing operations are applied to the graphics object of the
>> checkerboard itself.
>>
>> Hope that helps...
>> Jenny
>>
>>
>> On Fri, Mar 12, 2010 at 2:26 AM, Nora Mallory
>> <emall...@gmail.com <mailto:emall...@gmail.com>> wrote:
>>
>> Yeah, I can see how to use all the constants that they
>> gave us. However, I'm looking all over teh interwebs,
>> and everything I see about drawing things in Flex
>> involves using addChild. I did beginFill and drawCircle
>> and nothing shows up unless I then call addChild.
>>
>> --
>> Eleanor Mallory
>>
>> Massachusetts Institute of Technology
>> Department of Electrical Engineering and Computer Science
>> Class of 2011
>>
>> (773) 980-6672

>> el...@mit.edu <mailto:el...@mit.edu> |
>> emall...@gmail.com <mailto:emall...@gmail.com>

>> jpc...@mit.edu <mailto:jpc...@mit.edu>


>>
>>
>>
>>
>>
>> --
>> Sean Liu
>> Massachusetts Institute of Technology
>> Department of Electrical Engineering & Computer Science '10

>> (916) 220-4326 | sean...@mit.edu <mailto:sean...@mit.edu>
>

Tony Tran

unread,
Mar 13, 2010, 12:28:58 AM3/13/10
to 68...@googlegroups.com, Sean Liu (MIT), Jennifer Chan
Different board sizes shouldn't really matter, because the board model encapsulates all that, I think we're just displaying the pieces.

On that note, however, is anyone having the problem where when you first load up the app, the "pixel" board doesn't have anything (even if you click "new game" on the strokes board).  I think theres an issue where the created event is fired only when you switch to the pixel board.  Thus, the model doesn't have any listener and the pixel board doesn't display it unless you click "new game" while on the pixel board.

Anyone figure a way around this?
--
Tony Tran
Massachusetts Institute of Technology
Dept. of Electrical Engineering and Computer Science

Peter Nga

unread,
Mar 13, 2010, 12:32:19 AM3/13/10
to 68...@googlegroups.com, Sean Liu (MIT), Jennifer Chan
I just had it initialize the first time you go to it, checking where all
the checkers currently are for the given board.

> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>> wrote:
>
> Got it! Thanks!
>
>
> --
> Eleanor Mallory
>
> Massachusetts Institute of Technology
> Department of Electrical Engineering and Computer Science
> Class of 2011
>
> (773) 980-6672
> el...@mit.edu <mailto:el...@mit.edu>

> <mailto:el...@mit.edu <mailto:el...@mit.edu>> |
> emall...@gmail.com <mailto:emall...@gmail.com>
> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>
>
>
>
> On Fri, Mar 12, 2010 at 2:55 AM, Jennifer Chan
> <jpc...@mit.edu <mailto:jpc...@mit.edu>

> <mailto:jpc...@mit.edu <mailto:jpc...@mit.edu>>> wrote:
>
> It depends on which object's graphic object you are
> using.
> For example, if you make a new shape and call
> beginFill
> (like shape.grapihcs.beginFill(color)), in order
> for it to
> show up, you have to add the shape object to the
> parent with
> addChild. Make sure the beginFill, drawCircle, and
> any other
> drawing operations are applied to the graphics
> object of the
> checkerboard itself.
>
> Hope that helps...
> Jenny
>
>
> On Fri, Mar 12, 2010 at 2:26 AM, Nora Mallory
> <emall...@gmail.com <mailto:emall...@gmail.com>

> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>> wrote:
>
> Yeah, I can see how to use all the constants
> that they
> gave us. However, I'm looking all over teh
> interwebs,
> and everything I see about drawing things in Flex
> involves using addChild. I did beginFill and
> drawCircle
> and nothing shows up unless I then call addChild.
>
> --
> Eleanor Mallory
>
> Massachusetts Institute of Technology
> Department of Electrical Engineering and
> Computer Science
> Class of 2011
>
> (773) 980-6672
> el...@mit.edu <mailto:el...@mit.edu>

> <mailto:el...@mit.edu <mailto:el...@mit.edu>> |
> emall...@gmail.com
> <mailto:emall...@gmail.com> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>
>
>
>
> On Fri, Mar 12, 2010 at 2:13 AM, Steven Bartel
> <sba...@mit.edu <mailto:sba...@mit.edu>

> <mailto:jpc...@mit.edu <mailto:jpc...@mit.edu>>


>
>
>
>
>
>
> --
> Sean Liu
> Massachusetts Institute of Technology
> Department of Electrical Engineering & Computer Science '10
> (916) 220-4326 | sean...@mit.edu

> <mailto:sean...@mit.edu> <mailto:sean...@mit.edu

Sean Liu (MIT)

unread,
Mar 13, 2010, 1:08:58 AM3/13/10
to Tony Tran, 68...@googlegroups.com, Jennifer Chan
I assume you're putting your listeners in the ChangeWatcher (to avoid a null board).  Add a statement if (board) { addListeners() } and it should fix your problem.

It's caused because you already have a non-null board, but onLoad gets called when you go to view the pixel board.  So the ChangeWatcher won't get executed (since the board was already non-null and just stays that way).

Sean Liu (MIT)

unread,
Mar 13, 2010, 2:02:35 AM3/13/10
to Tony Tran, 68...@googlegroups.com, Jennifer Chan
Actually, I'm a bit confused about the different board sizes.  Say you click "New Game" in Pixel mode, and then change the board size to 3. Now you'll have checkers that are displaying off the board.

Should I not be using this.addChild(checkerImage)?  The issue is, if I try to do this.removeChild(checkerImage) inside the ChangeWatcher, it seems as if it's a "new" this, which no longer has the checkerImage...  but I don't really know how to store the "old" this.  If I don't do anything, the "old" this keeps the checkers displaying on the screen :-(.  Any help?

Thanks!
Sean

On Sat, Mar 13, 2010 at 12:28 AM, Tony Tran <tt...@mit.edu> wrote:

Peter Nga

unread,
Mar 13, 2010, 2:13:37 AM3/13/10
to 68...@googlegroups.com, Tony Tran, Jennifer Chan
I think when you change the size of the board, it should be like having
a new board (like when you first start up the program). Pressing new
board after changing the size should bring up the checkers again.

> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>> wrote:
>
> Got it! Thanks!
>
>
> --
> Eleanor Mallory
>
> Massachusetts Institute of Technology
> Department of Electrical Engineering and Computer
> Science
> Class of 2011
>
> (773) 980-6672
> el...@mit.edu <mailto:el...@mit.edu>

> <mailto:el...@mit.edu <mailto:el...@mit.edu>> |
> emall...@gmail.com <mailto:emall...@gmail.com>
> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>
>
>
>
> On Fri, Mar 12, 2010 at 2:55 AM, Jennifer Chan
> <jpc...@mit.edu <mailto:jpc...@mit.edu>

> <mailto:jpc...@mit.edu <mailto:jpc...@mit.edu>>> wrote:
>
> It depends on which object's graphic object you
> are using.
> For example, if you make a new shape and call
> beginFill
> (like shape.grapihcs.beginFill(color)), in
> order for it to
> show up, you have to add the shape object to
> the parent with
> addChild. Make sure the beginFill, drawCircle,
> and any other
> drawing operations are applied to the graphics
> object of the
> checkerboard itself.
>
> Hope that helps...
> Jenny
>
>
> On Fri, Mar 12, 2010 at 2:26 AM, Nora Mallory
> <emall...@gmail.com
> <mailto:emall...@gmail.com>

> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>> wrote:
>
> Yeah, I can see how to use all the
> constants that they
> gave us. However, I'm looking all over teh
> interwebs,
> and everything I see about drawing things
> in Flex
> involves using addChild. I did beginFill
> and drawCircle
> and nothing shows up unless I then call
> addChild.
>
> --
> Eleanor Mallory
>
> Massachusetts Institute of Technology
> Department of Electrical Engineering and
> Computer Science
> Class of 2011
>
> (773) 980-6672
> el...@mit.edu <mailto:el...@mit.edu>

> <mailto:el...@mit.edu <mailto:el...@mit.edu>> |
> emall...@gmail.com
> <mailto:emall...@gmail.com>
> <mailto:emall...@gmail.com


> <mailto:emall...@gmail.com>>
>
>
>
> On Fri, Mar 12, 2010 at 2:13 AM, Steven Bartel
> <sba...@mit.edu <mailto:sba...@mit.edu>

> <mailto:jpc...@mit.edu <mailto:jpc...@mit.edu>>


>
>
>
>
>
>
> --
> Sean Liu
> Massachusetts Institute of Technology
> Department of Electrical Engineering & Computer
> Science '10
> (916) 220-4326 | sean...@mit.edu

> <mailto:sean...@mit.edu> <mailto:sean...@mit.edu


> <mailto:sean...@mit.edu>>
>
>
>
>
>
>
> --
> Tony Tran
> Massachusetts Institute of Technology
> Dept. of Electrical Engineering and Computer Science
>
>
>
>
> --
> Sean Liu
> Massachusetts Institute of Technology
> Department of Electrical Engineering & Computer Science '10

> (916) 220-4326 | sean...@mit.edu <mailto:sean...@mit.edu>

Sean Liu (Gmail)

unread,
Mar 13, 2010, 2:22:14 AM3/13/10
to 68...@googlegroups.com, Tony Tran, Jennifer Chan
Right...but it still leaves a bad intermittent state in which there are random checkers all over the screen outside the bounds of the board before you click New Game :-(.

Peter Nga

unread,
Mar 13, 2010, 2:25:21 AM3/13/10
to 68...@googlegroups.com, Tony Tran, Jennifer Chan
You need to add a ChangeWatcher for board in pixel board that removes
the images. It's similar to the one in CheckerBoard...it triggers every
time the board is changed, which happens to also be when the board is
resized.

Sean Liu (Gmail) wrote:
> Right...but it still leaves a bad intermittent state in which there
> are random checkers all over the screen outside the bounds of the
> board before you click New Game :-(.
>
> On Sat, Mar 13, 2010 at 2:13 AM, Peter Nga <hl...@mit.edu
> <mailto:hl...@mit.edu>> wrote:
>
> I think when you change the size of the board, it should be like
> having a new board (like when you first start up the program).
> Pressing new board after changing the size should bring up the
> checkers again.
>
> Sean Liu (MIT) wrote:
>
> Actually, I'm a bit confused about the different board sizes.
> Say you click "New Game" in Pixel mode, and then change the
> board size to 3. Now you'll have checkers that are displaying
> off the board.
>
> Should I not be using this.addChild(checkerImage)? The issue
> is, if I try to do this.removeChild(checkerImage) inside the
> ChangeWatcher, it seems as if it's a "new" this, which no
> longer has the checkerImage... but I don't really know how to
> store the "old" this. If I don't do anything, the "old" this
> keeps the checkers displaying on the screen :-(. Any help?
>
> Thanks!
> Sean
>
> On Sat, Mar 13, 2010 at 12:28 AM, Tony Tran <tt...@mit.edu

> <mailto:tt...@mit.edu> <mailto:tt...@mit.edu


> <mailto:tt...@mit.edu>>> wrote:
>
> Different board sizes shouldn't really matter, because the
> board
> model encapsulates all that, I think we're just displaying the
> pieces.
>
> On that note, however, is anyone having the problem where
> when you
> first load up the app, the "pixel" board doesn't have anything
> (even if you click "new game" on the strokes board). I think
> theres an issue where the created event is fired only when you
> switch to the pixel board. Thus, the model doesn't have any
> listener and the pixel board doesn't display it unless you
> click
> "new game" while on the pixel board.
>
> Anyone figure a way around this?
>
>
> On Fri, Mar 12, 2010 at 9:37 PM, Peter Nga <hl...@mit.edu
> <mailto:hl...@mit.edu>

> <mailto:jpc...@mit.edu <mailto:jpc...@mit.edu>


> <mailto:jpc...@mit.edu <mailto:jpc...@mit.edu>>>
>
>
>
>
>
>
>
> -- Sean Liu
> Massachusetts Institute of Technology
> Department of Electrical Engineering & Computer
> Science '10
> (916) 220-4326 | sean...@mit.edu
> <mailto:sean...@mit.edu>
> <mailto:sean...@mit.edu

> <mailto:sean...@mit.edu>> <mailto:sean...@mit.edu

Maria Rodriguez

unread,
Mar 13, 2010, 5:41:44 PM3/13/10
to 68...@googlegroups.com, Tony Tran, Jennifer Chan
Did anyone else have trouble loading the images? I don't think I'm specifying the source correctly. Either that, or this.addChild(img) isn't doing what I think it is. Can someone please help?

Thanks,
Maria
--
Maria I. Rodriguez
Massachusetts Institute of Technology

Electrical Engineering & Computer Science
Class of 2011

Fuming Shih

unread,
Mar 13, 2010, 5:47:10 PM3/13/10
to 68...@googlegroups.com, mar...@mit.edu
http://digitalmedia.oreilly.com/helpcenter/flex3cookbook/chapter8.html

I used this code snippet to get my code working.

hope it helps,
--
Fuming, Shih
Research Assistant ,
Decentralized Information Group,
CSAIL, MIT

Katherine Lin

unread,
Mar 13, 2010, 10:29:25 PM3/13/10
to 68...@googlegroups.com, mar...@mit.edu
Hey,

Just to confirm, should the board draw checkers when we run the program? Or only after we click "New Game"? I thought being "New Game' based was ok, but after reading this thread, it seems people got checkers to display at loading?

-Kat

Tony Tran

unread,
Mar 13, 2010, 10:43:37 PM3/13/10
to 68...@googlegroups.com, mar...@mit.edu
I did it only on New Game. 

The onLoad discussion was for the pixel board.

Darren Yin

unread,
Mar 13, 2010, 10:59:58 PM3/13/10
to 68...@googlegroups.com, mar...@mit.edu
Should be after New Game, cause after the app starts, and before you
click New Game, none of the checkers have even been initialized yet.
If you add traces to all the events/look through the code in
Main.mxml, you can see that checkers only exist after New Game is
clicked.

~Darren

On Sat, Mar 13, 2010 at 10:29 PM, Katherine Lin <kat...@mit.edu> wrote:

Jennifer Li

unread,
Mar 13, 2010, 11:51:58 PM3/13/10
to 68...@googlegroups.com, mar...@mit.edu
Hey guys,

I'm pretty epically confused about how to register to BoardEvents.  I've gotten the ChangeWatcher set up when the checkerboard is created, and it calls a function which attempts to set up an event listener which will find BoardEvents and display the checkers.  It looks like this:
                this.board.addEventListener("BoardEvent", drawCheckers);

It doesn't seem to be doing anything.  I'm not sure what should go in as the first parameter, because the documentation says a string representing the event?...

Thanks for your help,
Jenny Li
--
Jennifer Li

Ted Tomlinson

unread,
Mar 14, 2010, 12:01:38 AM3/14/10
to 68...@googlegroups.com
events are tagged by name eg "add" "remove" etc, since it is just subclassing the event dispatcher. BoardEvent is the would be like calling addeventlistener("Event", draw checkers).

So you need board.addEventListener("add", drawCheckers). this drawCheckers function should draw the one checker that is an part of the event object, not the whole board. when you click "start Game" it fires off a bunch of add checker events in a row and you add the checkers as they are fired.

If you are using flex builder, the debugger is a good way to see how events are dispatched, just put a breakpoint inside the model where it calls dispatchEvent("add ...

Seak Meng Lay

unread,
Mar 14, 2010, 12:15:53 AM3/14/10
to 68...@googlegroups.com
Hey guys, I have a problem with the pixelCheckerBoard.

The first time I load the application, if I am in shared model mode and in
stroke tab, and I click on new game, the checkers populate the
strokecheckerboard but not the pixelcheckerboard. Although the
pixelcheckerboard is empty, if i click on move randomly, will see the moving
checkers, and not the rest. Now If i clear everything, go back to stroke tab,
and click on new game again, this time it populates both the stroke and pixel
checkerboards.

Did anyone run into the same problem?

Thanks
-Meng

Steven Bartel

unread,
Mar 14, 2010, 5:36:35 AM3/14/10
to 68...@googlegroups.com
Yes. Your problem is that the pixel checkboard is instantiated after
the model fires the event. My solution was to override the function
that paints the checkerboard in PixelCheckerBoard (which gets called
on initialization of CheckerBoard) to query the board for the list of
checkers and draw them. Hope this helps,

-Steve

--
Steven Bartel
Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology 2010
Phone: (617) 312-7225

Tobe Nwanna

unread,
Mar 14, 2010, 5:41:46 AM3/14/10
to 68...@googlegroups.com
So I'm working on the stroke model and I seem to be having a problem in
my event handler. When I click new game, it gets into my drawPieces
function and gets into the if(event.type=="add") if statement block but
never gets past

if(board.checkerAt(loc1.row,loc1.col).isKing)

Which is really weird because I don't think that should cause any
problems. By the way, loc1 is from var loc1:Location=event.from;

Is that the correct way of using that? It's not giving any errors so I
assume it is

Tobe Nwanna

unread,
Mar 14, 2010, 6:09:12 AM3/14/10
to 68...@googlegroups.com
So i fixed that problem. But another problem seems to be that I can't
get the to field in BoardEvents. It's colored blue in Flex so it seems
to be a reserved word, which would also explain why it never shows up
when I type " event. " for a BoardEvent. Can i change it to something
else or have other people figured out some way to use it?

Peter Nga

unread,
Mar 14, 2010, 1:28:39 PM3/14/10
to 68...@googlegroups.com
Even though it shows up as blue, it still gets the information from it.
If you're having problems accessing it, something else must be wrong (I
learned that the hard way).

Nicole Bieber

unread,
Mar 14, 2010, 7:17:03 PM3/14/10
to 68...@googlegroups.com
Should I be trying to avoid having all of the pieces flicker (basically,
very quickly appear and disappear) every time something changes on the
board in the pixel model? It seems like the only way I could avoid this
would be to remove and add Images individually rather than redrawing the
entire board each time - is that what I should be doing?
-n

Kimberly Baldauf

unread,
Mar 14, 2010, 8:02:51 PM3/14/10
to 68...@googlegroups.com
I'm having a problem where if I try to run the two types of boards
side-by-side,
my code never gets to the part where it sets the addEventListeners for
the pixel
board. It doesn't load until the tab is pressed (I assume that's right?) and
even then, it doesn't pass the if(board) check. I'm reusing the same
ChangeWatcher code as in my stroke board, and that one works fine. Is it
supposed to be different somehow?

-Kim

Yuzhi Zheng

unread,
Mar 14, 2010, 8:09:12 PM3/14/10
to 68...@googlegroups.com
For me, at first it doesn't load until a new board(by switching the
size) is made. So i added the set of lines for addEventListener stuff
into the onLoad, so it will always have a set of eventlisteners

-Yuzhi

Yuzhi Zheng
Massachusetts Institute of Technology Class of 2012
Course 6 - Electrical Engineering and Computer Science


John Pope

unread,
Mar 14, 2010, 8:26:02 PM3/14/10
to 68...@googlegroups.com
You can have both the pixelBoard and strokeBoard load at the beginning
if you add the tab navigator property creationPolicy="all". You
shouldn't need an if(board) check. Adding your listeners in the
ChangeWatcher should be fine.

Stefan Gimmillaro

unread,
Mar 14, 2010, 8:31:29 PM3/14/10
to 68...@googlegroups.com
I know we're supposed to be listening for when checkers are added or removed but where do those listeners actually go, I can't figure it out.  I know we aren't supposed to put them in main, but then how do I get the x and y for where we draw the checkers?

Thanks a bunch,
Stefan

Kwasi Nti

unread,
Mar 14, 2010, 8:40:34 PM3/14/10
to 68...@googlegroups.com

Same here. I've done debugging and I've looked at how the checkers are added to the board, but I can't get board.checkers().length to be not empty.  Pretty sure my logic for drawing  is okay but it's hard to check with an empty board.

Kwasi

On Mar 14, 2010 8:31 PM, "Stefan Gimmillaro" <ste...@mit.edu> wrote:

I know we're supposed to be listening for when checkers are added or removed but where do those listeners actually go, I can't figure it out.  I know we aren't supposed to put them in main, but then how do I get the x and y for where we draw the checkers?

Thanks a bunch,
Stefan



On Sun, Mar 14, 2010 at 8:26 PM, John Pope <jo...@mit.edu> wrote:
>

> You can have both the pixelB...

Michael Bernstein

unread,
Mar 14, 2010, 8:59:48 PM3/14/10
to 68...@googlegroups.com
I don't think that the pieces should be flickering especially much.  Every time paintSquares() is called, you should be able to remove all the old components and repopulate without seeing a flicker.
- Michael

Michael Bernstein

unread,
Mar 14, 2010, 9:08:54 PM3/14/10
to 68...@googlegroups.com
You might find it useful to separate out the code that paints the board (which you'll override) from the code that paints the checkers, and call the checker-painter from the board-painter function.  Then, you can register the listeners when you paint the board and call the checker painter when the event is fired.

The board should be populated when you click New Game.  That's the best I can say offhand for the empty array issue...  Try calling newGame(board) and immediately after querying board.checkers().
- Michael

Tobechukwu G Nwanna

unread,
Mar 14, 2010, 9:18:13 PM3/14/10
to 68...@googlegroups.com, Michael Bernstein
So have people found it easier to simply redraw all the pieces (in the pixel
model) than redrawing only the ones that move? I've been trying to only redraw
pieces that change by naming the images based on their locations but it seems
simply redrawing everything might be better, since we don't really care about
efficiency

Wolfe Styke

unread,
Mar 14, 2010, 9:57:10 PM3/14/10
to 68...@googlegroups.com
One problem with having to redraw all the pixel images when only one is affected (moved, turned into a king), is that you may notice a flicker of all the pieces disappearing and then reappearing each time one of these types of actions is taken.

It's quite possible to only redraw the affected pixel; it helps to have some mechanism that lets you find the affected pixel image among the children of the pixel checkerboard.

~Wolfe

Alexandre Oliveira

unread,
Mar 14, 2010, 10:07:06 PM3/14/10
to 68...@googlegroups.com
If you're seeing flickering because of the slow image controls, you can use embedding of the pictures:

[Embed(source="picture.png")]
[Bindable] var picture:Class;

Hope that helps!
- Alex

David Crowell

unread,
Mar 14, 2010, 11:05:15 PM3/14/10
to 68...@googlegroups.com
So for the PixelCheckerboard problem, I'm not sure what I should be
doing, conceptually. From the line "using Flex's builtin Image
component (Do not draw the pieces using something like
Graphics.beginBitmapFill)" I assume I'm going to want something
essentially similar to a <mx:Image> </mx:Image> to be created. Can I
create those dynamically with actionscript code? Should I initialize
an Image object for each square and somehow make it not show up?

Am I conceptually approaching this correctly?

Alexander M Patrikalakis

unread,
Mar 14, 2010, 11:06:32 PM3/14/10
to 68...@googlegroups.com
its not enough to instantiate an image and populate the fields of an image object; you have to explicitly (read AS statement) add it to the parent PixelCheckerboard component

Alex

Tobe Nwanna

unread,
Mar 14, 2010, 11:07:28 PM3/14/10
to 68...@googlegroups.com

Nicole Bieber

unread,
Mar 14, 2010, 11:21:04 PM3/14/10
to 68...@googlegroups.com
Okay, so I've got the thing working perfectly when I run it from Flex
builder, but I just discovered that when I export it and run the html
file, nothing shows up for the pixel model. I assume I need to embed or
include the images somehow - is that right? What concerns me is that
the squares don't show up either, but they do when I run it from
FlexBuilder.
-n

Nicole Bieber

unread,
Mar 14, 2010, 11:26:10 PM3/14/10
to 68...@googlegroups.com
Eh, nevermind - re-built the zip and it works this time. That was
weird. Huh.
-n

Ryan Ko

unread,
Mar 14, 2010, 11:27:52 PM3/14/10
to 68...@googlegroups.com
Any chance anyone is getting a TypeError: Error #1006: addChild is not a function. error?

Best,
Ryan Ko

Tobe Nwanna

unread,
Mar 14, 2010, 11:28:16 PM3/14/10
to 68...@googlegroups.com
How are people getting New Game to load for both models when you click
it on Strokes initially? I've got everything else working but
this...I've gone through the code and don't get why the images won't
draw when I click it.

David Crowell

unread,
Mar 14, 2010, 11:29:48 PM3/14/10
to 68...@googlegroups.com
Thanks, the stackoverflow link was useful. Another issue I'm
encountering which seems strange. I keep getting a broken image when
I try to add an image from AS code. So this works:

<mx:Image id="loader1" visible="false"
source="@Embed(source='../assets/black-king.png')"/>

but this:

<mx:Script>
<![CDATA[
var card:Image = new Image();
card.source = "@Embed(source='../assets/black-king.png')";
this.addChild(card);
]]>
</mx:Script>

gives me a broken image. What the hell?

Maria Guirguis

unread,
Mar 14, 2010, 11:35:56 PM3/14/10
to 68...@googlegroups.com
For me, it doesn't like the relative path :/

Maria Guirguis
Massachusetts Institute of Technology
Electrical Engineering and Computer Science BS '09, MEng '10

Alex Jiang

unread,
Mar 14, 2010, 11:37:41 PM3/14/10
to 68...@googlegroups.com
In Main, under TabNavigator, add creationPolicy = "all". This way both
tabs are updated initially.

Wolfe Styke

unread,
Mar 14, 2010, 11:39:57 PM3/14/10
to 68...@googlegroups.com
@ David: You want to use this inside the Script:

card.source =  card.source = "assets/black-king.png"; 

Don't use the "../" part in front, as that doesn't point where you think it does, unless you've changed your folder hierarchy from how it's given.

~ Wolfe

Tobe Nwanna

unread,
Mar 14, 2010, 11:40:14 PM3/14/10
to 68...@googlegroups.com
Thanks! Now I'm finally done!

Jennifer Li

unread,
Mar 14, 2010, 11:48:14 PM3/14/10
to 68...@googlegroups.com
for some reason, when I tried the creationPolicy method, it actually broke my PixelBoard.. now my pixelboard thinks the board is always null for some reason..

has anyone seen this problem?
--
Jennifer Li
Massachusetts Institute of Technology
Department of Electrical Engineering and Computer Science
Class of 2011

Tsung-Hsiang (Sean) Chang

unread,
Mar 12, 2010, 11:37:43 PM3/12/10
to 68...@googlegroups.com, Sean Liu (MIT), Jennifer Chan
No. In fact, you are not supposed to change the files other than PixelCheckerBoard.mxml and StrokeCheckerboard.mxml.
 
Sean

On Fri, Mar 12, 2010 at 9:37 PM, Peter Nga <hl...@mit.edu> wrote:
Does anybody know if we're supposed to support different board sizes when using "Different models" (i.e. have the strokes board of size 4 and have the pixels board of size 8)?

Steven Bartel wrote:
If you look at Checkerboard.mxml, it shows you how to handle this.  You have to add a ChangeListener, that listens changes in board (i.e. when it is set).  Your change listener can call a function that adds the listeners for your events.  Alternatively, override Checkerboard's version of paint, which gets called once or twice, depending on whether the board has been initialized.  In both cases, make sure to check if (!board) to see if it's null.


Good luck,

-Steve

--
Steven Bartel
Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology 2010
Phone: (617) 312-7225


On Mar 12, 2010, at 6:02 PM, Sean Liu (MIT) wrote:

How do we register for events in StrokeCheckerboard?

I'm trying to bind to the "BoardEvent"s like "add", "remove", etc.  I overrode the "onLoad", and was going to put a board.addEventListener, except board is still null when the onLoad is called...

Any help?

Thanks!
Sean

On Fri, Mar 12, 2010 at 2:55 AM, Nora Mallory <emall...@gmail.com <mailto:emall...@gmail.com>> wrote:

   Got it! Thanks!


   --
   Eleanor Mallory

   Massachusetts Institute of Technology
   Department of Electrical Engineering and Computer Science
   Class of 2011


   <mailto:emall...@gmail.com>



   On Fri, Mar 12, 2010 at 2:55 AM, Jennifer Chan <jpc...@mit.edu
   <mailto:jpc...@mit.edu>> wrote:

       It depends on which object's graphic object you are using.
        For example, if you make a new shape and call beginFill
       (like shape.grapihcs.beginFill(color)), in order for it to
       show up, you have to add the shape object to the parent with
       addChild.  Make sure the beginFill, drawCircle, and any other
       drawing operations are applied to the graphics object of the
       checkerboard itself.

       Hope that helps...
       Jenny


       On Fri, Mar 12, 2010 at 2:26 AM, Nora Mallory
       <emall...@gmail.com <mailto:emall...@gmail.com>> wrote:

           Yeah, I can see how to use all the constants that they
           gave us.  However, I'm looking all over teh interwebs,
           and everything I see about drawing things in Flex
           involves using addChild.  I did beginFill and drawCircle
           and nothing shows up unless I then call addChild.

           --
           Eleanor Mallory

           Massachusetts Institute of Technology
           Department of Electrical Engineering and Computer Science
           Class of 2011

           (773) 980-6672
           el...@mit.edu <mailto:el...@mit.edu> |

           emall...@gmail.com <mailto:emall...@gmail.com>



           On Fri, Mar 12, 2010 at 2:13 AM, Steven Bartel
           <sba...@mit.edu <mailto:sba...@mit.edu>> wrote:

               I'm pretty sure they just want you to draw circles
               with certain radii, at certain x,y positions.  It's
               done almost exactly the same as drawing the squares
               for checkers.  There are a few constants that tell
               you how many pixels per square, the colors, and the
               radius for the circles.  You should be able to use
               those to figure out a position, color, and radius,
               for a given checker and draw it.

               -Steve

               --
               Steven Bartel
               Department of Electrical Engineering and Computer Science
               Massachusetts Institute of Technology 2010
               Phone: (617) 312-7225




               On Mar 12, 2010, at 2:08 AM, Nora wrote:

                   When you say that the StrokeCheckerboard cannot
                   have child components,
                   does that mean that we can't use
                   this.rawChildren.addChild(x) in
                   addition to just not calling this.addChild(x)?






       --         Jennifer Chan
       MIT Class of 2011

       Department of Electrical Engineering and Computer Science
       jpc...@mit.edu <mailto:jpc...@mit.edu>






--
Sean Liu
Massachusetts Institute of Technology

Department of Electrical Engineering & Computer Science '10





--
Tsung-Hsiang Chang
Reply all
Reply to author
Forward
0 new messages