Sign in to follow this  
Followers 0
gsb

Flash content and fscommand event trouble...

9 posts in this topic

#1 ·  Posted (edited)

As a noobe I am trying to learn by example.

I am trying to combine tow examples by lod3n on "flashy" content.

One to catch and process the movies FSCommand events, and the other was to better handle the problem of resizing the flash content by embedding the flashy in another object.

And as a noobe, I have, so far, failed.

The problem is timing I thing.

I believe that the fscommand event handler needs to be defined before the flash player is initialized - ..well is just my thought.

I could sure use some help on making something like this work.

#include <GUIConstants.au3>
#include <ie.au3>
#include <array.au3>

$flashfile = _ArrayToString($cmdline," ",1)

$gui = GUICreate("Flashy"&$flashfile, 640, 480, -1, -1, 
          BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,
          $WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,
          $WS_CLIPSIBLINGS),$WS_EX_ACCEPTFILES)

$oIE = _IECreateEmbedded ( )
$browser = GUICtrlCreateObj($oIE, 3, 3, 634, 474)
GUICtrlSetState (-1, $GUI_DROPACCEPTED)
GUICtrlSetResizing(-1,$GUI_DOCKBORDERS)

_IENavigate ($oIE, 'about:blank')
$oDoc = _IEDocGetObj ($oIE)
$oDoc.body.style.overflow = "hidden"; "auto"
$oDoc.body.style.height = "100%"
$oDoc.body.style.margin = "0"
$oDoc.body.style.padding = "0"
GUISetState(@SW_SHOW)

$sHTML = '<embed id=flashy src="" '
$sHTML &= 'pluginspage="http://www.macromedia.com/go/getflashplayer" '
$sHTML &= 'type="application/x-shockwave-flash" '
$sHTML &= 'width="100%" height="100%" '
$sHTML &= 'bgcolor="#CCCCCC" '
$sHTML &= 'quality="best" '
$sHTML &= 'loop="false" '
$sHTML &= 'flashvars="gsbDebugLevel=2" '
$sHTML &= 'wmode="opaque" '
$sHTML &= 'swliveconnect="true"></embed>'
_IEBodyWriteHTML ($oIE, $sHTML)

$flash = _IEGetObjByName ($oIE, "flashy")
$oSink = ObjEvent($flash,"flashy_")
$eHndlr = ObjEvent($flash,"IEEvent_","Preview")

Func flashy_FSCommand($cmd,$args)
    msgbox(0,"FSCommand","au3 Command: "&$cmd & @crlf & "Args:" & $args)
EndFunc

if stringlen($flashfile) = 0 then 
    $flashfile = @scriptdir & "\localtest.swf"; default
ElseIf stringright($flashfile,4) <> ".swf" then 
    msgbox(16,"Flashy - Error","Bad file type.")
    Exit
EndIf

$flash.Movie = $flashfile
winsettitle($gui,"","Flashy - "&$flashfile)

While 1
    $Msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        case $msg = $GUI_EVENT_DROPPED
            loadswf(@GUI_DRAGFILE)
    EndSelect
WEnd

And thanks lod3n for your great example posts.

gsb

I've attached that little swf file.

example.zip

Edited by gsb

"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites



The problem is not timing.

In my experience, catching events from FScommand only works properly when you are dealing with a directly embedded flash object. If you try and go through IE, you will run into security issues. I think if you're going through IE like that, the only events that you can catch are mouseovers, and so forth.

The embedded flash object is great for FScommand, but not resizing. You can't even GUICtrlSetPos it. So, I would suggest, if you are really keen on resizing it, that you destroy it and recreate it whenever you resize the GUI. Not a lot of other options that I can see.

Personally, I think there is something fishy going on with AutoIt and resizing the flash object, but I'm sure I'd get argued right out of the forum if I seriously suggested something like that armed only with naive suspicion.


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

Share this post


Link to post
Share on other sites

Thank you for your time lod3n.

I will take that as the final answer then.

However I did make an example that worked as I wanted but was a true kludge.

Combining both techniques, one to simply execute fscommands and the other as a resizable movie.

Internally they use LocalConnection objects to pass requests and responses to and from.

So the second acts like a "server" of sorts to the actual movie.

Perhaps I will spend some more time on it and clean it up now that it seems the only practical solution.

Again, Thanks for your input.

gsb


"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites

You *might* be able to do it if the flash file were hosted on a web server. The security surrounding FSCommand, etc is triggered by *local* files. Good luck with whatever you come up with.

It would be really nifty to see a new flash based UI UDF spring forth. I would take a crack at it, but I don't know enough about flash to do much.


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

Share this post


Link to post
Share on other sites

Thanks again lod3n.

I willl try that too when I get a chance.

gsb


"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

So lod3n,

I took your comments to heart and this evening, when I got home from work, I went back and (tried to) clean up a previous example based on two of your "flashy" posts. It works fine for me and is included below in a zipped file.

This uses the LocalConnection object between two .swf's as I explained above, making the controller .swf as a server of sorts to the application .swf. The application.swf can be any local swf with a little special code (action script) included. BTW I do not use Flash but rather SWiSHmax, a cheaper version to generate the .swf's. So not .fla but .swi files which are also included.

