Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I followed the instructions given below to play with RunScheduledTask within DynamicModule.

ScheduledTask with scoped variables. Working with timed evaluation

Everything works great until it comes to the Inset, which does not update with the local variable. Any hints are welcome.

 RemoveScheduledTask[ScheduledTasks[]];
 d=DynamicModule[{x=0,y=0},
 {
    Dynamic[x,TrackedSymbols:>{x}],
    Framed@Graphics[{
        Dynamic[Point[{2+#,2+#}]&@x,TrackedSymbols:>{x}],
        Dynamic[
            Inset[
            Framed@Graphics[
                Point[{#+3,#+3}]&@x,
                PlotRange->{{1,5},{0,8}}
            ]
        ], 
        TrackedSymbols->{x}
        ]
    },
        PlotRange->{{0,6},{-1,9}}
    ]
 },
 Initialization:>(RunScheduledTask[x++,{.5,3}];)
 ]

Follow up:

rasher is correct, wrap the inset point in Dynamic works. Thx so much!

 RemoveScheduledTask[ScheduledTasks[]];
   d=DynamicModule[{x=0,y=0},
   {
   Dynamic[x,TrackedSymbols:>{x}],
   Framed@Graphics[{
    Dynamic[Point[{2+#,2+#}]&@x,TrackedSymbols:>{x}],

     Inset[
        Framed@Graphics[

        Dynamic[Point[{#+3,#+3}]&@x,TrackedSymbols:>{x}],
            PlotRange->{{1,5},{0,8}}
        ]
    ]
},
    PlotRange->{{0,6},{-1,9}}
]
},
 Initialization:>(RunScheduledTask[x++,{.5,3}];)
]
share|improve this question
    
Wrap the inset point in Dynamic –  rasher Mar 3 at 7:41
    
Tried that, no good. –  Benson Mar 3 at 8:16
    
Works for me (assuming result desired are the two points "following" each other). Could you perhaps update post with example? –  rasher Mar 3 at 8:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.