TiiToo / vegas

Automatically exported from code.google.com/p/vegas
1 stars 0 forks source link

EventDispatcher returns odd type #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I checked out the trunk version in AS3 and Flex Builder 3.

According to the tutorial, this should work:
import vegas.events.EventDispatcher;
var dispatcher:EventDispatcher = vegas.events.EventDispatcher.getInstance();

The above results in an error.

The following works:
var dispatcher:vegas.events.EventDispatcher =
vegas.events.EventDispatcher.getInstance();

The reason for this appears to be that there is a naming conflict since
flash.events.EventDispatcher is imported and can't return the
EventDispatcher type.

Anyway... I am still a few weeks new to AS so I don't know if this is
possible to work around.  I did attempt the following but it didn't appear
to work:
class EventDispatcherGlue extends EventDispatcher then EventDispatcher
extends EventDispatcherGlue.

Original issue reported on code.google.com by ces....@gmail.com on 20 Jan 2008 at 5:05

GoogleCodeExporter commented 9 years ago
In Flex2 and in Flash CS3 my code work.. Thanks for this feedback :)

EKA+ :)

Original comment by ekamel...@gmail.com on 20 Jan 2008 at 9:29

GoogleCodeExporter commented 9 years ago
Update your SVN and test it now :) I use a vegas.events.AbstractEventDispatcher 
class
to creates the hack.

I must install the Flex Builder 3 to test this new implementation but for the 
moment
work in Flex2 and Flash CS3 :)

Original comment by ekamel...@gmail.com on 20 Jan 2008 at 10:07

GoogleCodeExporter commented 9 years ago
Didn't work.. and I totally forgot to post the error message I was getting.

Here is the error message I get both before and after the change:
1046: Type was not found or was not a compile-time constant: EventDispatcher.
sandman/src sandman.mxml    line 10 1200850385518   2055
1120: Access of undefined property 
EventDispatcher.    sandman/src sandman.mxml    line
10  1200850385518   2056
Can not resolve a multiname reference unambiguously. 
flash.events:EventDispatcher
(from /Applications/Adobe Flex Builder
3/sdks/3.0.0/frameworks/libs/player/playerglobal.swc(EventDispatcher)) and
vegas.events:EventDispatcher (from /Users/work/Documents/Flex Builder
3/sandman/vegas/vegas/events/EventDispatcher.as) are available. sandman/src
sandman.mxml    Unknown 1200850385479   2053

You can download and try the Flex Builder 3 Beta 3 for free.  You can have both 
Flex
Builder 2 and 3 installed without any conflicts.

Original comment by ces....@gmail.com on 20 Jan 2008 at 5:36

GoogleCodeExporter commented 9 years ago
I have test my EventDispatcher class in FlexBuilder 3 with an AS3 project and 
an Flex
Project and all it's work fine.

I can use both class flash.events.EventDispatcher and 
vegas.events.EventDispatcher in
the same time, 

example AS3 :

{{{
package 
{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.EventDispatcher;

    import vegas.errors.*;
    import vegas.events.EventDispatcher;
    import vegas.logging.*;
    import vegas.logging.targets.SOSTarget;

    public class Application extends Sprite
    {
        public function Application()
        {

            // setup target
            var target:SOSTarget = new SOSTarget("application", 0xD8F394) ;
            target.filters = ["myApplication", "vegas.errors.*"] ; // use a empty array to
receive all logs.
            target.includeLines = true ;
            target.level = LogEventLevel.ALL ; 

            // register target
            Log.addTarget(target); 

            // create a log writer
            logger = Log.getLogger("myApplication") ;

            var dispatcher1:vegas.events.EventDispatcher =
vegas.events.EventDispatcher.getInstance() ;
            dispatcher1.addEventListener( Event.CHANGE , change ) ;
            logger.debug(dispatcher1) ;

            dispatcher1.dispatchEvent( new Event( Event.CHANGE ) ) ;

            var dispatcher2:flash.events.EventDispatcher = new flash.events.EventDispatcher() ;
            dispatcher2.addEventListener(Event.CHANGE, change) ;

            logger.debug(dispatcher2) ;

            dispatcher2.dispatchEvent( new Event( Event.CHANGE ) ) ;

        }

        public var PacMan:MovieClip ;

        /**
         * @
         */
        public var logger:ILogger ;

        public function change( e:Event ):void
        {
            logger.debug(e) ;   
        }

    }
}
}}}

Example MXML : 
{{{
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 

        xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout="absolute" 
        xmlns:test="test.*"
        creationComplete="onComplete(event)"

>

    <mx:Script>
        <![CDATA[

            import flash.display.Sprite;
            import flash.events.Event;
            import flash.events.EventDispatcher;

            import vegas.errors.*;
            import vegas.events.EventDispatcher;
            import vegas.logging.*;
            import vegas.logging.targets.SOSTarget;

            public function onComplete( event:Event ):void
            {

                var target:SOSTarget = new SOSTarget("application", 0xD8F394) ;
                target.filters = ["myApplication", "vegas.errors.*"] ; // use a empty array to
receive all logs.
                target.includeLines = true ;
                target.level = LogEventLevel.ALL ; 

                // register target
                Log.addTarget(target); 

                // create a log writer
                LOGGER = Log.getLogger("myApplication") ;

                var dispatcher1:vegas.events.EventDispatcher =
vegas.events.EventDispatcher.getInstance() ;
                dispatcher1.addEventListener( Event.CHANGE , change ) ;
                LOGGER.debug(dispatcher1) ;

                dispatcher1.dispatchEvent( new Event( Event.CHANGE ) ) ;

                var dispatcher2:flash.events.EventDispatcher = new flash.events.EventDispatcher() ;
                dispatcher2.addEventListener(Event.CHANGE, change) ;

                LOGGER.debug(dispatcher2) ;

                dispatcher2.dispatchEvent( new Event( Event.CHANGE ) ) ;

            }

            public static var LOGGER:ILogger ;

            public function change( e:Event ):void
            {
                LOGGER.debug(e) ;   
            }

        ]]>
    </mx:Script>

</mx:Application>
}}}
Works fine :)

Original comment by ekamel...@gmail.com on 21 Jan 2008 at 10:35