The result is a local swf (application.swf) run with this simple .exe (localtest7.exe) with its accompanying controller.swf allows the local application full system access via the fscommand.

This is an alternative to the far more restrictive "projector .exe" files generated by the SWiSHmax application (or flash for that matter) due to the Flash Player security model as you mentioned above.

In this example, the fscommand is ... well, very limited to say the least. But it does generates a local log file of the fscommands transactions (gsblog.txt) a feat not do-able with a simple "projector .exe" file as exported from the SWiSHmax application. It is simply a quick example for proof of concept.

See, I am a co-admin on a popular SWiSHmax forum and such issues are often raised. To date, most of my work (~all) is web based. However, I thought I might try to find a better method for these .exe users trying to make presentations with interfaces to other system applications.

Here is the AutoIt code. Suggestion for improvement are welcomed. Not many others here seem interested in such so I address this more to you lod3n. BTW: I am in Seattle.

#include <GUIConstants.au3>
#include <ie.au3>
#include <array.au3>

$flashfile = _ArrayToString($cmdline," ",1)
if stringlen($flashfile) = 0 then 
    $flashfile = @scriptdir & "\application.swf"; default
ElseIf stringright($flashfile,4) <> ".swf" then 
    msgbox(16,"Flashy - Error","Bad file type.")
    Exit
EndIf

$file = FileOpen("gsblog.txt", 1)

$gui = GUICreate("Flashy - " & $flashfile, 640, 480, -1, -1, 
    BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,
    $WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,
    $WS_CLIPSIBLINGS),$WS_EX_ACCEPTFILES); ...wrap issues

$sfObj = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
$SinkObject=ObjEvent($sfObj,"controller_"); 
$GUIActiveX = GUICtrlCreateObj( $sfObj, 0, 0, 1, 1)
$sfObj.Movie = @scriptdir & "\controller.swf"
$sfObj.ScaleMode = 3
$sfObj.BGColor = "#DDDDDD"
$sfObj.Loop = false
$sfObj.WMode = "window"

$oIE = _IECreateEmbedded ( )
$browser = GUICtrlCreateObj($oIE, 2, 2, 636, 476)
GUICtrlSetState (-1, $GUI_DROPACCEPTED)
GUICtrlSetResizing(-1,$GUI_DOCKBORDERS)

_IENavigate ($oIE, 'about:blank')
$oDoc = _IEDocGetObj ($oIE)
$oDoc.body.style.overflow = "hidden"
$oDoc.body.style.height = "100%"
$oDoc.body.style.margin = "0"
$oDoc.body.style.padding = "0"
GUISetState(@SW_SHOW)

$sHTML  = '<embed '
$sHTML &= 'id=application '
$sHTML &= 'src="' & $flashfile & '" '
$sHTML &= 'pluginspage="http://www.macromedia.com/go/getflashplayer" '
$sHTML &= 'type="application/x-shockwave-flash" '
$sHTML &= 'width="100%" height="100%" '
$sHTML &= 'bgcolor="#CCCCCC" '
$sHTML &= 'quality="best" '
$sHTML &= 'loop="false" '
$sHTML &= 'flashvars="gsbTraceLevel=2" '
$sHTML &= 'wmode="window" '
$sHTML &= 'swliveconnect="true" '
$sHTML &= '></embed>'
_IEBodyWriteHTML ($oIE, $sHTML)
$application = _IEGetObjByName ($oIE, "application")

While 1
    $Msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        case $msg = $GUI_EVENT_DROPPED
            loadswf(@GUI_DRAGFILE)
    EndSelect
WEnd

FileClose($file)

Exit

Func controller_FSCommand($cmd,$args)
    Select
        Case $cmd = "showmenu"
            Return
        Case stringlen($flashfile) > 0; defalut select
            If $file <> -1 Then
                FileWrite($file, "FSCommand - cmd: " & $cmd & "  Args: " & $args & @CRLF)
            EndIf
            msgbox(0,"FSCommand","au3 FSCommand" & @crlf & "Cmd: " & $cmd & @crlf & "Args: " & $args)
    EndSelect
EndFunc

And thanks again for your interest and help.

gsb

exampleFiles.zip

Edited by gsb

"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites

That is really cool! Good job. You know, you can have your FSCommand call any function you like, just use Call($cmd, $arg). Well, you can have it call any of your *own* functions. There's some limitations on calling AutoIt functions.


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

Share this post


Link to post
Share on other sites

Thanks lod3n... was you that got me started.

I made a standalone tray icon script that provides this back-end fscommand processing to any "configured" flash page from the web too.

Is coming along well.

gsb


"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites

OK Lod3n,

Here is a simple example to download and run.

Is a compiled au3 and a 1K swf.

The exe loads a mixed HTML page from the web and provides both local (javascript in the page) fscommand support as well as 'remote' fscommand support via the controller.swf and the compiled AutoIt script, gsb_fscp.exe.

Grab it at my site to test... Example zipped 237k

...if you are still interested.

gsb


"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
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
Sign in to follow this  
Followers 0