Hi,

> var liveStream = "";
> ...
> "Value undefined (result of expression liveStream.stop) is not
> object."

It sounds like langChange is being called before livestart is being
called; the string object doesn't have a stop method.  You'll want to
code defensively against the possibility that liveStream is not (yet)
set to an instance of PeriodicalUpdater.

Why would you use a blank string?  Just:

    var liveStream;

...which means that liveStream is declared but undefined.  Then in
langChange, test:

    if (liveStream) {
        liveStream.stop();
        liveStream = undefined; // For next time
    }

This is not Prototype stuff, this is just page logic.  I suggest
sitting down with a debugger and really working through what's going
on on your page.  I'm pretty sure PeriodicalUpdater#stop works.

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Mar 8, 11:24 am, flughund <br...@fruehjahr.ch> wrote:
> Hm, thx for quick answer. Now I tried to set only one
> PeriodicalUpdater like this:
>
> var liveStream = "";
>
> Event.observe(window, 'load', function() {
>                 livestart();
>
> });
>
> function livestart(){
>         var liveStream = new Ajax.PeriodicalUpdater('live_buehne', '/inc/
> live.php?lang=all', { method: 'get', frequency: 5, decay: 2,
> onComplete: blinken });
>
> }
>
> function langChange(lang){
>         liveStream.stop();
>         liveStream = new Ajax.PeriodicalUpdater('live_buehne', '/inc/live.php?
> lang='+lang, { method: 'get', frequency: 5, decay: 2, onComplete:
> blinken });
>
> }
>
> **
> But then I get from the console:
>
> "Value undefined (result of expression liveStream.stop) is not
> object."
>
> ????
>
> What I wish to have ist that:
>
> 1. start a periodicalUpdate AFTER the page has load
> 2. have the PU in a global variable that I can stop it, change a
> parameter and run it again
>
> Maybe thats not possible?
>
> Thx + Regards, Dave
>
> On Mar 8, 7:42 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > Hi,
>
> > Assuming you are calling livestart() at some point, you're creating
> > two PeriodicalExecuters [one at initialization time and another in
> > livestart()].  The second one overwrites the reference to the first,
> > so if you later call langChange(), my guess is that you are succeeding
> > in stopping the second one; the first one continues.
>
> > FWIW, you're also ignoring the 'lang' parameter in livestart().
>
> > HTH,
> > --
> > T.J. Crowder
> > tj / crowder software / com
> > Independent Software Engineer, consulting services available
>
> > On Mar 7, 8:39 pm, fruehjahr <fruehj...@gmail.com> wrote:
>
> > > Yes, I searched right here and @ Google for a solution. But I spent
> > > now over an hour with debugging and I can't find the solution. Please
> > > help!
>
> > > Ok, here's my script:
>
> > > var     liveStream = new Ajax.PeriodicalUpdater('live_buehne', '/inc/
> > > live.php?lang=all', { method: 'get', frequency: 5, decay: 2 });
>
> > > function livestart(lang){
> > >         var liveStream = new Ajax.PeriodicalUpdater('live_buehne', '/inc/
> > > live.php?lang=all', { method: 'get', frequency: 5, decay: 2 });
>
> > > }
>
> > > function langChange(lang){
> > >         liveStream .stop();
> > >         liveStream = new Ajax.PeriodicalUpdater('live_buehne', 
> > > '/inc/live.php?
> > > lang='+lang, { method: 'get', frequency: 5, decay: 2 });
>
> > > }
>
> > > But stop() won't stop!
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to