View Full Version : Where did my var go???
ghuton
05-10-2002, 10:00 PM
I am using loadVariablesNum to call a VBScript that runs a little routine and returns a var "strHD" which contains "A12". For testing purposes I have the text "A12" display as dynamic text using the var "strHD". It displays fine "A12".
Now I need to strHD.substr(0,1)the var to get the "A" and strHD.substr(1,2) to get "12". But when I do this the var is gone. There is nothing in strHD. I am doing this in the same frame and ActionScript layer.
By the way the .vbs is sending this to FLash "response.send("strHD="&strHD)"
Where has my var gone? How do I get him back. How do I hold on to him so I manipulate the little bugger before he goes?
Ghuton,
Sounds like your doing everything right but it's hard to tell. The quickest way to resolve an issue like this is simply to post your code.
Talk to you then ;),
--FADE
ghuton
05-13-2002, 02:50 PM
I really don't get this. Here is the exact code I am using.
From vbs file:
case MODE_GET_HCDC
strHD = hs.GetDeviceCode(strLocNam)
hs.WriteLog "LocNam", strLocNam
hs.writeLog "HcDc", strHD
response.send("strHD="&strHD)
What above does is:
Line 1 pass value of "strLocNam" (Kitchen Halos) to function hs.GetDeviceCode set it = to Var strHD. StrHD becomes = to A12
Line 2: Debug print val of strLocNam which prints correctly
Line 3: Debug print val of strHD which prints correctly
Line 4: send the val of strHD back to Flash which it does.
In Flash:
strMode = 8;
strLocNam = "Kitchen Halos"
loadVariablesNum("mechmen.vbs", 0, "GET");
stop();
What above does in Flash:
Line 1: Sets Case mode in .vbs file listed at top
Line 2: Sets the val of strLocNam
Line 3: Sends all of this off to the .vbs file to process.
This all works fine. In Flash using a text box and setting properties to "Dynamic Text" and setting "Var" = strHD. I can print the value of strHD (A12) in Flash. SO I know the value of strHD has been passed to Flash from the vbs file. However, when I try to do something to strHD like:
strHC = strHD.substr(0,1);
strDC = strHD.substr(1,2);
which should return strHC = "A" and strDC = "12" and then for testing purposes try to print the 2 vars. They are empty. I get nothing. What is happening to the var strHD? I need to do this because I nned to send the "A" and the "12" back to the vbs file for further proscessing as separate items.
Any help much appreciated.
-Glenn
ghuton
05-13-2002, 04:09 PM
Also, when I do this. My the value of strHD does not print.
_root.createTextField("mytext",1,100,100,300,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;
myformat = new TextFormat();
myformat.color = 0xff0000;
myformat.bullet = false;
mytext.text = strHD;
mytext.setTextFormat(myformat);
But yet when I set the var through the Property Inspector for a Dynamic Text Box it works.
Just tried this for testing purposes. I really need to keep all this stuff in Player5
ghuton
05-13-2002, 06:12 PM
Ok, I found my var!!! But... don't understand what is happening, or how to deal with it. If I create a second frame with the above to create a text field w/ action script (and no "stop();") on frame one or two. Then, first pass I get a "0" in frame 2, then when it loops back to frame 1, I see the correct value displayed. This pattern then repeats.
What is happening. Why do I not see it in the first loop? But the next time I pass through frame 1 it is there, but returning "0" in frame 2.
Am I really just talking to myself here? I mean I guess I am figuring it out all the same.
ghuton
05-13-2002, 06:56 PM
So, I now I get it. The deal is you cannot play with your vars until at least the second frame. Of, course this is a well documented fact. HA! And all you voyeurs were completely aware of this fact and were merely reviling in public displays of mental masturbation. Thanks to all who helped. Me
you are welcome. ;)
heh, good job. sorry about that. forgot to think that swonking was your problem.
1 frame may not be enough time, depending on the length of time it takes your other script to return data via loadVariables.
so a search on "swonk" to find out how others have worked with this.
or load it into a movie clip and use the onClipEvent(data) to notify you when you have data loaded via loadVariables/Num
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.