Instance variable question....
Ned Konz
ned at bike-nomad.com
Wed Mar 19 15:38:35 UTC 2003
On Wednesday 19 March 2003 12:40 am, Brian Brown wrote:
> Greetings!
>
> I'm playing with a Morph copied from IconicButton that displays an
> MPEGDisplayMorph instead of a Form as it's graphic. The idea is to
> be able to start and stop the movie by clicking the button. I have
> it *mostly* working, but I wanted to something like the following
> as my actionSelector:
>
> playToggle
> "Toggle the movie playing"
>
> (theMovie running)
> ifFalse: [theMovie startPlaying.]
> ifTrue: [theMovie stopPlaying.]
>
> theMovie is an instance variable that points to my
> MPEGDisplayMorph; if I instantiate one of these "MovieButton"
> objects, I can start and stop the movie by evaluating:
>
> buttonInstance target startPlaying
>
> but trying to call playToggle or even trying to evaluate the
> instance variable: running (part of MPEGDisplayMorph) gives a
> message not understood. Am I simply not accessing or evaluating
> that instance variable correctly?
The instance variable "running" in MPEGDisplayMorph has no accessors.
You can make one, though, and then call it.
You can't access instance variables of an object (easily) from another
object. When objects want to make some of their internal state
public, their class can provide an accessor.
So if you define
MPEGDisplayMorph>>running
^running
You can then get to it from outside.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|