Что нового

Работа с Adobe Flash (SWF)

ynbIpb

Скриптер
Сообщения
399
Репутация
110
Решил тут поработать с флешем. на англ. форуме нашёл некоторый код. вот что имею:
Код:
#include <WindowsConstants.au3>

$swffile = @ScriptDir & "\file.swf"
If Not FileExists($swffile) Then
    Exit
EndIf
GUICreate("Flash", 640, 510)
$Button_1 = GUICtrlCreateButton("stop", 10, 482, 75, 20)
$Flash_Create = ObjCreate("ShockwaveFlash.ShockwaveFlash.8")
$Flash_Load_Obj = GUICtrlCreateObj($Flash_Create , 0 , 0 , 640, 480)
$Flash_Create.Movie = $swffile
$Flash_Create.Loop = True
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
		Case $Button_1
			; что тут вставить чтоб остановить флеш 
             ;и освободить память и всё такое
    EndSwitch
WEnd
Так вот есть наверное какой-то перечень команд, который я не знаю ну вот типа как там есть две: $Flash_Create.Movie и $Flash_Create.Loop, какие ещё бывают?
Как правильно завершать работу с флешем? наверное нужно какуюто команду объекту послать? и освободить некие переменные?
 

kaster

Мой Аватар, он лучший самый
Команда форума
Глобальный модератор
Сообщения
4,020
Репутация
626
не совсем то, то может пригодится
http://www.php.ru/manual/ref.swf.html
 
Автор
ynbIpb

ynbIpb

Скриптер
Сообщения
399
Репутация
110
Да что-то я там вообще ничего не понимаю.
почитал инглишсайт по поводу объектов.
единственное, что понял выключать объект нужно присваиванием его переменной нуля.
пробовал вот такое ставить на кнопку стоп:
$Flash_Create.Stop()
$Flash_Create = 0
но флешролик всёравно продолжает играть...
 

Renz

Осваивающий
Сообщения
63
Репутация
37
не все swf можно остановить т.к. они пишутся в одном фрейме(кадре)
 
Автор
ynbIpb

ynbIpb

Скриптер
Сообщения
399
Репутация
110
Да, это до меня уже дошло. Сделал по хитрому, каждый раз создаю и удаляю контрол с флешем в своём гуи.

Код:
Func _startplayer ($indexx); функция начала воспроизведения 
If $indexx = 0 Then Return ; если индекс 0 значит ничего не выбрано. 
$curfile = $swffilesdir &"\"& $swffiles[$indexx] 
GUICtrlSetState ($list_1, $GUI_HIDE); скрываем список 
GUICtrlSetState ($pic_1, $GUI_HIDE); скрываем картинку 
GUICtrlSetState ($Label_1, $GUI_HIDE); скрываем лейбл с текстом 
GUICtrlSetState ($Button_1, $GUI_SHOW); отображаем кнопку 
GUICtrlSetState ($Button_2, $GUI_SHOW); отображаем кнопку 
GUICtrlSetState ($Button_3, $GUI_SHOW); отображаем кнопку 
Global $Flash_Create = ObjCreate("ShockwaveFlash.ShockwaveFlash.10"); должен быть установлен flash_player_ax_v.10.x 
Global $Flash_Load_Obj = GUICtrlCreateObj($Flash_Create , 0 , 0 , 800, 620) 
$Flash_Create.Movie = $curfile 
$Flash_Create.Loop = True 
WinSetTitle ($TeachshopGUI, "", "Teachshop shell "&$version&"  -  "&$swffiles[$indexx]); меняем заголовок окна на имя урока 
EndFunc 
 
