Skip to main content
Participant
June 28, 2006
Question

How to declare a new Data Type?

  • June 28, 2006
  • 2 replies
  • 207 views
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!
This topic has been closed for replies.

2 replies

Inspiring
June 28, 2006

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!
>


Inspiring
June 28, 2006
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."