Sign in to follow this  
Followers 0

_GuiCtrlCreateFlash()

14 posts in this topic

Posted (edited)

Pretty self explanatory really...

The Function.

Func _GuiCtrlCreateFlash($iXpos,$iYpos,$iWidth,$iHeight,$vSWFPath, $offset = 27)
    
    Local $oIE, $GUIActiveX, $tmp, $hFile
    $oIE = ObjCreate("Shell.Explorer.2")
    $GUIActiveX = GUICtrlCreateObj ($oIE, $iXpos, $iYpos, $iWidth, $iHeight)
    

    $tmp = '<object width="' & $iWidth & '" height="' & $iHeight & '">'
    $tmp &= '<param name="movie" value="AutoIt.swf">'
    $tmp &= '<embed src="' & $vSWFPath & '" width="' & $iWidth-$offset & '" height="' & $iHeight-$offset & '">'
    $tmp &= '</embed>'
    
    $hFile = FileOpen(@tempDir & "\AutoItFlash.html",2)
    FileWrite($hFile,$tmp)
    FileClose($hFile)
    $oIE.navigate(@tempDir & "\AutoItFlash.html")
    $oIE.document.body.scroll = "no"
    FileDelete(@tempDir & "\AutoItFlash.html")
    
    Return $GUIActiveX
    
EndFunc

