2 Replies Latest reply on Jun 28, 2006 12:17 PM by Newsgroup_User

    How to declare a new Data Type?

    ihtus
      I have a new Data type ( fxn ) declared in delphi, and i would like to convert the code to actionscript
      quote:


      type fxn=procedure(t:extended;x:array of extended;var f:array of extended);
      .....
      procedure fp(t:extended;x:array of extended;var f:array of extended);
      begin
      f[0]:=x[1];
      f[1]:=-sin(x[0])*(g/ll);
      end;
      ....

      procedure r_kutta6(eps,t0:extended;x0:array of extended;fnx:fxn;
      var t:extended;var x:array of extended);
      begin
      ...
      fnx(t0,x0,f); //means fp(t0,x0,f); - when applying the procedure.
      ...
      end;

      ...
      r_kutta6(0.0001,t0,xx0,fp,t,xx);




      how can i declare in actionscript such a new data type, and after - to use as i do in delphi
      thanks!
        • 1. Re: How to declare a new Data Type?
          Level 7
          ihtus,

          > how can i declare in actionscript such a new data type, and
          > after - to use as i do in delphi

          It goes without saying that any new datatype in ActionScript can only do
          what ActionScript is inherently capable of doing. Your sample code looks
          fine, in that regard. To declare a datatype in ActionScript 2.0, you'll
          have to write your own class.

          Check out Joey Lott's three-part ActionScript 2.0 Primer for details.

          http://www.person13.com/articles/


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: How to declare a new Data Type?
            Level 7

            If you want to pass a function (pointer) as an argument, you can just do so.

            function fp(t,x,f)
            {
            f[0]=x[1];
            f[1]= -Math.sin(x[0])*(g/ll);
            }

            function r_kutta6(eps,x0,fnx,t,x)
            {
            ...
            fnx(t0,x0,f); //means fp(t0,x0,f); - when applying the procedure.
            ...
            }

            r_kutta6(0.0001,t0,xx0,fp,t,xx);


            "ihtus" <webforumsuser@macromedia.com> wrote in message
            news:e7uhlp$qig$1@forums.macromedia.com...
            > I have a new Data type ( fxn ) declared in delphi, and i would like to
            convert
            > the code to actionscript
            >
            quote:


            > type fxn=procedure(t:extended;x:array of extended;var f:array of
            extended);
            > .....
            > procedure fp(t:extended;x:array of extended;var f:array of extended);
            > begin
            > f[0]:=x[1];
            > f[1]:=-sin(x[0])*(g/ll);
            > end;
            > ....
            >
            > procedure r_kutta6(eps,t0:extended;x0:array of extended;fnx:fxn;
            > var t:extended;var x:array of extended);
            > begin
            > ...
            > fnx(t0,x0,f); //means fp(t0,x0,f); - when applying the procedure.
            > ...
            > end;
            >
            > ...
            > r_kutta6(0.0001,t0,xx0,fp,t,xx);
            >
            >

            >
            > how can i declare in actionscript such a new data type, and after - to
            use as
            > i do in delphi
            > thanks!
            >