Can I use Flash together with PureBasic?

Everything else that doesn't fall into one of the other PB categories.
User avatar
IceSoft
Addict
Addict
Posts: 1684
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Can I use Flash together with PureBasic?

Post by IceSoft »

Can I use Flash together with PureBasic?

Maybe as a Splash screen wich is using flash animation?
Any ideas, examples?

Thanks
IceSoft
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

afaik you can do it by using activeX elements!? just search on the forum, i remember someone posted something for this before!?
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

You could try using activex or a webgadget
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

A webgadget would definently be the easiest way, however this of course requires the user to have a flash enabled browser (tell me who dont have this these days)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

If you compile your flash presentation as a standalone exe you can use RunProgram(), that might be something to try. That way it won't even require the flash player to work. (I haven't tried it but I've seen it done with good results)
BERESHEIT
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

humm, i have an example on how to interact in purebasic with flash.
if my memory is good, it was a Fred snippet...
Last edited by Flype on Tue Mar 14, 2006 8:32 pm, edited 1 time in total.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

hehe, found it (translated to PB4 ) :

Code: Select all

;
; Embedded flash player example (ActiveX)
;
; By AlphaSND
;

; Flash ActiveX interface definition
;

Interface IShockwaveFlash Extends IDispatch
  get_ReadyState(a)
  get_TotalFrames(a)
  get_Playing(a)
  put_Playing(a)
  get_Quality(a)
  put_Quality(a)
  get_ScaleMode(a)
  put_ScaleMode(a)
  get_AlignMode(a)
  put_AlignMode(a)
  get_BackgroundColor(a)
  put_BackgroundColor(a)
  get_Loop(a)
  put_Loop(a)
  get_Movie(a)
  put_Movie(a)
  get_FrameNum(a)
  put_FrameNum(a)
  SetZoomRect(a,b,c,d)
  Zoom(a)
  Pan(a,b,c)
  Play()
  Stop()
  Back()
  Forward()
  Rewind()
  StopPlay()
  GotoFrame(a)
  CurrentFrame(a)
  IsPlaying(a)
  PercentLoaded(a)
  FrameLoaded(a,b)
  FlashVersion(a)
  get_WMode(a)
  put_WMode(a)
  get_SAlign(a)
  put_SAlign(a)
  get_Menu(a)
  put_Menu(a)
  get_Base(a)
  put_Base(a)
  get_scale(a)
  put_scale(a)
  get_DeviceFont(a)
  put_DeviceFont(a)
  get_EmbedMovie(a)
  put_EmbedMovie(a)
  get_BGColor(a)
  put_BGColor(a)
  get_Quality2(a)
  put_Quality2(a)
  LoadMovie(a,b.p-bstr)
  TGotoFrame(a,b)
  TGotoLabel(a,b)
  TCurrentFrame(a,b)
  TCurrentLabel(a,b)
  TPlay(a)
  TStopPlay(a)
  SetVariable(a,b.p-bstr)
  GetVariable(a,b.p-bstr)
  TSetProperty(a,b,c)
  TGetProperty(a,b,c)
  TCallFrame(a,b)
  TCallLabel(a,b)
  TSetPropertyNum(a,b,c)
  TGetPropertyNum(a,b,c)
  get_SWRemote(a)
  put_SWRemote(a)
  get_Stacking(a)
  put_Stacking(a)
EndInterface

Prototype AtlAxWinInit()
Prototype AtlAxCreateControl(a.p-bstr,b.l,c.l,d.l)
Prototype AtlAxGetControl(a.l,b.l)

If OpenLibrary(0,"atl.dll")
  AtlAxWinInit.AtlAxWinInit             = GetFunction(0, "AtlAxWinInit")
  AtlAxCreateControl.AtlAxCreateControl = GetFunction(0, "AtlAxCreateControl")
  AtlAxGetControl.AtlAxGetControl       = GetFunction(0, "AtlAxGetControl")
Else
  MessageRequester("Error", "OpenLibrary() failed.")
  End
EndIf

Movie$ = "c:\clock.swf"
Movie$ = "c:\\WINDOWS\\Help\\Tours\\mmTour\\segment1.swf"

CoInitialize_(0)

If OpenWindow(0, 100, 100, 300, 315, "")
  
  CreateGadgetList(WindowID(0)) 
  ContainerGadget(0, 0, 0, 300, 275) ; This will be our container window, where the ActiveX will be rendered
  CloseGadgetList()
  
  ButtonGadget(1, 10, 285, 70, 25, "Play", #PB_Button_Toggle)
  ;ButtonGadget(2, 90, 285, 70, 25, "Play")
  
  If AtlAxWinInit()
    
    AtlAxCreateControl("ShockwaveFlash.ShockwaveFlash", GadgetID(0), 0, @Container.IUnknown) ; It always create the IE control even if flash isn't found
    
    If Container
      
      AtlAxGetControl(GadgetID(0),@oFlash.IShockwaveFlash)
      
      If oFlash
        
        If oFlash\QueryInterface(?IID_ShockwaveFlash, @oFlash) = 0 ; Be sure it's a flash object in the IE container
          
          oFlash\LoadMovie(0, Movie$)
          oFlash\get_ReadyState(@State)   ; Seems to return 4 when the movie is ready to play, 3 else.
          
          Select State
            Case 4
              ;oFlash\Play()
              oFlash\FlashVersion(@Version)
              Debug "Flash Version: " + Hex(Version)
              oFlash\put_BackgroundColor($000000)
              oFlash\get_BackgroundColor(@BackColor)
              Debug "BackColor: " + Hex(BackColor)
            Default
              Debug State
              MessageRequester("Error", "The movie can't be loaded ("+Movie$+")")
          EndSelect
          oFlash\put_Quality(0)
          Repeat
            Select WaitWindowEvent(50)
              Case #PB_Event_CloseWindow
                Break
              Case #PB_Event_SizeWindow
                ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0), WindowHeight(0)-35)
                ResizeGadget(1, #PB_Ignore, WindowHeight(0)-30, #PB_Ignore, #PB_Ignore)
                ;ResizeGadget(2, #PB_Ignore, WindowHeight(0)-30, #PB_Ignore, #PB_Ignore)
              Case #PB_Event_Gadget
                Select EventGadget()
                  Case 1
                    Select GetGadgetState(1)
                      Case 0 : oFlash\Stop()
                      Case 1 : oFlash\Play()
                    EndSelect
                EndSelect
            EndSelect
            oFlash\CurrentFrame(@frame)
            SetWindowTitle(0, "Frame " + Str(frame))
          ForEver
          
          oFlash\Release()
          
        EndIf
        
        oFlash\Release()
        
      EndIf
      
    EndIf
    
  EndIf
  
  CloseWindow(0)   ; Don't forget this one, else the program will crash
  
EndIf

CoUninitialize_()

End

DataSection
  IID_ShockwaveFlash: Data.q $11CFAE6DD27CDB6C,$000054534544B896
EndDataSection
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
theNerd
Enthusiast
Enthusiast
Posts: 131
Joined: Sun Mar 20, 2005 11:43 pm

Post by theNerd »

Wow! This is great and something I used in VB. It can add a nice professional element to applications.
Post Reply