question for ps4

18 views
Skip to first unread message

Chris Cheng

unread,
Apr 3, 2010, 5:10:52 PM4/3/10
to 68...@googlegroups.com
Hello,

This question is mainly directed at the staff, although for ps4, does anyone know for part 2 whether it's acceptable to click on the tiny amount of whitespace around the checker in the checker image to move it?  The checker in the image is not exactly a circle, so is it acceptable to click anywhere on the image or do we have to look within the image data to find the non-transparent pixels?

Thanks,
Chris

--
Christopher Cheng
Massachusetts Institute of Technology
Class of 2010/(2011 Masters of Engineering)
Computer Science and Engineering

Igor Kopylov

unread,
Apr 3, 2010, 6:14:47 PM4/3/10
to 68...@googlegroups.com
It's fine if the checker can be picked up by the empty corner of its containing square. Alternatively, you could use the checker radius to figure out the appropriate hit area. One of the Going Further suggestions has a tip about how you could use pixel data for hit testing in the PixelCheckerboard.

-Igor

Alan Anderson

unread,
Apr 3, 2010, 6:15:39 PM4/3/10
to 68...@googlegroups.com

For problem 2, we are supposed to use event.target to figure out which component is getting dragged, but it seems like event.target returns an object? variable.

How can I convert this to a UIComponent?  Casting didn't work.

Maria Rodriguez

unread,
Apr 3, 2010, 7:27:45 PM4/3/10
to 68...@googlegroups.com
Casting does work. Try: (UIComponent)(event.target)


On Sat, Apr 3, 2010 at 6:15 PM, Alan Anderson <ala...@mit.edu> wrote:

For problem 2, we are supposed to use event.target to figure out which component is getting dragged, but it seems like event.target returns an object? variable.

How can I convert this to a UIComponent?  Casting didn't work.




--
Maria I. Rodriguez
Massachusetts Institute of Technology
Electrical Engineering & Computer Science
Class of 2011

Ted Tomlinson

unread,
Apr 3, 2010, 7:30:06 PM4/3/10
to 68...@googlegroups.com
or use th AS keyword as in event.target as UIComponent

Yunus Sasmaz

unread,
Apr 3, 2010, 7:31:14 PM4/3/10
to 68...@googlegroups.com, Igor Kopylov
When I pick a checker by clicking the empty corner of its square and try to go
outside the checkerboard, it does not follow. I set setCapture to true, but
still the checker does not follow. However, it does follow if I pick the
checker by clicking on the checker (the non-empty circle).

Any suggestions here?

Yunus

----- Message from ig...@MIT.EDU ---------
Date: Sat, 3 Apr 2010 18:14:47 -0400
From: Igor Kopylov <ig...@MIT.EDU>
Reply-To: 68...@googlegroups.com
Subject: Re: question for ps4
To: 68...@googlegroups.com

> --
> To unsubscribe, reply using "remove me" as the subject.
>


----- End message from ig...@MIT.EDU -----


Maria Rodriguez

unread,
Apr 3, 2010, 8:25:37 PM4/3/10
to 68...@googlegroups.com
Whoops!

UIComponent(event.target) not (UIComponent)(event.target)

David Crowell

unread,
Apr 3, 2010, 9:31:06 PM4/3/10
to 68...@googlegroups.com
Hmm, I must be doing something wrong.  In my PixelCheckerboard, I create an Image and then call this.addChild(image) for each checker (on a move or add event).  This worked fine for the last problem set.  So I added a line here that is interactor.listenTo(image), interactor being an instance of MoveInteractor.  In the listenTo function, I add an event listener for MouseDown events to the image.

In that event listener I have "var component:UIComponent = UIComponent(event.target)";  I've also tried the as keyword.  In both situations I get an error "TypeError: Error #1034: Type Coercion failed: cannot convert mx.core::FlexLoader@5437f61 to mx.core.UIComponent".  

So I'm assuming that calling the listenTo function on an Image instance is wrong?

I thought this might be the case, so instead I just called listenTo on the pixel checkerboard as a whole.  This works whenever I click on a blank portion of the board, but when I click on a checker image I get the same error message.  

Ideas?

Olayemi A F Oyebode

unread,
Apr 3, 2010, 9:34:27 PM4/3/10
to 68...@googlegroups.com
I had this same problem. To load the image files, Flex uses a FlexLoader, so when you use event.target, you get back a FlexLoader object which is not a UIComponent. I use event.currentTarget instead. How are the people using event.target getting it to work? 

2010/4/3 David Crowell <dcro...@mit.edu>



--
Mr Olayemi A F Oyebode

Seak Meng Lay

unread,
Apr 3, 2010, 9:42:49 PM4/3/10
to 68...@googlegroups.com
Try

var target:UIComponent = UIComponent(event.currentTarget)

Ryan Ko

unread,
Apr 5, 2010, 2:17:59 AM4/5/10
to 68...@googlegroups.com
Still getting the coerce error message described above. Any fixes? thanks,

Ryan Ko
Massachusetts Institute of Technology Class of 2011
Department of Electrical Engineering and Computer Science
510.468.6998 || r...@mit.edu
Phi Kappa Theta Fraternity -- "Give, expecting nothing thereof."
Reply all
Reply to author
Forward
0 new messages