Func _stopplayer (); функция остановки воспроизведения 
$Flash_Create.Stop() ; останавливаем воспроизведение 
$Flash_Create = 0 
GUICtrlDelete ($Flash_Load_Obj); удаляем окно с флешем 
GUICtrlSetState ($Button_1, $GUI_HIDE) ; прячем кнопку 
GUICtrlSetState ($Button_2, $GUI_HIDE) ; прячем кнопку 
GUICtrlSetState ($Button_3, $GUI_HIDE) ; прячем кнопку 
GUICtrlSetState ($list_1, $GUI_SHOW) ; отображаем список 
GUICtrlSetState ($pic_1, $GUI_SHOW); отображаем картинку 
GUICtrlSetState ($Label_1, $GUI_SHOW); отображаем лейбл с текстом 
WinSetTitle ($TeachshopGUI, "", "Teachshop shell "&$version); возвращаем исходное состояние заголовка 
EndFunc
 

Renz

Осваивающий
Сообщения
63
Репутация
37
Вот все свойства:
  • width=px or % (Modify the width of the object)
  • height=px or a% (Modify the height of the object)
  • play=true/false (Start playing the file or wait at first frame, default:true)
  • loop=true/false (Loop the animation, default:true)
  • quality=low/autolow/medium/high/autohigh/best (Predefine the quality)
  • devicefont=true/false (Change the look of the text used in flash file)
  • bgcolor=#? (? -> Hexadecimal integer: 0-9, A-F)
  • scale=showall/noborder/exactfit (Automatically adjust content to width and height)
  • menu=true/false (Show or hide the menu on right-click)
  • align
  • salign
  • base
  • wmode
  • SeamlessTabbing
  • flashvars=?var1=value1&var2=value2 (communicate two variables var1 and var2 to the movie)
  • name (object-specific)
  • id (embed-specific)
  • movie (object-specific)
  • src (embed-specific)
 

Renz

Осваивающий
Сообщения
63
Репутация
37
Долго копал по работе с Flash. Решение оказалось внутри flash10I.ocx, думаю пригодится кому-нибудь. Необходимо было отлавливать нажатие batton в swf, менял frame при нажатии и проверял его значение, для меня было так проще.
Код:
//Shockwave Flash
//Version: 1.0
ShockwaveFlashObjects;
GUID = {D27CDB6B-AE6D-11CF-96B8-444553540000};


