Skip to main content
Participating Frequently
February 9, 2007
Question

Delegates in FMS

  • February 9, 2007
  • 3 replies
  • 425 views

Hi has anybody managed to get some sort of scoping class/object like a Delegate or Proxy to work with SERVER SIDE ACTIONSCRIPT?

Not having much luck myself.

Cheers
    This topic has been closed for replies.

    3 replies

    Inspiring
    February 12, 2007
    hello :)

    SSAS = javascript 1.5 based on ECMASCript 262 (ed3)

    you can use OOP with the same tools in AS1 and AS2 (because AS2 == AS1
    in the bytecode of the swf)

    When you create a class in SSAS or AS1 you use a constructor method to
    create your class

    MyClass = function()
    {
    // the constructor
    }

    You can add method in your class with the prototype object :

    MyClass.prototype.myMethod = function()
    {
    trace(this + " : " + myMethod) ;
    // the code of your method
    }

    To use the class (or constructor function) you use the new keyword

    var myInstance = new MyClass() ;
    myInstance.myMethod() ;


    In my framework i decorate the Function prototype and you can use the
    method "extend" to extends your class

    ClassA = function()
    {

    }

    ClassA.prototype.methodA = function() {} ;


    ClassB = function()
    {

    }

    ClassB.extend(ClassA) ;

    ClassB.prototype.methodB = function() {} ;

    var i = new ClassB() ;
    i.methodA() ; // ok it work !! the ClassB extends ClassA

    in SSAS you must write you code with the ECMASCript and javascript 1.5 DOM.

    My SSAS framework use a polymorphism with the AS2 framework... you can
    use the same class ( or almost because the SSAS library is based on
    Core2 : http://code.google.com/p/core2/ )


    For me all tools in SSAS are the sames in AS2 (event model, remoting
    tools, logging framework based on the AS3 mx.logging framework etc...)

    the next month i'm going to implement IOC tools in SSAS based on
    Sprint.NET implementation and EDEN format to create the external
    application builder file (
    http://www.martinfowler.com/articles/injection.html )

    For me i wait the next version of FMS... i hope a Javascript2 or AS3
    core SSAS API.

    EKA+ :)


    alanskinner a écrit :
    > excellent thanks!
    >
    > One thing though - is this framework written in AS2 or use classes.
    >
    > You cant use class {} in SSAS can you or am i wrong in that?
    Participating Frequently
    February 12, 2007
    excellent thanks!

    ok i tried this

    this.XMLObject.onLoad = new vegas.events.Delegate(p_client, p_client.callbackHandler); // both valid...

    now i would normally use delegate in the above way

    but i get the following error

    Sending error message: ## TypeError : object is not a function ##

    is it talking about the first parameter?

    im not to osure about your o and action variables and how they would relate to my code situation

    Cheers
    Inspiring
    February 9, 2007
    Hello :)


    You can use my OpenSource Framework VEGAS with this SSAS version :
    http://vegas.riaforge.org/

    1 - download VEGAS with the SVN or the zip in RIAFORGE

    2 - insert the content of the directory : SSAS/trunk/src/ in your
    application directory or in the Scriplibs directory in the FMS server
    install path.

    http://svn.riaforge.org/vegas/SSAS/trunk/src/

    3 - in your main.asc write :

    load("src/vegas.asc") ;

    And now you can use my framework :)

    The vegas.events.Delegate class is like the mx.utils.Delegate class and
    more !

    Example 1 :

    var o = {} ;
    o.toString = function ()
    {
    return "[myObject]" ;
    }

    var action = function ()
    {
    trace(this + " - action") ;
    var l = arguments.length ;
    for (var i = 0 ; i<l ; i++)
    {
    trace(" > " + arguments ) ;
    }
    }

    var fProxy = vegas.events.Delegate.create(o, action, "arg3") ;
    fProxy("arg1", "arg2") ;

    Example 2 :

    var fProxy = new Delegate(o, action, "arg3") ;
    fProxy.run("arg1", "arg2") ;

    My framework is the same in AS2 ... you can read the AS2 documentation
    of VEGAS in the AS2/trunk path or in my web site :
    http://www.ekameleon.net/vegas/docs/

    (warning... vegas is the same in SSAS, in SSAS ASGard and the remoting
    package is the same too.. but in SSAS you can use PEGAS, LUNAS etc..
    it's only AS2 libraries.)

    EKA+ :)



    alanskinner a écrit :
    > Hi has anybody managed to get some sort of scoping class/object like a Delegate or Proxy to work with SERVER SIDE ACTIONSCRIPT?
    >
    > Not having much luck myself.
    >
    > Cheers