RE: [Flashcoders] var (eventHandler)

2007-02-07 Thread Kalani Bright
you shouldn't var any functions even though technically that is correct.

also anything withoug a access keyword is defaulted to private which means
you can only access it from the class.

so to answer your question

public function onEnterFrame():Void
{
//code here
} 
The void means you are not using a return.
if you are doing actionscript 1.0 then technically that is okay...

so something like 

var myFunction = function ()
{
//code here
}

is what you should be using but that is 1.0 and not for classes.  


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of eric cash
Sent: Tuesday, February 06, 2007 7:42 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] var (eventHandler)

Okay, I'm guessing it's a stupid question, so I'll get over it asap.
I've never written a custom class before, and have recently started to code
things in Flash which are much more complex, approaching application status,
so I'm trying to wwrap my head around all of this OOP stuff.  I keep running
into something that I can't get though...  
using the VAR keyword when declaring event handlers, like this example from
Object-Oriented Actionscript for Flash 8:

var onEnterFrame:Function = doSomething;

I've Googled my [EMAIL PROTECTED] off, and I can't get it to save my life, and 
this seemed
like the best place to ask.  Will one of you take a couple minutes out of
your day to help a poor guy out?

Thanks

ec
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] var (eventHandler)

2007-02-07 Thread Muzak

 also anything withoug a access keyword is defaulted to private which means
 you can only access it from the class.


That's not correct, it's public by default.

regards,
Muzak 


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] var (eventHandler)

2007-02-06 Thread eric cash

Okay, I'm guessing it's a stupid question, so I'll get over it asap.
I've never written a custom class before, and have recently started to 
code things in Flash which are much more complex, approaching 
application status, so I'm trying to wwrap my head around all of this 
OOP stuff.  I keep running into something that I can't get though...  
using the VAR keyword when declaring event handlers, like this example 
from  Object-Oriented Actionscript for Flash 8:


var onEnterFrame:Function = doSomething;

I've Googled my [EMAIL PROTECTED] off, and I can't get it to save my life, and this 
seemed like the best place to ask.  Will one of you take a couple 
minutes out of your day to help a poor guy out?


Thanks

ec
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] var (eventHandler)

2007-02-06 Thread Jason Boyd

It's possible you are getting confused in further details about event
handling. There is some invisible stuff happening here that goes
beyond just understanding classes and objects. Buttons and MovieClips
are registered listeners of mouse events automatically. What this
means is that an event broadcaster will call specific methods of any
button or movie clip. By default, however, these methods do not exist
-- that is, there are no such properties as onMouseMove, onRelease,
etc.

In a class, you would define methods (normally) in the class definition:

class MyThing {
 function onRelease() {
   doSomething();
 }
}

However with buttons and clips you often are dealing with an object
(aka instance), rather than the class, so you can take advantage of
ActionScript's allowing dynamic properties. This feature means you can
add new methods and properties to object instances that were not
defined in the class:

var obj:Object = new Object();
obj.new_prop = foo;
obj.doSomething = function () { trace something; }

And so, with a button or clip, you can assign an event handler:

my_mc.onRelease = function() {
 // respond to mouse click
}

Once this method exists in the object, it will respond to this event,
which it has previously been receiving and ignoring.
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] var (eventHandler)

2007-02-06 Thread Hairy Dog Digital
Eric,

The example you're referring to comes up when the authors of that text are
explaining the concept of encapsulation. It's a way of creating an
onEnterFrame event on the same timeline as the code. It doesn't actually
have anything to do with classes.

If you have a class that extends the movieClip class and want an object of
that class to do something at each enterFrame event, you'd want to use
something such as:

class myMovieClips extends MovieClip {

// PRIVATE METHODS
private function doSomething():Void {
// code here
}

// EVENT HANDLERS
function onEnterFrame():Void {
this.doSomething();
}
}

Make more sense? HTH!

...Rob

_
Rob Emenecker
Hairy Dog Digital
410.694.3575 (arf)
410.694.3550 (fax)
www.HairyDogDigital.com
 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of eric cash
Sent: Tuesday, February 06, 2007 10:42 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] var (eventHandler)

Okay, I'm guessing it's a stupid question, so I'll get over it asap.
I've never written a custom class before, and have recently started to code
things in Flash which are much more complex, approaching application status,
so I'm trying to wwrap my head around all of this OOP stuff.  I keep running
into something that I can't get though...  
using the VAR keyword when declaring event handlers, like this example from
Object-Oriented Actionscript for Flash 8:

var onEnterFrame:Function = doSomething;

I've Googled my [EMAIL PROTECTED] off, and I can't get it to save my life, and 
this seemed
like the best place to ask.  Will one of you take a couple minutes out of
your day to help a poor guy out?

Thanks

ec

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com