//Shockwave Flash
Dispatch IShockwaveFlash;
GUID = {D27CDB6C-AE6D-11CF-96B8-444553540000};
  function QueryInterface(riid: ^GUID; out ppvObj: ^^VOID); stdcall;
  function AddRef: UI4; stdcall;
  function Release: UI4; stdcall;
  function GetTypeInfoCount(out pctinfo: ^UINT); stdcall;
  function GetTypeInfo(itinfo: UINT; lcid: UI4; out pptinfo: ^^VOID); stdcall;
  function GetIDsOfNames(riid: ^GUID; rgszNames: ^^I1; cNames: UINT; lcid: UI4; out rgdispid: ^I4); stdcall;
  function Invoke(dispidMember: I4; riid: ^GUID; lcid: UI4; wFlags: UI2; pdispparams: ^DISPPARAMS; out pvarResult: ^Variant; out pexcepinfo: ^EXCEPINFO; out puArgErr: ^UINT); stdcall;
  //property ReadyState
  property-get ReadyState: I4; stdcall;
  //property TotalFrames
  property-get TotalFrames: I4; stdcall;
  //property Playing
  property-get Playing: Bool; stdcall;
  //property Playing
  property-put Playing(: Bool); stdcall;
  //property Quality
  property-get Quality: INT; stdcall;
  //property Quality
  property-put Quality(: INT); stdcall;
  //property ScaleMode
  property-get ScaleMode: INT; stdcall;
  //property ScaleMode
  property-put ScaleMode(: INT); stdcall;
  //property AlignMode
  property-get AlignMode: INT; stdcall;
  //property AlignMode
  property-put AlignMode(: INT); stdcall;
  //property BackgroundColor
  property-get BackgroundColor: I4; stdcall;
  //property BackgroundColor
  property-put BackgroundColor(: I4); stdcall;
  //property Loop
  property-get Loop: Bool; stdcall;
  //property Loop
  property-put Loop(: Bool); stdcall;
  //property Movie
  property-get Movie: BSTR; stdcall;
  //property Movie
  property-put Movie(: BSTR); stdcall;
  //property FrameNum
  property-get FrameNum: I4; stdcall;
  //property FrameNum
  property-put FrameNum(: I4); stdcall;
  //method SetZoomRect
  function SetZoomRect(left: I4; top: I4; right: I4; bottom: I4); stdcall;
  //method Zoom
  function Zoom(factor: INT); stdcall;
  //method Pan
  function Pan(x: I4; y: I4; mode: INT); stdcall;
  //method Play
  function Play; stdcall;
  //method Stop
  function Stop; stdcall;
  //method Back
  function Back; stdcall;
  //method Forward
  function Forward; stdcall;
  //method Rewind
  function Rewind; stdcall;
  //method StopPlay
  function StopPlay; stdcall;
  //method GotoFrame
  function GotoFrame(FrameNum: I4); stdcall;
  //method CurrentFrame
  function CurrentFrame: I4; stdcall;
  //method IsPlaying
  function IsPlaying: Bool; stdcall;
  //method PercentLoaded
  function PercentLoaded: I4; stdcall;
  //method FrameLoaded
  function FrameLoaded(FrameNum: I4): Bool; stdcall;
  //method FlashVersion
  function FlashVersion: I4; stdcall;
  //property WMode
  property-get WMode: BSTR; stdcall;
  //property WMode
  property-put WMode(: BSTR); stdcall;
  //property SAlign
  property-get SAlign: BSTR; stdcall;
  //property SAlign
  property-put SAlign(: BSTR); stdcall;
  //property Menu
  property-get Menu: Bool; stdcall;
  //property Menu
  property-put Menu(: Bool); stdcall;
  //property Base
  property-get Base: BSTR; stdcall;
  //property Base
  property-put Base(: BSTR); stdcall;
  //property Scale
  property-get Scale: BSTR; stdcall;
  //property Scale
  property-put Scale(: BSTR); stdcall;
  //property DeviceFont
  property-get DeviceFont: Bool; stdcall;
  //property DeviceFont
  property-put DeviceFont(: Bool); stdcall;
  //property EmbedMovie
  property-get EmbedMovie: Bool; stdcall;
  //property EmbedMovie
  property-put EmbedMovie(: Bool); stdcall;
  //property BGColor
  property-get BGColor: BSTR; stdcall;
  //property BGColor
  property-put BGColor(: BSTR); stdcall;
  //property Quality2
  property-get Quality2: BSTR; stdcall;
  //property Quality2
  property-put Quality2(: BSTR); stdcall;
  //method LoadMovie
  function LoadMovie(layer: INT; url: BSTR); stdcall;
  //method TGotoFrame
  function TGotoFrame(target: BSTR; FrameNum: I4); stdcall;
  //method TGotoLabel
  function TGotoLabel(target: BSTR; label: BSTR); stdcall;
  //method TCurrentFrame
  function TCurrentFrame(target: BSTR): I4; stdcall;
  //method TCurrentLabel
  function TCurrentLabel(target: BSTR): BSTR; stdcall;
  //method TPlay
  function TPlay(target: BSTR); stdcall;
  //method TStopPlay
  function TStopPlay(target: BSTR); stdcall;
  //method SetVariable
  function SetVariable(name: BSTR; value: BSTR); stdcall;
  //method GetVariable
  function GetVariable(name: BSTR): BSTR; stdcall;
  //method TSetProperty
  function TSetProperty(target: BSTR; property: INT; value: BSTR); stdcall;
  //method TGetProperty
  function TGetProperty(target: BSTR; property: INT): BSTR; stdcall;
  //method TCallFrame
  function TCallFrame(target: BSTR; FrameNum: INT); stdcall;
  //method TCallLabel
  function TCallLabel(target: BSTR; label: BSTR); stdcall;
  //method TSetPropertyNum
  function TSetPropertyNum(target: BSTR; property: INT; value: R8); stdcall;
  //method TGetPropertyNum
  function TGetPropertyNum(target: BSTR; property: INT): R8; stdcall;
  //method TGetPropertyAsNumber
  function TGetPropertyAsNumber(target: BSTR; property: INT): R8; stdcall;
  //property SWRemote
  property-get SWRemote: BSTR; stdcall;
  //property SWRemote
  property-put SWRemote(: BSTR); stdcall;
  //property FlashVars
  property-get FlashVars: BSTR; stdcall;
  //property FlashVars
  property-put FlashVars(: BSTR); stdcall;
  //property AllowScriptAccess
  property-get AllowScriptAccess: BSTR; stdcall;
  //property AllowScriptAccess
  property-put AllowScriptAccess(: BSTR); stdcall;
  //property MovieData
  property-get MovieData: BSTR; stdcall;
  //property MovieData
  property-put MovieData(: BSTR); stdcall;
  //property inline-data
  property-get InlineData: IUnknown; stdcall;
  //property inline-data
  property-put InlineData(: IUnknown); stdcall;
  //property SeamlessTabbing
  property-get SeamlessTabbing: Bool; stdcall;
  //property SeamlessTabbing
  property-put SeamlessTabbing(: Bool); stdcall;
  //method EnforceLocalSecurity
  function EnforceLocalSecurity; stdcall;
  //property Profile
  property-get Profile: Bool; stdcall;
  //property Profile
  property-put Profile(: Bool); stdcall;
  //property ProfileAddress
  property-get ProfileAddress: BSTR; stdcall;
  //property ProfileAddress
  property-put ProfileAddress(: BSTR); stdcall;
  //property ProfilePort
  property-get ProfilePort: I4; stdcall;
  //property ProfilePort
  property-put ProfilePort(: I4); stdcall;
  //method Call
  function CallFunction(request: BSTR): BSTR; stdcall;
  //method SetReturnValue
  function SetReturnValue(returnValue: BSTR); stdcall;
  //method DisableLocalSecurity
  function DisableLocalSecurity; stdcall;
  //property AllowNetworking
  property-get AllowNetworking: BSTR; stdcall;
  //property AllowNetworking
  property-put AllowNetworking(: BSTR); stdcall;
  //property AllowFullScreen
  property-get AllowFullScreen: BSTR; stdcall;
  //property AllowFullScreen
  property-put AllowFullScreen(: BSTR); stdcall;

