--- In [email protected], "David Terry" <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> First, let me apologize. I am very, very new to Flex 2 & ActionScript
> 3, and the learning process has been very slow going and painful.
>
1st suggestion, since there is a LACK of flex 2 books, go onto lyndia.com, sign
up for 1
month (about 25 buckos) and watch the 2 videos on flex (actionscript 3 videos
are
somewhat useful also).
2nd, components come in both small and large size. Small ones are the ones
that come
with flex that you drag onto the canvas to build your user interface (UI). Big
ones are what
YOU program, they consist of the small components and actionscript code
(Business
Logic). Sometimes you want to turn off, move, resize some of the small
components. This
is where states comes in. You can define multiple states for each of your
components that
accomplish this. (Transitions make the state change "pretty" with animation,
but since you
are a beginner, don't worry about them yet.
> I truly do not understand the relationship between components, states,
> and transitions.
As others have already said, the best (NOT ONLY!) way to have components
communicate
is to have one component send a message (Raise an event) and have another one
Listen
for that event.
Sending a msg is as simple as having a line of actionscript with something like:
dispatchEvent(new Event("MY EVENT")
(Yes, there are a LOT of refinements, like using a static variable to minimize
typos, but
again, lets learn to walk first!)
When you dispatch an event, ALL components above this one (in other words, not
CHILDREN, but PARENTS) will Hear this event. You determine which one will
respond to it
(can be more than one) by adding an event listener. This is usually done in
the init
function of the tasks that you want to handle (listen to) this event. That
code looks
something like:
private function init() : void {
model.addEventListener(LAST_ORDER, doLastOrder);
}
All i need now is a function called doLastOrder that will be executed whenever
the
LAST_ORDER event is raised.
Hope this helps a little
bruce