setInterval Problem

View: New views
5 Messages — Rating Filter:   Alert me  

setInterval Problem

by Jim Boykin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have following scenario where setInterval does not fire.

On button Release Handler - Load sound -> On Complete Sound Handler ->
Create XML Socket -> On Data Handler -> setInterval(myfunction, 30000)

setInterval never fires and myfunction never gets called. However, if
I use setInterval(myfunction, 30000) from the button release handler,
it does works.


Here is AS layout

class myclass {

static var app : myclass;

// entry point
static function main(mc) {
app = new myclass();
}

...

function myfunction() {

}

}


This works fine in MMC though.

Please help.

~Jim

--
MTASC : no more coffee break while compiling

Re: setInterval Problem

by Julien De Luca-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you tried

setInterval(this, 'myfunction', 30000);

or

setInterval(Delegate.create(this, this.myfunction), 30000);

?


Jim Boykin a écrit :

> I have following scenario where setInterval does not fire.
>
> On button Release Handler - Load sound -> On Complete Sound Handler ->
> Create XML Socket -> On Data Handler -> setInterval(myfunction, 30000)
>
> setInterval never fires and myfunction never gets called. However, if
> I use setInterval(myfunction, 30000) from the button release handler,
> it does works.
>
>
> Here is AS layout
>
> class myclass {
>
> static var app : myclass;
>
> // entry point
> static function main(mc) {
> app = new myclass();
> }
>
> ...
>
> function myfunction() {
>
> }
>
> }
>
>
> This works fine in MMC though.
>
> Please help.
>
> ~Jim
>
>  


--
MTASC : no more coffee break while compiling

Re: setInterval Problem

by Jim Boykin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I tried first method earlier after searching mailing list and it does not work.

I just tried second method and it gives error - ' type error Unknown
variable Delegate'

Please help

Thanks Anyway.

 type error Unknown variable Delegate

On 10/2/07, Julien D <jd@...> wrote:

> Have you tried
>
> setInterval(this, 'myfunction', 30000);
>
> or
>
> setInterval(Delegate.create(this, this.myfunction), 30000);
>
> ?
>
>
> Jim Boykin a écrit :
> > I have following scenario where setInterval does not fire.
> >
> > On button Release Handler - Load sound -> On Complete Sound Handler ->
> > Create XML Socket -> On Data Handler -> setInterval(myfunction, 30000)
> >
> > setInterval never fires and myfunction never gets called. However, if
> > I use setInterval(myfunction, 30000) from the button release handler,
> > it does works.
> >
> >
> > Here is AS layout
> >
> > class myclass {
> >
> > static var app : myclass;
> >
> > // entry point
> > static function main(mc) {
> > app = new myclass();
> > }
> >
> > ...
> >
> > function myfunction() {
> >
> > }
> >
> > }
> >
> >
> > This works fine in MMC though.
> >
> > Please help.
> >
> > ~Jim
> >
> >
>
>
> --
> MTASC : no more coffee break while compiling
>

--
MTASC : no more coffee break while compiling

Re: setInterval Problem

by jannerick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

to use delegate, you need to import the delegate class. maybe it would
it would be a good idea if you post the relevant code, so we can see
where the failure might be.

regards,
jan eric

Jim Boykin schrieb:

> I tried first method earlier after searching mailing list and it does not work.
>
> I just tried second method and it gives error - ' type error Unknown
> variable Delegate'
>
> Please help
>
> Thanks Anyway.
>
>  type error Unknown variable Delegate
>
> On 10/2/07, Julien D <jd@...> wrote:
>> Have you tried
>>
>> setInterval(this, 'myfunction', 30000);
>>
>> or
>>
>> setInterval(Delegate.create(this, this.myfunction), 30000);
>>
>> ?
>>
>>
>> Jim Boykin a écrit :
>>> I have following scenario where setInterval does not fire.
>>>
>>> On button Release Handler - Load sound -> On Complete Sound Handler ->
>>> Create XML Socket -> On Data Handler -> setInterval(myfunction, 30000)
>>>
>>> setInterval never fires and myfunction never gets called. However, if
>>> I use setInterval(myfunction, 30000) from the button release handler,
>>> it does works.
>>>
>>>
>>> Here is AS layout
>>>
>>> class myclass {
>>>
>>> static var app : myclass;
>>>
>>> // entry point
>>> static function main(mc) {
>>> app = new myclass();
>>> }
>>>
>>> ...
>>>
>>> function myfunction() {
>>>
>>> }
>>>
>>> }
>>>
>>>
>>> This works fine in MMC though.
>>>
>>> Please help.
>>>
>>> ~Jim
>>>
>>>
>>
>> --
>> MTASC : no more coffee break while compiling
>>
>

--
MTASC : no more coffee break while compiling

Re: setInterval Problem

by Julien De Luca-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you call setInterval from your static main function, you should instead do :
static function main(mc) {
  app = new myclass();
  setInterval(app, 'myfunction', 30000); // beware that 30000 is 30 seconds !
}
This should work.

Anyway, good to know, to import delegate, add :

import mx.utils.Delegate

at the beginning of the file, and be sure to add -mx to compiler params.

jannerick a écrit :
to use delegate, you need to import the delegate class. maybe it would
it would be a good idea if you post the relevant code, so we can see
where the failure might be.

regards,
jan eric

Jim Boykin schrieb:
  
I tried first method earlier after searching mailing list and it does not work.

I just tried second method and it gives error - ' type error Unknown
variable Delegate'

Please help

Thanks Anyway.

 type error Unknown variable Delegate

On 10/2/07, Julien D jd@... wrote:
    
Have you tried

setInterval(this, 'myfunction', 30000);

or

setInterval(Delegate.create(this, this.myfunction), 30000);

?


Jim Boykin a écrit :
      
I have following scenario where setInterval does not fire.

On button Release Handler - Load sound -> On Complete Sound Handler ->
Create XML Socket -> On Data Handler -> setInterval(myfunction, 30000)

setInterval never fires and myfunction never gets called. However, if
I use setInterval(myfunction, 30000) from the button release handler,
it does works.


Here is AS layout

class myclass {

static var app : myclass;

// entry point
static function main(mc) {
app = new myclass();
}

...

function myfunction() {

}

}


This works fine in MMC though.

Please help.

~Jim


        
--
MTASC : no more coffee break while compiling

      

  


--
MTASC : no more coffee break while compiling