Interface ICanHandleException;
GUID = {C5598E60-B307-11D1-B27D-006008C3FBFB};
  function CanHandleException(pExcepInfo: ^EXCEPINFO; pvar: ^Variant): HResult; stdcall;

//Event interface for Shockwave Flash
Dispatch _IShockwaveFlashEvents;
GUID = {D27CDB6D-AE6D-11CF-96B8-444553540000};
  function OnReadyStateChange(out newState: I4); stdcall;
  function OnProgress(out percentDone: I4); stdcall;
  function FSCommand(command: BSTR; args: BSTR); stdcall;
  function FlashCall(request: BSTR); stdcall;

//Shockwave Flash
CoClass ShockwaveFlash;
GUID = {D27CDB6E-AE6D-11CF-96B8-444553540000};

//IFlashFactory Interface
Interface IFlashFactory;
GUID = {D27CDB70-AE6D-11CF-96B8-444553540000};

//IFlashObjectInterface Interface
Interface IFlashObjectInterface;
GUID = {D27CDB72-AE6D-11CF-96B8-444553540000};

Interface IDispatchEx;
GUID = {A6EF9860-C720-11D0-9337-00A0C90DCAA9};
  function GetDispID(bstrName: BSTR; grfdex: UI4; out pid: ^I4): HResult; stdcall;
  function RemoteInvokeEx(id: I4; lcid: UI4; dwFlags: UI4; pdp: ^DISPPARAMS; out pvarRes: ^Variant; out pei: ^EXCEPINFO; pspCaller: ^IServiceProvider; cvarRefArg: UINT; rgiRefArg: ^UINT; out rgvarRefArg: ^Variant): HResult; stdcall;
  function DeleteMemberByName(bstrName: BSTR; grfdex: UI4): HResult; stdcall;
  function DeleteMemberByDispID(id: I4): HResult; stdcall;
  function GetMemberProperties(id: I4; grfdexFetch: UI4; out pgrfdex: ^UI4): HResult; stdcall;
  function GetMemberName(id: I4; out pbstrName: ^BSTR): HResult; stdcall;
  function GetNextDispID(grfdex: UI4; id: I4; out pid: ^I4): HResult; stdcall;
  function GetNameSpaceParent(out ppunk: ^IUnknown): HResult; stdcall;

