This content has been marked as final.
Show 10 replies
-
1. Re: Why isnt this working
Greg Dove Dec 7, 2007 7:07 AM (in response to DanelKirch)getNewMess is expecting an object argument (normally sent by the EventDispatcher from you button click event). Your setInterval call is not providing anything for the argument. -
2. Re: Why isnt this working
Greg Dove Dec 7, 2007 7:09 AM (in response to DanelKirch)try:
var intervalID:Number = setInterval(getNewMess, 3000, {target:this.refresh_btn} ); -
3. Re: Why isnt this working
DanelKirch Dec 7, 2007 7:19 AM (in response to DanelKirch)it sounds complicated.
Is there any other way to trigger same call as button does ?
I need it reload automatically after every 3 minutes. (it is going to be as system-tray apllication) thats why is button no good solution. -
4. Re: Why isnt this working
DanelKirch Dec 7, 2007 7:25 AM (in response to DanelKirch)Yep it worked out fine, but it gives me 2 alert messages now ;) -
5. Re: Why isnt this working
Greg Dove Dec 7, 2007 7:50 AM (in response to DanelKirch)the number 3000 in your setInterval is equivalent to 3 seconds because its in milliseconds
If you want it to be 3 minutes
then it should be 3*60*1000 = 180000
-
6. Re: Why isnt this working
Greg Dove Dec 7, 2007 7:52 AM (in response to DanelKirch)"Is there any other way to trigger same call as button does ?"
Yes. If you're not wanting to use the button as well you can. But you will need to change the function getNewMess.
-
7. Re: Why isnt this working
Greg Dove Dec 7, 2007 7:57 AM (in response to Greg Dove)try this, I think it will work for both. :
var t=this;
function getNewMess(evt:Object) {
var pc:PendingCall = t.service.GetNyaMedd();
pc.responder = new RelayResponder(t, "onNewMess", "onFault");
}
//next two functions the same
this.refresh_btn.addEventListener("click",getNewMess);
var intervalID:Number = setInterval(getNewMess, 180000);
/I think that should work -
8. Re: Why isnt this working
DanelKirch Dec 7, 2007 11:42 AM (in response to Greg Dove)Thanx GWD!
It worked out fine!
I allmost hated the idea to have to include the button there because i dont want too much components on the stage (even if they are not on the stage).
Anyhow. Like you said, it works! -
9. Re: Why isnt this working
DanelKirch Dec 7, 2007 11:45 AM (in response to DanelKirch)By the way,
im using slides / forms in my application and ive included this code allmost everywhere that gets data from amfphp.
Is this version better than evt.target._parent ? if so could you explain, why / how ? -
10. Re: Why isnt this working
Greg Dove Dec 7, 2007 12:18 PM (in response to DanelKirch)evt.target._parent
is just using the event argument that is dispatched to and therefore received by your listener function. It is dispatched/sent by your button component instance. The event object from components - in as2 - normally contains at least two properties. A type property... in this case that's "click" , because its a click event and a target property. The target property is a reference to the component instance from which the event originated. It can be particularly useful if you have one listener handling events from many sources. So.....
evt.target._parent is referring to the container clip of the instance that sent the event. i.e. The _parent of the button in this case.
That's why I replaced it with t (=this) which is a reference to the timeline that the button is running in. Now it doesn't need to get that reference from checking the _parent of the evt.target property from the evt argument. Which means the argument that the newMess function receives can be ignored and its no longer reliant on it. Sounds confusing but once you "get" it, it all makes sense. Eventually, lol.
And of couse you don't need to have a button if you don't want one.

