Hello All,

I am trying to figure out how to use the ObserveValue Component, when I
use it inside of a Class File.

In all the examples I've seen, they all utilize the Class File as a MXML
Component - and when I use it in this manner, it works just fine.

BUT, I really need to use this inside my Class Files - and as far as I
can tell, I should be able to import the Class File, and create a new
variable - casting it as an ObserveValue() - but when I use it this way,
nothing happens.

Per the examples, here is the proper use of the file:

<ac:ObserveValue 
        id="valueObserver" 
        source="{ model.myVarToBeWatched }" 
        handler="valueObserverHandler" 
        value="true"/>

Now, I'd like to use it using pure ActionScript - and here's what I got
so far: (keep in mind, the AS Class File below, is extending the Control
in which it belongs to - and rest assured, that I am placing all the
appropriate code within all the proper Event Listeners, like
onCreationComplete, etc.)  I am just keeping it simple, for this
particular post.

package
{
        import com.adobe.ac.*;
        
        class myClass extends Panel
        {
                private var myObserve:ObserveValue = new ObserveValue();
                [Bindable]
                public var model:ApplicationModel =
ApplicationModel.getInstance();
                
                public function myClass():void
                {
                        initObservers();
                }
                
                private function initObservers():void
                {
                        myObserve.source = model.myVarToBeWatched;
                        myObserve.handler = valueObserverHandler;
                        myObserve.value = true;
                }
                
                private function valueObserverHandler( event:Event
):void
                {
                        trace( "it worked" );
                }
        }
}

In my real code, I wait for the Creation Complete Event, before I
initialize all of my Event Listeners, etc.  So you can assume that my
real code, is properly setup.

My real question here is, when creating component written purely in AS3,
can they be used either way - like as an inline Component in MXML, or if
you choose, referenced within an AS3 Package?  I don't see why not,
since MXML Controls are all just Class Files anyway...

So I just wanted to know if somebody could shed some light on what I'm
doing wrong, or if the ObserveValue Class just wasn't designed to be
used in this manner.

Thanks in advance for all your help,

Mike

Reply via email to