dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Visual Basic and as3

  1. #1
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400

    Visual Basic and as3

    Hi,
    Im trying to find away of getting flash to play happy with vb6.
    This was easy enough when using as2. But when using as2, for a vb developer to change a variable in flash they would use somthing like _root.vartochange = "blar blar".
    However in as3 there is no such thing as "_root". Ive research this alot and caunt find anyway for vb to comunicate with flash. Would turning the flash into an air app make things any easier does any one know? This is a standalone flash app Im developing and not for web.
    Has anyone a solution to this?
    Or is there some sort of bridge I could use between the two?


    Thanks
    Aidan

  2. #2
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    You're going to have to use ExternalInterface to communicate with AS3, just like you do in an HTML page with JavaScript. In this case your VB application is the host instead of the browse+javascript environment.

  3. #3
    Senior Member
    Join Date
    Oct 2009
    Posts
    112

    VB6 variables --> AS3

    Quote Originally Posted by Northcode View Post
    You're going to have to use ExternalInterface to communicate with AS3, just like you do in an HTML page with JavaScript. In this case your VB application is the host instead of the browse+javascript environment.

    Can you explain this further?

    basically i have SUCCESFULLY used fscommand to send variables from AS3 to VB6, but there doenst seem to be any way to do the opposite (send variables back from VB6 to AS3).

    looking around on the web, EsternalInterface seems to be the only way that may provide a solution to do this, but i am new to as3 and don't have a clue how to write this function.

    does anyone else know how to do this? i can be more specific, or upload the code i have if i need to!
    PLEASE HELP!

  4. #4
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400
    Hi matt sorry for the late reply,
    If I was to use exsternalInterface I was going to use this blog post as refference. Seemed to make sense...
    http://nitin-sinha.blogspot.com/2009...unication.html

    However I'm a flash developer and have no idea about vb.
    Our resident VB developer struggled to get the cradle that holds the flash set-up correctly in vb.

    As a consequence we didn't use exsternalInterface.

    In the end we used a xml socket which can be notoriously difficult to set-up as quit often you need some kind of demon for it to work.

    However because this was working on a locale machine.. i don't think out vb developer needed to create a demon.
    As such a xml socket between flash and our vb back end works sweet as a nut!

    If you fancy having a crack at the xml socket have a butches at this....
    http://livedocs.adobe.com/flash/9.0/...XMLSocket.html

  5. #5
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    aidanmack,
    your right, i just figured out how to use xml sockets they work great. i've heard they might have the potential to be slow or be interuppted by firewalls, but so far no problems, its working great.

    i have a quesiton about flash. in my project, i have a slider that moves up and down on a rectangle:

    var bounds:Rectangle = new Rectangle(424.9, 37, 0, 320);//gives a line, slider can only
    //slide on this line

    i have been using xml sockets to track the position of the slider and send to VB. the rectangle has 320 positions, divided by 40 makes 8 (it turns on a series of eight lights).
    anyway, i have been tracking the position by using this code:

    function sData(e:ProgressEvent):void{
    var d:String=s.readUTFBytes(s.bytesAvailable);
    d=d.charAt(0);
    trace(d);
    slider.y=Number(d);
    }

    specifacally the part that says, slider.y=Number(d);

    the problem with this is that it's tracking the slider's position on the stage (y).

    Is there a way to track the slider's position on the Rectangle? that way it would be more accurate.

    for example: slider.RECTANGLE=Number(d) rather than slider.y=Number(d);

    do you get what i mean or do i need to re-explain that lol
    thanks
    Last edited by mattwatts15; 10-08-2009 at 07:14 AM. Reason: to clarify

  6. #6
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    mattwatts15: Subtract the sliders y location on the stage from the current y location of the slider to get a value from 0..max_slider_position and map that onto the range from 0..320 (or whatever the maximum height of your rectangle is).

    aidanmack: If your VB guy wants a working VB project that implements ExternalInterface in both directions just give me a shout by PM or email to support@northcode.com and I'll hook you up.

  7. #7
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400
    mattwatts15: Ummm yeah I would go with what he said (northcode) ha
    Northcode Thanks sir, Will make a note of your username/post. I think things are going to get rather complicated in the next few weeks for myself and vb developers. If we get stuck will let you know.
    We pay via paypal!

    Tar
    Aidan

  8. #8
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    aidanmack I haven't posted it here because it was something I just whipped up and it's kinda drity but I'm not looking for $, you can have the VB sample for nothing if you want it.

  9. #9
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400
    Cheers Tim,
    By all means send it through! Might come in handy at some point.
    aidanmack at hotmail dot com


    Thanks again.

  10. #10
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Sent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center