|
Home > Archive > Macromedia Flash Server > June 2005 > Mediator Class in AS2?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Mediator Class in AS2?
|
|
| Sean Moran 2005-06-16, 2:45 am |
|
Been working through the FCS book, and I am a bit thrown off by the
Mediator / PlayBack /NetStream subclass example as I have pretty
much dropped in to actionscript at the 2.0 level and most of my
coding has been done (er, hacked) in AS2.
Any examples of a NetStream Mediator / Director kind of thing is AS2?
TIA,
Sean
=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
| |
| Sean Moran 2005-06-16, 2:45 am |
|
As a possible answer to my question - would a good example be the
NSManager.as in Peldi's FLVPlayer??
;)
Sean
On Jun 15, 2005, at 10:12 PM, Sean Moran wrote:
>
> Been working through the FCS book, and I am a bit thrown off by the
> Mediator / PlayBack /NetStream subclass example as I have pretty
> much dropped in to actionscript at the 2.0 level and most of my
> coding has been done (er, hacked) in AS2.
>
> Any examples of a NetStream Mediator / Director kind of thing is AS2?
>
> TIA,
>
> Sean
>
>
> =-----------------------------------------------------------
> Supported by Fig Leaf Software - http://www.figleaf.com
> =-----------------------------------------------------------
>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
>
=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
| |
| Brian Lesser 2005-06-16, 5:45 pm |
| Hi Sean,
A mediator, sometimes also called a director, is just a custom object
designed to coordinate the work of other objects and UI components. The
mediator sets itself up as a listener on the UI components and perhaps
on a NetStream. The mediator responds to events like the stream ending
or someone pressing a play button. The mediator often can keep track of
what state it is in. For example if you have a mediator that controls
stream playback it could keep track of the fact the stream is in a
"playing" state. Depending on what state it is in it can react to events
in different ways if that is necessary. On page 178 the PlayBackDirector
is a simple mediator class that controls stream playback and user
interface elements.
The PlayBackDirector works with a subclass of the NetStream class. Why
did I bother doing that? Because the status events you get back from a
NetStream class don't tell you what state the stream is in. So I made a
NetStreamPlaybackClass that figures out what state it is in based on the
status events it receives. In turn it sends out events describing what
state it is in. For example it sends events called: "buffering",
"playing", "paused". Those events are a lot easier to handle than lower
level events like NetStream.Buffer.Empty. So the NetStreamPlaybackClass
sends higher level events to the PlaybackDirector. The PlayBackDirector
responds by changing the user interface the user sees.
I hope that makes sense.
Yours truly,
-Brian
Sean Moran wrote:
>
> Been working through the FCS book, and I am a bit thrown off by the
> Mediator / PlayBack /NetStream subclass example as I have pretty
> much dropped in to actionscript at the 2.0 level and most of my
> coding has been done (er, hacked) in AS2.
>
> Any examples of a NetStream Mediator / Director kind of thing is AS2?
>
> TIA,
>
> Sean
>
>
> =-----------------------------------------------------------
> Supported by Fig Leaf Software - http://www.figleaf.com
> =-----------------------------------------------------------
>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
| |
| Sean Moran 2005-06-16, 5:45 pm |
|
Brian,
Thanks. Yes it makes a lot of sense - it is just that I have never
gotten my head around prototypes and mixing as1 and as2 is not a good
idea.
I have taken some of the logic of your code and some of the examples
in the FLVPlayer code and come up with something, but it is still to
project specific for my tastes. But at least it is working ;)
95% of our stuff deal with pre recorded streams so catching the end
has been a pain - well, not really, but trying to "reset" the player
with a ns.seek(0) and clearing out the status txt display (would show
"buffering" of course) was lots of fun.

Sean
On Jun 16, 2005, at 7:58 AM, Brian Lesser wrote:
>
> Hi Sean,
> A mediator, sometimes also called a director, is just a custom
> object designed to coordinate the work of other objects and UI
> components. The mediator sets itself up as a listener on the UI
> components and perhaps on a NetStream. The mediator responds to
> events like the stream ending or someone pressing a play button.
> The mediator often can keep track of what state it is in. For
> example if you have a mediator that controls stream playback it
> could keep track of the fact the stream is in a "playing" state.
> Depending on what state it is in it can react to events in
> different ways if that is necessary. On page 178 the
> PlayBackDirector is a simple mediator class that controls stream
> playback and user interface elements.
> The PlayBackDirector works with a subclass of the NetStream class.
> Why did I bother doing that? Because the status events you get back
> from a NetStream class don't tell you what state the stream is in.
> So I made a NetStreamPlaybackClass that figures out what state it
> is in based on the status events it receives. In turn it sends out
> events describing what state it is in. For example it sends events
> called: "buffering", "playing", "paused". Those events are a lot
> easier to handle than lower level events like
> NetStream.Buffer.Empty. So the NetStreamPlaybackClass sends higher
> level events to the PlaybackDirector. The PlayBackDirector responds
> by changing the user interface the user sees.
> I hope that makes sense.
> Yours truly,
> -Brian
>
>
=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
|
|
|
|
|