Bert, I followed your suggestion for making an orderedcollection and just adding ImageMorph as the items in the collection. Now I am trying to figure out how to assign an image to each item and then display it in another morph.
Here's what I have so far but I can't get it to show up. newCellAt: i at: j | c sa leftValue topValue | sa := OrderedCollection new. sa add: ImageMorph new. sa add: ImageMorph new. sa add: ImageMorph new. c := sa at: 2. c image: (Form fromFileNamed: 'FCIf.png'). leftValue := 10. c width: 100. topValue := 20. c height: 70]. c position: (leftValue) @ (topValue). owner addMorph: c. -----Original Message----- From: beginners-boun...@lists.squeakfoundation.org [mailto:beginners-boun...@lists.squeakfoundation.org] On Behalf Of Bert Freudenberg Sent: Monday, November 09, 2009 11:25 AM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] OrderedCollection if imageMorphs On 09.11.2009, at 02:08, Christine Wolfe wrote: > Oh wow! thanks - having the sample code will be a huge help. I'll > give it a > try. > > -----Original Message----- > From: Randal L. Schwartz [mailto:mer...@stonehenge.com] > Sent: Sunday, November 08, 2009 8:03 PM > To: Christine Wolfe > Cc: beginners@lists.squeakfoundation.org > Subject: Re: [Newbies] OrderedCollection if imageMorphs > >>>>>> "Christine" == Christine Wolfe <cwd...@earthlink.net> writes: > > Christine> Oh, I'm so so sorry - I thought it was OK to ask dumb > questions > on > Christine> the newbie forum (blush) I'll try to figure out how to > make an > Christine> instance variable an order collection. > > It's perfectly OK, and that's why you were corrected. :) > > Basically, you'll do the following: > > * add an instance variable: contents > > on your instance side, add: > > initialize > super initialize. > contents := OrderedCollection new. > > then for each item of the collection protocol, delegate it, as in: > > add: anItem > ^contents add: anItem. > > includes: anItem > ^contents includes: anItem. > > size > ^contents size. > > and so on. If you get really tired of adding all of them, > just add them as you need them (when the debugger tells you :). Why would you want to add all these methods and your own class in the first place? They are there already, perfectly usable. > If you wanna get really tricky, you can add a #doesNotUnderstand: > handler to > perform the method on the contents variable, but that can mess up your > debugging, so it's better if you don't. Err, now that goes into the land of advanced applied magic. Please ignore that last paragraph ;) Christine, if you want an OrderedCollection of ImageMorphs (as you wrote in the subject) then do just that. Create an OrderedCollection, not a subclass of it. And add ImageMorphs, not subclasses of ImageMorphs (unless they indeed do specific processing - but even then I'd probably make only one ImageMorph subclass and customize that). It is often unnecessary to create your own classes for everything. For example, if the only difference of a regular ImageMorph and your own Morph subclass is the image it shows, then do not create a subclass. Just assign the right image. And maybe assign an event handler, no need for subclassing there either. OTOH, when I look at your high-level goal "I'm making a pinball machine in which the little ball follows the order of execution of a student entered flowchart" I don't really see the need for a "SymbolArray" nor even "OrderedCollection of ImageMorphs". Maybe you should design the UI first and then implement whatever is necessary to make it work? - Bert - _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners