Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Flash Remoting

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-17-2003, 02:09 PM   #1
vwoohu
Registered User
 
Join Date: Jul 2003
Posts: 11
Post help

I have trouble with the following code (I don't know how to describe it) :


Code:


function getData_result (result) {
_root.tempData = result ;
}
function load () {
trace (_root.tempData) ;
}
function init () {
myService.getData () ;
load () ;
}
init () ;
stop();




I'm trying to process the _root.tempData which is a reference to the result returned from service call GetData. tempData is assigned the result value from the service call but I can't access the tempData in the load function. But I can access it if the init function finish executing. Is there a way to access that variable from the same function call?

Vincent
vwoohu is offline   Reply With Quote
Old 07-17-2003, 02:39 PM   #2
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

You can't access until its populated. Which means after the result handler fires. This would fix it.

ActionScript Code:
function getData_result (result) { _root.tempData = result ; load () ; } function load () { trace (_root.tempData) ; } function init () { myService.getData () ; } init () ; stop();
freddycodes is offline   Reply With Quote
Old 07-17-2003, 02:42 PM   #3
vwoohu
Registered User
 
Join Date: Jul 2003
Posts: 11
Default nope

I see. but I may not want to use load () in the getData_result function every time. Just inside of the init function. Would a setInterval work?

V
vwoohu is offline   Reply With Quote
Old 07-17-2003, 02:45 PM   #4
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

I am not going to try and figure out why you don't want to use load() in the result handler. But a watch would work.

ActionScript Code:
function getData_result (result) { _root.tempData = result ; } load = function (prop, oldVal, newVal) {       trace (newVal); }; function init () { _root.watch("tempData", load); myService.getData () ; } init () ; stop();

Last edited by freddycodes; 07-17-2003 at 02:58 PM..
freddycodes is offline   Reply With Quote
Old 07-17-2003, 02:54 PM   #5
vwoohu
Registered User
 
Join Date: Jul 2003
Posts: 11
Default

nope didn't work . is there another function I can use?

V
vwoohu is offline   Reply With Quote
Old 07-17-2003, 02:57 PM   #6
vwoohu
Registered User
 
Join Date: Jul 2003
Posts: 11
Default

I can access the tempData after init function has been called. but not inside the same function
vwoohu is offline   Reply With Quote
Old 07-17-2003, 02:57 PM   #7
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

I mean it does work, I don't just spew non-working code here for the fun of it, could you post your attempt? Even better to show you it works.

ActionScript Code:
function getData_result (result) {         _root.tempData = result ; } load = function (prop, oldVal, newVal) {         trace (newVal); }; function init () {         _root.watch("tempData", load);         getData_result ("Hello") ; } init () ; stop();
freddycodes is offline   Reply With Quote
Old 07-17-2003, 03:00 PM   #8
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Quote:
Originally posted by vwoohu
I can access the tempData after init function has been called. but not inside the same function
Like I said before you can't access it until its populated, flash is not going to wait for the result handler to fire before moving to the next line of actionscript. So by trying to access tempData on the line below the service call, just is not going to work.
freddycodes is offline   Reply With Quote
Old 07-17-2003, 03:31 PM   #9
vwoohu
Registered User
 
Join Date: Jul 2003
Posts: 11
Default

I apologize; I didn't read your code thoroughly. The code I placed above is a simplified version of the code below. The code involves two service calls, a getUTCID to populate a combobox, and loadData which loads saved data from a database and replaces the top item of combobox with the load item. That's the reason for running both functions inside of Init.

ActionScript Code:
function init () { service.getUTCID ()//populates a combo box with data _root.watch ("_root.utcidlist", service2.loadData (username,unit)) ; } function loadData_result (result) {    populate (holder, result,_root.utcidlist)  //holder contains the combobox                                 //push the loaded item to the top of combobox } function getUTCID_result () { .... some code    _root.utcidlist = result ; } init() ; stop();

I know it's not pretty. I hope you can help. Thanks
vwoohu is offline   Reply With Quote
Old 07-17-2003, 03:39 PM   #10
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Would you not be able to use

ActionScript Code:
function init () {         service.getUTCID ()//populates a combo box with data } function loadData_result (result) {         populate (holder, result,_root.utcidlist)  //holder contains the combobox         //push the loaded item to the top of combobox         } function getUTCID_result () { //        .... some code         _root.utcidlist = result ;         service.loadData (username,unit); } init() ; stop();
freddycodes is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:59 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.