Jump to content

Using the fscommand() function in Flash 8 to control AutoItv3?


Justin
 Share

Recommended Posts

Hi there.. Im a n00b on the board, but have been using AutoIt for just over 9 months now to create countless tools for myself at work. I love this scripting language!

Anyway, right now what I'm working on is a GUI window that contains a flash object acting as my GUI controls.

Within Flash, say you were working with vb script:

on (release) {
    fscommand("");
}

what I'm trying to figure out is what needs to be inside of the "" after the fscommand. Would it be a call to a function within the autoit script? Where do I go from here? Is this possible?

here is the function reference from the Flash help file:

Using the fscommand() function
NOTE
 
 The External API is a replacement for fscommand() in Flash 8 for interoperating with a HTML page or a container application. The External API offers more robust functionality than fscommand() in this situation. For more information, see About the External API.
 

You use the fscommand() function to send a message to whichever program is hosting Flash Player, such as a web browser. 

NOTE
 
 Using the fscommand() to call Javascript does not work on the Safari or Internet Explorer browsers for the Macintosh.
 

The fscommand() function has two parameters: command and arguments. To send a message to the stand-alone version of Flash Player, you must use predefined commands and arguments. For example, the following event handler sets the stand-alone player to scale the SWF file to the full monitor screen size when the button is released:

my_btn.onRelease = function() {
    fscommand("fullscreen", true);
};

Help!!

Link to comment
Share on other sites

I downloaded their demo flash file, which was making the calls, and this works for me:

#include <GUIConstants.au3>
$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
$SinkObject=ObjEvent($oRP,"sampleFlaMovie_") ; 

Func sampleFlaMovie_FSCommand($command,$args)
    msgbox(0,"FSCommand","Command: "&$command & @crlf & "Args:" & $args)
EndFunc

GUICreate ("Embed ShockwaveFlash control Test", 320, 265, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))

$GUIActiveX    = GUICtrlCreateObj( $oRP, 10, 10 , 300 , 225 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Movie = @scriptdir & '\sampleFlaMovie.swf'; the wave file from inet / could be on disk
    .ScaleMode = 3;0 showall, 1 noborder, 2 exactFit, 3 noscale
    .bgcolor = "#000000"; change background color to white FFFFFF
    .Loop = True
    .wmode = "Opaque"; Opaque / transparent
;.Stop / .Play
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
   
GUIDelete ()
Exit

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

okay, I used your example script, and my own flash file, and i got this kind of working.

The only problem now, is that every button I make in flash with the fscommand() in it calls the same function.

how do i vary which function the button calls?

sorry, im a designer by nature, not a programmer :)

Link to comment
Share on other sites

Using their example file again:

#include <GUIConstants.au3>
$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
$SinkObject=ObjEvent($oRP,"sampleFlaMovie_") ; 

Func sampleFlaMovie_FSCommand($command,$args)
;~  msgbox(0,"FSCommand","Command: "&$command & @crlf & "Args:" & $args)
    call($command,$args)
EndFunc

func showMessageBox($text)
    msgbox(0,"showMessageBox",$text)
EndFunc

func ask($text)
    msgbox(0,"ask",$text)
EndFunc

GUICreate ("Embed ShockwaveFlash control Test", 320, 265, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))

$GUIActiveX    = GUICtrlCreateObj( $oRP, 10, 10 , 300 , 225 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Movie = @scriptdir & '\sampleFlaMovie.swf'; the wave file from inet / could be on disk
    .ScaleMode = 3;0 showall, 1 noborder, 2 exactFit, 3 noscale
    .bgcolor = "#000000"; change background color to white FFFFFF
    .Loop = True
    .wmode = "Opaque"; Opaque / transparent
;.Stop / .Play
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
   
GUIDelete ()
Exit

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Thanks!

I feel stupid now. that makes too much sense for me to have thought of. :)

Now, just a shot in the dark, but does anybody know of a way to have the flash scripting take information back from say, a variable in the autoit script? For instance, if in the autoit script I had a input box come up to set a user name variable, would it be possible for Flash to read that variable and put it into a dynamic text box?

I'm assuming that it would use the Loadvariable command, but not sure how to format it to work with autoit

Edited by Justin
Link to comment
Share on other sites

Funny you should mention that. I found this while researching a previous support post:

http://www.permadi.com/tutorial/flashjscommand/

So, I think, with the example we're working with, assuming there is a Flash Form element named "message", this ought to be able to set it

$oRP.SetVariable("/:message", "Text from AutoIt!")
Let me know if that works, and if you make something really cool, post it to Scripts and Scraps!

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Funny you should mention that. I found this while researching a previous support post:

http://www.permadi.com/tutorial/flashjscommand/

So, I think, with the example we're working with, assuming there is a Flash Form element named "message", this ought to be able to set it

$oRP.SetVariable("/:message", "Text from AutoIt!")
Let me know if that works, and if you make something really cool, post it to Scripts and Scraps!

that worked perfectly!!!! This is actually pretty exciting since you can pretty much do endless design with a GUI in Flash, and easy complex functionality with AutoIt. I'll post my full program as soon as I get done. Thanks!

Link to comment
Share on other sites

  • 3 weeks later...

I've been away awhile, and just noticed this thread. Has anyone made an example Flash-based GUI? That could be really interesting to design your interface in Flash with animations and all that and have interaction with AutoIt for external functions.

In other words, I get what you're doing and understand the code. I'm just wondering if anyone has done anything impressive with it yet.

*Edit* Possibly a really slick progress bar? LOL Which brings up the subject of passing data back into the Flash, such as a value for the progress bar, or text box values.

*Edit* Nevermind, the SetVariable function should do it.

Edited by c0deWorm

My UDFs: ExitCodes

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...