Basic stuff

basic stuff

hey, im really new to actionscripting

im experimenting for stuff, trying to get a good feel of actionscript.

i’m stuck on this d=rt calculator im trying to make.

here is the code i put into the first frame:

function Formula (t, d) {
this.time = t;
this.distance = d;
this.getSpeed = function(){return this.time / this.distance}

i have an input text field, and its variable is t

i have a button which is supposed to submit what you type in to the text field. the code for it is:

on (release) {
setProperty(" _root.Formula", _time, t)

there is an error in the code for the button. this is the error the debugger gives me:

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 2: Property name expected in GetProperty.
setProperty(" _root.Formula", _time, t)

what am i doing wrong?
i have been trying to figure this out, and i cant…
=) =) =)

Try using this code instead, it might make things more easy for you. Give your textfield an instance name

_root.holdtext.onChanged = function(){

this reacts with whatever you enter or type into the textfield. You can then add your own actions after this.

Hope this helps.


thanks! ill try that

hmm… won’t that invoke the Onchange everytime you press a key inside of the input box?

on (release) {
setProperty(" _root.Formula", _time, t)

is equivalent to

on (release) {_root.Formula._time=t;}

Flash 4 syntax…

Anyway, there’s no _time property in the object Formula, and there is no Formula object to start with.

Try that

on (release){_root.Formula(t,d);}

but your textboxes have to be called ‘t’ and ‘d’.

pom :asian: