Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_GuiCtrlCreateFlash()


  • Please log in to reply
13 replies to this topic

#1 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,759 posts

Posted 03 July 2008 - 07:29 AM

Pretty self explanatory really...

The Function.

Plain Text         
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

Plain Text         
#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,"<a href='http://www.2inept.co.uk/icecastleblaster.swf' class='bbc_url' title='External link' rel='nofollow external'>http://www.2inept.co.uk/icecastleblaster.swf"</a>)     $Flash2 = _GuiCtrlCreateFlash(10,330,600,300,"<a href='http://www.flashgames247.com/images/logo_rhino_199x91.swf' class='bbc_url' title='External link' rel='nofollow external'>http://www.flashgames247.com/images/logo_rhino_199x91.swf"</a>)     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, 03 July 2008 - 12:47 PM.








#2 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,590 posts

Posted 03 July 2008 - 09:04 AM

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

Plain Text         
#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,"<a href='http://www.2inept.co.uk/icecastleblaster.swf' class='bbc_url' title='External link' rel='nofollow external'>http://www.2inept.co.uk/icecastleblaster.swf"</a>)     $Flash2 = _GuiCtrlCreateFlash(10,330,600,300,"<a href='http://www.flashgames247.com/images/logo_rhino_199x91.swf' class='bbc_url' title='External link' rel='nofollow external'>http://www.flashgames247.com/images/logo_rhino_199x91.swf"</a>)     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:
When the words fail... music speaks

#3 Synapse

Synapse

    Adventurer

  • Active Members
  • PipPip
  • 107 posts

Posted 03 July 2008 - 10:36 AM

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

Thx

#4 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 03 July 2008 - 12:48 PM

Why are you embedding an Internet Explorer object? Embed the Flash player directly:
AutoIt         
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


#5 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,759 posts

Posted 03 July 2008 - 12:53 PM

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

AutoIt         
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

#6 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,759 posts

Posted 03 July 2008 - 12:54 PM

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

#7 DexterMorgan

DexterMorgan

    My Member Title

  • Active Members
  • PipPipPipPipPipPip
  • 890 posts

Posted 03 July 2008 - 02:39 PM

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, 03 July 2008 - 02:39 PM.

code

#8 ptrex

ptrex

    Universalist

  • MVPs
  • 2,415 posts

Posted 03 July 2008 - 07:21 PM

@ChrisL

This might give you some more inspiration

Embedded Flash Payer

regards,

ptrex

#9 dmoniac

dmoniac

    Seeker

  • Active Members
  • 21 posts

Posted 04 July 2008 - 09:15 AM

Good job

#10 nhardel

nhardel

    Seeker

  • Active Members
  • 30 posts

Posted 13 July 2008 - 08:09 PM

AutoIt         
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

#11 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 13 July 2008 - 10:21 PM

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.

#12 nhardel

nhardel

    Seeker

  • Active Members
  • 30 posts

Posted 14 July 2008 - 03:11 AM

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

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

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

#13 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 14 July 2008 - 03:27 AM

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, 14 July 2008 - 03:29 AM.


#14 nhardel

nhardel

    Seeker

  • Active Members
  • 30 posts

Posted 15 July 2008 - 01:29 AM

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.....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users