Interface IServiceProvider;
GUID = {6D5140C1-7436-11CE-8034-00AA006009FA};
  function RemoteQueryService(guidService: ^GUID; riid: ^GUID; out ppvObject: ^IUnknown): HResult; stdcall;

//IFlashObjectInterface Interface
CoClass FlashObjectInterface;
GUID = {D27CDB71-AE6D-11CF-96B8-444553540000};

//IFlashObject Interface
Dispatch IFlashObject;
GUID = {86230738-D762-4C50-A2DE-A753E5B1686F};
  function QueryInterface(riid: ^GUID; out ppvObj: ^^VOID); stdcall;
  function AddRef: UI4; stdcall;
  function Release: UI4; stdcall;
  function GetTypeInfoCount(out pctinfo: ^UINT); stdcall;
  function GetTypeInfo(itinfo: UINT; lcid: UI4; out pptinfo: ^^VOID); stdcall;
  function GetIDsOfNames(riid: ^GUID; rgszNames: ^^I1; cNames: UINT; lcid: UI4; out rgdispid: ^I4); stdcall;
  function Invoke(dispidMember: I4; riid: ^GUID; lcid: UI4; wFlags: UI2; pdispparams: ^DISPPARAMS; out pvarResult: ^Variant; out pexcepinfo: ^EXCEPINFO; out puArgErr: ^UINT); stdcall;
  function GetDispID(bstrName: BSTR; grfdex: UI4; out pid: ^I4); stdcall;
  function RemoteInvokeEx(id: I4; lcid: UI4; dwFlags: UI4; pdp: ^DISPPARAMS; out pvarRes: ^Variant; out pei: ^EXCEPINFO; pspCaller: ^IServiceProvider; cvarRefArg: UINT; rgiRefArg: ^UINT; out rgvarRefArg: ^Variant); stdcall;
  function DeleteMemberByName(bstrName: BSTR; grfdex: UI4); stdcall;
  function DeleteMemberByDispID(id: I4); stdcall;
  function GetMemberProperties(id: I4; grfdexFetch: UI4; out pgrfdex: ^UI4); stdcall;
  function GetMemberName(id: I4; out pbstrName: ^BSTR); stdcall;
  function GetNextDispID(grfdex: UI4; id: I4; out pid: ^I4); stdcall;
  function GetNameSpaceParent(out ppunk: ^IUnknown); stdcall;

//FlashObject Class
CoClass FlashObject;
GUID = {E0920E11-6B65-4D5D-9C58-B1FC5C07DC43};
 

HukpoFuJl

AццkuЙ HukpoFuJl
Сообщения
98
Репутация
38
Тема вроде обобщенная, хоть и старая, поэтому спрошу тут...

Предыстория: У меня по кнопке меняется (обновляется) флэшролик игры вк... При этом мне приходится обнулять переменную с объектом, удалять контрол и пересоздавать и то и то, но при этом сам флэш из памяти не выгружается... таким образом, перезапустив вконтактовскую игру (которая жрет 300мб оперативы) 5 раз, я получаю 1,5гб сжираемой оперативы просто так...

Вопрос: Как корректно выгрузить флэш, что бы он не жрал ресурсы!?

PS: В принципе подходящей альтернативой будет даже перезагрузка(обновление) флеша. Что-нить типо $oFlash.ReLoad()
 
Верх