[Newbies] OrderedCollection if imageMorphs

Christine Wolfe cwdw01 at earthlink.net
Sat Nov 7 15:28:54 UTC 2009


I want to put add an imageMorph on top of another imageMorph.

 

I can do this with the following method (note SymbolBlank is an imageMorph

MyBoard>>addSymbol

|im|

im := SymbolBlank new.

self addMorph: im.

im topLeft: 2 at 2.

 

I want to enhance this so I can choose one of a collection of imageMorphs to
add.

 

I created a class, SymbolArray, that is a subclass of OrderedCollection with
the following initialize method. Each of the items I'm adding (SymbolBlank,
SymbolGet, etc) is an imageMorph.

 

SymbolArray>>initialize

super initialize.

self add: SymbolBlank new.

self add: SymbolGet new.

self add: SymbolProcess new.

self add: SymbolPut new.

self add: SymbolIf new.

self add: SymbolWhile new.

 

Then I tried to modify the addSymbol method as show below.

When I do, I get the following error message which sounds like I don't have
an element at index 1.

SymbolArray(OrderedCollection)>>errorNoSuchElement

SymbolArray(OrderedCollection)>>at:

 

| sa si |

sa := SymbolArray new.

si := sa at: 1.

self addMorph: si.

si topLeft:  2 at 2.

 

I hope someone can help me figure out how to accomplish what I want to do.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20091107/7b5a47dd/attachment.htm


More information about the Beginners mailing list