I am having trouble getting the variables supplied by Visual Basic to display into a textField or added into an Array.
Currently I use AS2 for our company's existing software. It is a software which loads the SWF files and supplies all variables externally.
In AS2, VB would simply give me ;
var name:String = "JOHN";
var lastName:String = "DOE";
This I can access in every movieClips anytime by calling
myName.text = _root.name+" "+_root.lastName;
or in the case of adding the variables into an Array, I simply put the following;
var myArray:Array = new Array(_root.name, _root.lastName, _root.age, _root.sex);
I can't do this on AS3 and I do hope that anyone can help me with this problem.
Thanks in advance.
Comments
Actually, another member had just asked a very similar question. Check out the answer I provided here: http://groups.adobe.com/posts/4128394337 This should give the answer to the root question when using ActionScript 3.
It will only work if you type in the variable & its value but will not display the "new" value supplied by VB.
Here is more info on accessing "root" in AS3: http://www.kirupa.com/forum/showthread.php?p=1952513
A critical part of accessing the stage and/or root is that the stage needs to be added to the displaylist before you access it. You can set up an event listener for ADDED_TO_STAGE and then access stage or root once that event fires. In your case, can you trace out stage or are you getting null? If you are getting null, then stage isn't available, and you'll need the event to fire before your vars from VB are accessible.
Hey thanks John, I will play with with and let you kknow how it goes.
By default, the software that loads my swf file already sent out the variables. I can't get my swf file to see those variables. In AS2 I used onEnterFrame or setIntervals to detect the changes.
setInterval works in AS3. Are you using that? If you want to use enter frame, that is set up a bit differently. You'll need to set up the listener and the handler.
Example:
{// your code here - exampleIf you are still unable to gain access to the variables being injected by VisualBasic, you may want to look at a debugger solution like MonsterDebugger (http://www.monsterdebugger.com/). Its free (open source) and should allow you to see the entire tree of your SWF and find if the values are being injected properly by the VB app. Lee Brimelow has a intro video on his GotoAndLearn site (http://gotoandlearn.com/play?id=109 )
Yes I have tried both.
The DeMonster Debugger does not show the VB variables at all.
Then are you sure the VB is actually setting the values into the SWF properly? How are they injecting the data? There are various methods for doing this.
On the development side I have a simulator program compiled in VB with ActiveX, which contains predefined variable names. I can insert any values to into a field then load the SWF from that simulator.
All I know is that when I click the send button, the new values will show up on an AS2 SWF.
On AS3 (loaded from the simulator) for example, if I set the value of a myVariable:String to null the SWF will not detect if that null value has changed.
The VB send this command: SWF1.SetVariable 'myVariable' with a string data off "whatetever"
I can set AS2 to see if myVariable is null or not and then display the new data when it becomes != null.
If the VB app is passing data in similar to how FlashVars work, then the data doesn't get placed on the root like it did in AS2. In a AS3 SWF, the passed in FlashVars (assuming VB is injecting it this way) is located in the loaderInfo. In MonsterDebugger, it would under MainTimeline > loaderInfo (LoaderInfo) > parameters
More info on LoaderInfo and how to access it via ActionScript 3.0 is located here : http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html
Ok thanks, I will check it out.
I tried it and still can't get it to work.
With AS2, our VB developers could use the SetVariable for his input & I could use fscommand for my output. Simple as that but reading through the forums http://forums.adobe.com/search.jspa?q=AS3++VB6&resultTypes=MESSAGE&resultTypes=COMMUNITY&peopleEnabled=true&dateRange=all&username=&numResults=15&rankBy=10001
I realized that a lot of questions were never answered. The only documentation regarding VB and Flash is outdated (I mean good for AS2) http://www.adobe.com/devnet/flash/articles/flash_vb.pdf , in fact that is the bases of our company's software. It seems like we are going to be stuck on AS2 and miss out on a lot of good stuff that AS3 has to offer.
Sorry there isnt' more of an answer out there for you. Possibly best sticking to AS2 since VisualBasic is no longer being supported by Microsoft and Adobe probably won't put any more resources into providing documentation to connecting to older systems.
I dug into a bit more and several people are suggesting to use ExternalInterface to communicate back and forth between VB and Flash AS2/AS3.