An Example

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


    GUICreate("Embedded Flash", 640, 680, (@DesktopWidth - 640) / 2, (@DesktopHeight - 680) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $Flash = _GuiCtrlCreateFlash(10,10,400,300,"http://www.2inept.co.uk/icecastleblaster.swf")
    $Flash2 = _GuiCtrlCreateFlash(10,330,600,300,"http://www.flashgames247.com/images/logo_rhino_199x91.swf")
    GUISetState()   ;Show GUI

    

; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            
        EndSelect
        
    WEnd

    GUIDelete()


Func _GuiCtrlCreateFlash($iXpos,$iYpos,$iWidth,$iHeight,$vSWFPath, $offset = 27)
    
    Local $oIE, $GUIActiveX, $tmp, $hFile
    $oIE = ObjCreate("Shell.Explorer.2")
    $GUIActiveX = GUICtrlCreateObj ($oIE, $iXpos, $iYpos, $iWidth, $iHeight)
    

    $tmp = '<object width="' & $iWidth & '" height="' & $iHeight & '">'
    $tmp &= '<param name="movie" value="AutoIt.swf">'
    $tmp &= '<embed src="' & $vSWFPath & '" width="' & $iWidth-$offset & '" height="' & $iHeight-$offset & '">'
    $tmp &= '</embed>'
    
    $hFile = FileOpen(@tempDir & "\AutoItFlash.html",2)
    FileWrite($hFile,$tmp)
    FileClose($hFile)
    $oIE.navigate(@tempDir & "\AutoItFlash.html")
    $oIE.document.body.scroll = "no"
    FileDelete(@tempDir & "\AutoItFlash.html")
    
    Return $GUIActiveX
    
EndFunc
Edited by ChrisL

Share this post


Link to post
Share on other sites



Posted

Pretty self explanatory really...

The Function.

Func _GuiCtrlCreateFlash($iXpos,$iYpos,$iWidth,$iHeight,$vSWFPath, $offset = 42)
    
    Local $oIE, $GUIActiveX, $tmp, $hFile
    $oIE = ObjCreate("Shell.Explorer.2")
    $GUIActiveX = GUICtrlCreateObj ($oIE, $iXpos, $iYpos, $iWidth, $iHeight)

    $tmp = '<object width="' & $iWidth & '" height="' & $iHeight & '">'
    $tmp &= '<param name="movie" value="AutoIt.swf">'
    $tmp &= '<embed src="' & $vSWFPath & '" width="' & $iWidth-$offset & '" height="' & $iHeight-$offset & '">'
    $tmp &= '</embed>'
    
    $hFile = FileOpen(@tempDir & "\AutoItFlash.html",2)
    FileWrite($hFile,$tmp)
    FileClose($hFile)
    $oIE.navigate(@tempDir & "\AutoItFlash.html")
    
    FileDelete(@tempDir & "\AutoItFlash.html")
    
    Return $GUIActiveX
    
EndFunc

An Example

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


    GUICreate("Embedded Flash", 640, 680, (@DesktopWidth - 640) / 2, (@DesktopHeight - 680) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $Flash = _GuiCtrlCreateFlash(10,10,400,300,"http://www.2inept.co.uk/icecastleblaster.swf")
    $Flash2 = _GuiCtrlCreateFlash(10,330,600,300,"http://www.flashgames247.com/images/logo_rhino_199x91.swf")
    GUISetState()   ;Show GUI

    

; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            
        EndSelect
        
    WEnd

    GUIDelete()


Func _GuiCtrlCreateFlash($iXpos,$iYpos,$iWidth,$iHeight,$vSWFPath, $offset = 42)
    
    Local $oIE, $GUIActiveX, $tmp, $hFile
    $oIE = ObjCreate("Shell.Explorer.2")
    $GUIActiveX = GUICtrlCreateObj ($oIE, $iXpos, $iYpos, $iWidth, $iHeight)

    $tmp = '<object width="' & $iWidth & '" height="' & $iHeight & '">'
    $tmp &= '<param name="movie" value="AutoIt.swf">'
    $tmp &= '<embed src="' & $vSWFPath & '" width="' & $iWidth-$offset & '" height="' & $iHeight-$offset & '">'
    $tmp &= '</embed>'
    
    $hFile = FileOpen(@tempDir & "\AutoItFlash.html",2)
    FileWrite($hFile,$tmp)
    FileClose($hFile)
    $oIE.navigate(@tempDir & "\AutoItFlash.html")
    
    FileDelete(@tempDir & "\AutoItFlash.html")
    
    Return $GUIActiveX
    
EndFunc
Nice work! Thanks for sharing ChrisL! muttley

Share this post


Link to post
Share on other sites

Posted

Awsome function....one thing... could u add a new param to hide the scrollbar?

Thx

Share this post


Link to post
Share on other sites

Posted

Why are you embedding an Internet Explorer object? Embed the Flash player directly:

Func _CreateSWF($SWFPath, $SWFL, $SWFT, $SWFW, $SWFH, $SWFBGColor = "#505050")

    ; Create Flash Object
    $SWFObj = ObjCreate("ShockwaveFlash.ShockwaveFlash")
    $SWFActiveX = GUICtrlCreateObj( $SWFObj, $SWFL, $SWFT, $SWFW, $SWFH)

    ; Configure Flash Object
    With $SWFObj
        .Movie = $SWFPath
        .ScaleMode = 3 ;0 showall, 1 noborder, 2 exactFit, 3 noscale
        .bgcolor = $SWFBGColor
        .Loop = True
        ;.WMode = "transparent"
        .allowScriptAccess = "Always"
        
        ;Variable inject Method 1
        ;.FlashVars = '&library_path=' & @ScriptDir & '\charts_library&xml_source=' & @ScriptDir & '\sample.xml'
        
        ;Variable inject Method 2
        ;.SetVariable('library_path', @ScriptDir & '\charts_library')
        ;.SetVariable('xml_source', $SWFPath)
    EndWith
    
    Return $SWFObj
EndFunc

Share this post


Link to post
Share on other sites

Posted

Why are you embedding an Internet Explorer object? Embed the Flash player directly:

Func _CreateSWF($SWFPath, $SWFL, $SWFT, $SWFW, $SWFH, $SWFBGColor = "#505050")

    ; Create Flash Object
    $SWFObj = ObjCreate("ShockwaveFlash.ShockwaveFlash")
    $SWFActiveX = GUICtrlCreateObj( $SWFObj, $SWFL, $SWFT, $SWFW, $SWFH)

    ; Configure Flash Object
    With $SWFObj
        .Movie = $SWFPath
        .ScaleMode = 3 ;0 showall, 1 noborder, 2 exactFit, 3 noscale
        .bgcolor = $SWFBGColor
        .Loop = True
        ;.WMode = "transparent"
        .allowScriptAccess = "Always"
        
        ;Variable inject Method 1
        ;.FlashVars = '&library_path=' & @ScriptDir & '\charts_library&xml_source=' & @ScriptDir & '\sample.xml'
        
        ;Variable inject Method 2
        ;.SetVariable('library_path', @ScriptDir & '\charts_library')
        ;.SetVariable('xml_source', $SWFPath)
    EndWith
    
    Return $SWFObj
EndFunc
Ahh much better

Share this post


Link to post
Share on other sites

Posted

Awsome function....one thing... could u add a new param to hide the scrollbar?

Thx

I did it but it appears that my method was not the best way

Share this post


Link to post
Share on other sites

Posted (edited)

Good job Chris... It is nice :(

I did it but it appears that my method was not the best way

It doesnt matter.. You tried and you did pretty good muttley

You help a lot of people like me :)

Edited by Konstig

Share this post


Link to post
Share on other sites

Posted

@ChrisL

This might give you some more inspiration

Embedded Flash Payer

regards,

ptrex

Share this post


Link to post
Share on other sites

Posted

Good job

Share this post


Link to post
Share on other sites

Posted

Func _CreateSWF($SWFPath, $SWFL, $SWFT, $SWFW, $SWFH, $SWFBGColor = "#505050")

    ; Create Flash Object
    $SWFObj = ObjCreate("ShockwaveFlash.ShockwaveFlash")
    $SWFActiveX = GUICtrlCreateObj( $SWFObj, $SWFL, $SWFT, $SWFW, $SWFH)

    ; Configure Flash Object
    With $SWFObj
        .Movie = $SWFPath
        .ScaleMode = 3 ;0 showall, 1 noborder, 2 exactFit, 3 noscale
        .bgcolor = $SWFBGColor
        .Loop = True
        ;.WMode = "transparent"
        .allowScriptAccess = "Always"
        
        ;Variable inject Method 1
        ;.FlashVars = '&library_path=' & @ScriptDir & '\charts_library&xml_source=' & @ScriptDir & '\sample.xml'
        
        ;Variable inject Method 2
        ;.SetVariable('library_path', @ScriptDir & '\charts_library')
        ;.SetVariable('xml_source', $SWFPath)
    EndWith
    
    Return $SWFObj
EndFunc
Noobie here

I don't understand how to pass along the .xml file to the .swf I uncommented your

.SetVariable('xml_source', $SWFPath)
and renamed the 'xml_source' to the name of my xml file but the file doesn't seem to get passed. I know that it works with embed in an HTML file

<PARAM NAME="movie" VALUE="gauge.swf?xml_source=sample.xml" />

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites

Posted

Noobie here

I don't understand how to pass along the .xml file to the .swf I uncommented your

.SetVariable('xml_source', $SWFPath)
and renamed the 'xml_source' to the name of my xml file but the file doesn't seem to get passed. I know that it works with embed in an HTML file

<PARAM NAME="movie" VALUE="gauge.swf?xml_source=sample.xml" />

Any help would be greatly appreciated

You probably have to use the full path to the file.

Share this post


Link to post
Share on other sites

Posted

You probably have to use the full path to the file.

Tried that. just causes the flash to not even try to run

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


    GUICreate("Embedded Flash", 640, 680, (@DesktopWidth - 640) / 2, (@DesktopHeight - 680) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $Flash = _CreateSWF('C:\Documents and Settings\user\Desktop\gauge\gauge.swf',10,10,400,300)
    $Flash2 = _GuiCtrlCreateFlash(10,330,600,300,"C:\Documents and Settings\user\Desktop\gauge\gauge.swf?xml_source=sample.xml")
    GUISetState()    ;Show GUI

    

; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            
        EndSelect
        
    WEnd

    GUIDelete()

Func _CreateSWF($SWFPath, $SWFL, $SWFT, $SWFW, $SWFH, $SWFBGColor = "#505050")

    ; Create Flash Object
    $SWFObj = ObjCreate("ShockwaveFlash.ShockwaveFlash")
    $SWFActiveX = GUICtrlCreateObj( $SWFObj, $SWFL, $SWFT, $SWFW, $SWFH)

    ; Configure Flash Object
    With $SWFObj
        .Movie = $SWFPath
        .ScaleMode = 3 ;0 showall, 1 noborder, 2 exactFit, 3 noscale
        .bgcolor = $SWFBGColor
        .Loop = True
        ;.WMode = "transparent"
        .allowScriptAccess = "Always"
        
        ;Variable inject Method 1
        ;.FlashVars = '&library_path=' & @ScriptDir & '\charts_library&xml_source=' & @ScriptDir & '\sample.xml'
        
        ;Variable inject Method 2
        ;.SetVariable('library_path', @ScriptDir & '\charts_library')
        .SetVariable('C:\Documents and Settings\user\Desktop\gauge\sample.xml', $SWFPath)
    EndWith
    
    Return $SWFObj
EndFunc
Func _GuiCtrlCreateFlash($iXpos,$iYpos,$iWidth,$iHeight,$vSWFPath, $offset = 42)
    
    Local $oIE, $GUIActiveX, $tmp, $hFile
    $oIE = ObjCreate("Shell.Explorer.2")
    $GUIActiveX = GUICtrlCreateObj ($oIE, $iXpos, $iYpos, $iWidth, $iHeight)

    $tmp = '<object width="' & $iWidth & '" height="' & $iHeight & '">'
    $tmp &= '<param name="movie" value="gauge.swf?xml_source=sample.xml">'
    $tmp &= '<embed src="' & $vSWFPath & '" width="' & $iWidth-$offset & '" height="' & $iHeight-$offset & '">'
    $tmp &= '</embed>'
    
    $hFile = FileOpen(@tempDir & "\AutoItFlash.html",2)
    FileWrite($hFile,$tmp)
    FileClose($hFile)
    $oIE.navigate(@tempDir & "\AutoItFlash.html")
    
    FileDelete(@tempDir & "\AutoItFlash.html")
    
    Return $GUIActiveX
    
EndFunc

Trying to piece together a useful way to display the flash, I have tried both ways of embeding it in autoit. Neither way seems to work. The .swf file is a way for me to make gauges in my project but I must be able to have it find the .xml file. Normally this code works

<HTML>
<BODY bgcolor="#FFFFFF">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" 
    WIDTH="400"
    HEIGHT="250"
    id="gauge" />
<PARAM NAME="movie" VALUE="gauge.swf?xml_source=sample.xml" />
<PARAM NAME="quality" VALUE="high" />
<PARAM NAME="bgcolor" VALUE="#666666" />
<param name="allowScriptAccess" value="sameDomain" />
<EMBED src="gauge.swf?xml_source=sample.xml" 
    quality="high" 
    bgcolor="#666666" 
    WIDTH="400" 
    HEIGHT="250" 
    NAME="gauge" 
    allowScriptAccess="sameDomain" 
    swLiveConnect="true" 
    TYPE="application/x-shockwave-flash" 
    PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
</BODY>
</HTML>

I make sure that the xml is in the same directory as the swf file and everything works. So I guess what I really am asking is a better defination of .Setvariable and how this works. Again thanks in advance. muttley

Here is a link to where I got the flash from: Flash Gauges

Share this post


Link to post
Share on other sites

Posted (edited)

This isn't correct:

.SetVariable('C:\Documents and Settings\user\Desktop\gauge\sample.xml', $SWFPath)

Should be:

.SetVariable('xml_source', 'C:\Documents and Settings\user\Desktop\gauge\sample.xml'

Maybe also try:

.FlashVars = '&xml_source=' & @ScriptDir & '\sample.xml'

Edited by weaponx

Share this post


Link to post
Share on other sites

Posted

This isn't correct:

.SetVariable('C:\Documents and Settings\user\Desktop\gauge\sample.xml', $SWFPath)

Should be:

.SetVariable('xml_source', 'C:\Documents and Settings\user\Desktop\gauge\sample.xml'

Maybe also try:

.FlashVars = '&xml_source=' & @ScriptDir & '\sample.xml'

Thanks weaponx

I could not get .SetVariable('xml_source', 'C:\Documents and Settings\user\Desktop\gauge\sample.xml' to work gave me a syntax error

but

.FlashVars = '&xml_source=' & @ScriptDir & '\sample.xml' did work

this has helped out alot Thanks for sticking with me thru this

Your a gentleman and a scholar.....

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

  • Recently Browsing   0 members

    No registered users viewing this page.