#VRML V2.0 utf8

DEF TS TouchSensor { }

DEF Script1 Script {
    eventIn  SFTime touchTime
    eventOut SFBool toScript2
    eventOut SFBool toScript3
    eventOut SFString string

    url "javascript:
        function touchTime() {
            toScript2 = TRUE;
        }
        function eventsProcessed() {
            string = 'Script1.eventsProcessed';
            toScript3 = TRUE;
        }"
}

DEF Script2 Script {
   eventIn  SFBool fromScript1
   eventOut SFBool toScript4
    eventOut SFString string

    url "javascript:
        function fromScript1() {
        }
        function eventsProcessed() {
            string = 'Script2.eventsProcessed';
            toScript4 = TRUE;
        }"
}

DEF Script3 Script {
   eventIn  SFBool fromScript1
   eventOut SFBool toScript5
   eventOut SFBool toScript6
   eventOut SFString string

    url "javascript:
        function fromScript1() {
            toScript5 = TRUE;
        }
        function eventsProcessed() {
            string = 'Script3.eventsProcessed';
            toScript6 = TRUE;
        }"
}

DEF Script4 Script {
    eventIn SFBool fromScript2

    url "javascript:
        function fromScript2() {
        }"
}

DEF Script5 Script {
    eventIn SFBool fromScript3

    url "javascript:
        function fromScript3() {
        }"
}

DEF Script6 Script {
    eventIn  SFBool fromScript3
    eventOut SFBool toScript7
    eventOut SFString string

    url "javascript:
        function fromScript3() {
            toScript7 = TRUE;
        }
        function eventsProcessed() {
            string = 'Script6.eventsProcessed';
        }"
}

DEF Script7 Script {
    eventIn  SFBool fromScript6

    url "javascript:
        function fromScript6() {
        }"
}

ROUTE TS.touchTime TO Script1.touchTime
ROUTE Script1.toScript2 TO Script2.fromScript1
ROUTE Script1.toScript3 TO Script3.fromScript1
ROUTE Script2.toScript4 TO Script4.fromScript2
ROUTE Script3.toScript5 TO Script5.fromScript3
ROUTE Script3.toScript6 TO Script6.fromScript3
ROUTE Script6.toScript7 TO Script7.fromScript6


# Display the results

DEF Collector Script {
    eventOut   MFString string
    eventIn SFString fromString
    url "javascript:
        function initialize() { string[0] = 'Event Sequence:'; }
        function fromString(s) {
            i = string.length;
            string[i] = '    '+i+') '+s+' occurred';
        }"
}

Transform {
    translation 0 2 0
    children Shape {
        appearance Appearance {
            material Material { diffuseColor 0 0.6 0 }
        }
        geometry Sphere { }
    }
}

Shape { geometry DEF Result Text { } }

Viewpoint { position 7 -1 18 }

ROUTE Script1.string TO Collector.fromString
ROUTE Script2.string TO Collector.fromString
ROUTE Script3.string TO Collector.fromString
ROUTE Script6.string TO Collector.fromString
ROUTE Collector.string TO Result.string