This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > December 2003 > eventout in script within proto ?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author eventout in script within proto ?
Robert Ludewig

2003-12-08, 11:57 am

hello is there a way to get an eventout of a script (wich is within a
proto) out of the proto?

like this:

Proto timer
[
eventOut SFTime time
]
{
# here is a Scriptnode that generates a time that shall
# be the eventout of this proto

}

so I could to:

ROUTE timer.time TO MyTimeSensor.starttime
Joerg Scheurich aka MUFTI

2003-12-09, 10:03 am

> hello is there a way to get an eventout of a script (wich is within a
quote:

> proto) out of the proto?


quote:

> like this:


quote:

> Proto timer
> [
> eventOut SFTime time
> ]
> {
> # here is a Scriptnode that generates a time that shall
> # be the eventout of this proto


quote:

> }


quote:

> so I could to:


quote:

> ROUTE timer.time TO MyTimeSensor.starttime



simply use "IS" in the script header

#VRML V2.0 utf8

PROTO timer
[
eventOut SFTime time
]
{

DEF TimeSensor1 TimeSensor
{
loop TRUE
}

DEF Script2 Script
{
eventIn SFTime time1_in
eventOut SFTime time IS time
url
[
"java script:

// eventOut SFTime time //

function time1_in(value)
{
// value SFTime
time = value;

}
"
]
}

ROUTE TimeSensor1.time TO Script2.time1_in
}

DEF timer1 timer
{
}

DEF Script1 Script
{
eventIn SFTime time1_in
url
[
"java script:

function time1_in(value)
{
// value SFTime
print(value);
}
"
]
}

ROUTE timer1.time TO Script1.time1_in
Robert Ludewig

2003-12-09, 10:03 am

That brings me to another question:

if the proto hase some exposedfields , how do I acess them within a Script?
IS doesn`t seem to work.
Jeremy Pitten

2003-12-09, 9:40 pm

Assuming the proto exposedFields map to some node exposedField within the
proto definition then you need to define a ROUTE statement to route an
eventOut generated by the exposedField to the eventIn in the script node.

So, for example:

proto Timer [
exposedField SFBool enable false
]{
DEF time TimerSensor { enabled IS enable }

DEF script Script {
eventIn SFBool setEnabled
url [ "javascript : function setEnabled(value){ blah blah } ]
}

ROUTE time.enabled_changed TO script.setEnabled
}

"Robert Ludewig" <schwertfischtrombose@gmx.de> wrote in message
news:683ab5d5.0312090244.a220434@posting.google.com...
quote:

> That brings me to another question:
>
> if the proto hase some exposedfields , how do I acess them within a


Script?
quote:

> IS doesn`t seem to work.




Herbert Stocker

2003-12-09, 9:40 pm



Jeremy Pitten wrote:
quote:

> Assuming the proto exposedFields map to some node exposedField within the
> proto definition then you need to define a ROUTE statement to route an
> eventOut generated by the exposedField to the eventIn in the script node.
>



If there is no such node, you can make your own node with a
PROTO statement.

Instead of DEF time TimerSensor { enabled IS enable }
you can say:

PROTO hlp [
exposedField SFBool enable FALSE
] { Group {} }

DEF effs hlp { enable IS enable }

Herbert

quote:

> So, for example:
>
> proto Timer [
> exposedField SFBool enable false
> ]{
> DEF time TimerSensor { enabled IS enable }
>
> DEF script Script {
> eventIn SFBool setEnabled
> url [ "javascript : function setEnabled(value){ blah blah } ]
> }
>
> ROUTE time.enabled_changed TO script.setEnabled
> }
>
> "Robert Ludewig" <schwertfischtrombose@gmx.de> wrote in message
> news:683ab5d5.0312090244.a220434@posting.google.com...
>
>
> Script?
>
>
>
>




--
Herbert Stocker (aka hersto)
http://www.hersto.de
www.bitmanagement.de

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews