A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: As3 -vba

  1. #1
    Junior Member
    Join Date
    Jan 2015
    Posts
    4

    As3 -vba

    First let me say Hi and apologise in advance for any 'newbie' fopars I may, inadvertently, make.

    I am new to flash and on a very steep learning curve. Up to now I seem to have been doing ok(ish) but now I'm stuck trying to get my head round ExternalInterface

    I need to pass a string value to VBA from flash

    Below is the function that gets the info from xml into a string on a double click. This works fine.
    Trace shows string changing relevant to item clicked etc

    Now I need to pass this string into VBA . tried everything (including a couple of bottles of JD )but I can't get my head around it. Can someone please help?

    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.utils.*;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import flash.events.MouseEvent;
    import flash.external.ExternalInterface;

    //(removed this lot to shorten the post as it is just imports from other.as files and Public functions doin stuff like setting the stage adding listners etc)

    private function onMenuDoubleClick(e:MouseEvent):void {

    var title:String

    title = e.target.data.@title;
    trace ("title: "+title)



    }

    }

    }

    Many thanks in advance

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I'm not sure about the vb stuff, but you can prbably figure out how to get the data you require from the javascript!!!
    AS
    PHP Code:
    menuButton.doubleClickEnabled true;
    menuButton.addEventListener(MouseEvent.DOUBLE_CLICK,onMenuDoubleClick);

    function 
    onMenuDoubleClick(e:MouseEvent):void
    {
        var 
    title:String;
        
    title "This is the string";
        
    //title = e.target.data. @ title;// altered for my testing
        
    if (ExternalInterface.available)
        {
            
    trace("title: " title);
            
    ExternalInterface.call('fromFlash',title);
        }

    javascript
    PHP Code:
    <script language="JavaScript">
        function 
    fromFlash(flashString)
        {
            
    alert(flashString);
        }
    </
    script

  3. #3
    Junior Member
    Join Date
    Jan 2015
    Posts
    4
    Quote Originally Posted by fruitbeard View Post
    Hi,

    I'm not sure about the vb stuff, but you can prbably figure out how to get the data you require from the javascript!!!
    [/PHP]
    Thanks for the response.

    This is one of the problems I am having. All tuts, samples, etc. seem to make the assumption that Flash will be running through a browser and, in which case, JS can be used. Tried that route but it doesn't help me.

    I am prob missing something unsentimental but then 2+2 only = 4 if you know how to work out the answer!

    All the info states that what I want to do is possible but I just can't figure it

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Try here perhaps, http://board.flashkit.com/board/show...orm-VB6-to-AS3

    further down the page I believe, Northcode would probably have a solution for you but I have not seen his name here for a few months now.

  5. #5
    Junior Member
    Join Date
    Jan 2015
    Posts
    4
    Quote Originally Posted by fruitbeard View Post
    Hi,

    Try here perhaps, http://board.flashkit.com/board/show...orm-VB6-to-AS3

    further down the page I believe, Northcode would probably have a solution for you but I have not seen his name here for a few months now.
    Thanks once again

    I have been and taken a look at that but the solution doesn't work. It is a standard example that is elsewhere and is aimed at callback not call.

    Callback = (application) to AS3
    Call = AS3 to (application) an that appears to be where information is sketchy

    I do seem to have a habit of opening up black arts

    I have been trying fscommand instead

    In AS

    import flash.system.fscommand;

    private function onCoverFlowDoubleClick(e:MouseEvent):void {

    var title:String

    title = e.target.data.@title;
    trace ("title: "+title);

    fscommand("execute");
    }

    And in VBA

    Private Sub Form_Activate_FSCommand(ByVal command As String, ByVal args As String)


    If command = "execute" Then

    MsgBox "success"

    End If

    Me.(formname).Movie = "C:\...........swf"

    End Sub

    But that isn't working either

    There has to be a way. I've bin on this all this week and it's driving me nuts. The missus is threatening to leave and I've run outa Jack lol

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Not sure if you read the whole thread, but I see this part glowing at me.
    To go the other way, just implement the ShockwaveFlash1.FlashCall event on the VB side and use ExternalInterface.call() to call out using whatever parameters you like. You don't have to register each function you want to call on the VB side. For example: ExternalInterface.call("VBFunction", "pi", 3.1415927). All calls go to the one FlashCall event in VB and you have to parse the mess of XML you get from Flash
    post #7 on that last link

    perhaps if you post your q on that thread it might stir the necessary peeps into forming an answer for you, as we do get emails in threads we are joined onto.

    or there is the General Help -> Standalone & Applications section
    Last edited by fruitbeard; 01-31-2015 at 06:58 AM.

  7. #7
    Junior Member
    Join Date
    Jan 2015
    Posts
    4

    resolved

    Quote Originally Posted by fruitbeard View Post
    Hi,

    Not sure if you read the whole thread, but I see this part glowing at me.


    post #7 on that last link

    perhaps if you post your q on that thread it might stir the necessary peeps into forming an answer for you, as we do get emails in threads we are joined onto.

    or there is the General Help -> Standalone & Applications section
    Doh

    TBH I have seen that example zillions of times and didn't bother reading the rest of the post.

    The clue was ......"All calls go to the one FlashCall event in VB"
    That gave me the clue I needed.

    So, for anyone else that may look for this, here is my solution:-

    AS3 - The bits in red are the ones you need here

    Code:
    import flash.display.*; import flash.events.*; import flash.net.*; import flash.utils.*; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.events.MouseEvent; import flash.external.ExternalInterface; //(removed this lot to shorten the post as it is just imports from other.as files and Public functions doin stuff like setting the stage adding listners etc) private function onMenuDoubleClick(e:MouseEvent):void { if (ExternalInterface.available) ExternalInterface.call(e.target.data.@title); // ExternalInterface (this is the string from the target record in my xml table); } } }
    Now lets deal with the VBA
    You need 2 things
    First

    Code:
    Private Sub Form_Activate() Me.(name of your form).Movie = ("Path to your.swf" End Sub
    Plus This (there may be a better way to achieve this but it's down and dirty and it works)

    Code:
    Private Sub MainMenu_FlashCall(ByVal request As String) Dim strXML As String Dim strArray() As String Dim strTrim() As String Dim intCount As Integer 'first lets get the call from flash and dump it in a string strXML = request 'this is a long string because it is the complete record in xml and has many components so we need to tiy 'it up. for me I can do this in 2 stages using < & > as delimiters to get the substring I want to work with strArray = Split(strXML, "<") For intCount = LBound(strArray) To UBound(strArray) Next 'the item I need is the forth item in the array so we can split that off again with strTrim = Split(strArray(3), ">") For intCount = LBound(strTrim) To UBound(strTrim) Next 'now we are down to an array consisting of 2 items and I need the second (remember that the first item is 0) iItem = strTrim(1)
    ' A Debug.Print of iItem will prove that you have what you need to work with
    Eureka!

    Now I have something that I can play wiv

    Will put some error checking in when I've finished but that's all standard stuff.
    It may be a good idea to include an 'is not available' routine in the ExternalInterface as a safeguard to prevent the swf from falling over but I'll look into that

    Once again thanks for your help fruitbeard and I hope this is of some assistance to others at some stage

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