Embed a flash object in a single VFP exe.

Published on by Yousfi Benameur

This code produces an executable from any flash object swf.The swf is a kind of executable animation made as an activeX (old versions can embed on forms) .Its compiled from a fla editing code and its success is very great.
Flash is very used on the web because its protect all embed data( however ,there is some decompilers for flash objects).

these objects are various used as animations,codes interacts,games,....its place in the web is very important and Microsoft tried  to concurence this product by silverlight but  no success.
VFP dont a friend with flash.But flash is nowaydays always embed in a navigator as activeX object and its the wayt o play with it from VFP.
then flash works always with an (html file+swf) object who is embed and these 2 files must be in same folder.
This project have goal to embed a flash in single exe, but how ?
the solution is simple:
-convert flash swf file to a txt file.this is embed as resource in a project and can be manipulated inside the exe environment
   -I used strtofile(filetostr(...)) to extract the swf as txt file and embed it on a proj created programmatly.when running the single exethe txt file is restored as swf file in temp folder.
   -then i use 
create proj from.......and build exe  from proj...     to produce the independent exe (single, want to say works visually with no html , no swf)
   -this is not possible but the way is to
create the html file+swf file in temp folder and play in this folder.
   -clean any trace  when close application by destroying the 2 files.

-Safely swf flash file must be standlone and dont depend on other data as xml..otherwise must also embed the dependencies in project.
the exe can be moved anywhere on the disc.it works as single application without any external files needed.
This is a way to open the door of all swf products (animations,gadgets,utilities,....who populate more  80% of the web.


Even JS files with javascript (extension file .js) can be embed in proj/exe as txt files and restored in temp folder with html,swf...to make the aplication running correctly.Its the same way as above.

*to test this application download some swf (there is a lot for free on the web) and run


*!*This a demo with a  flash  swf file embed in a vfp browser
*!*see the help how to do with.
*!*Yousfi Benameur El BAYADH ALGERIA
*!* wednesday 20 february 2013
*!*the flash file (
rename any standalone swf to  color.swf)  must be mandatory in the source folder.

*Save this file as yflash.prg

Set Safe Off
Declare Integer Sleep In kernel32 Integer
Publi yrep
yrep =Addbs(Justpath(Sys(16)))
Set Defa To (yrep)

local m.oo


m.oo + "color.swf"]

Sleep(2500)  &&wait to create swf file safety

On Shutdown Quit
Publi yform,yrep

Read Events
Define Class asup As Form
    Height = 600
    Width = 800
    ShowWindow = 2
    AutoCenter = .T.
    BorderStyle = 3
    Caption = ""
    BackColor = Rgb(192,192,192)
    Name = "Form1"

    Add Object obrowser As OleControl With ;
        Anchor=15, ;
        Top =   0, ;
        Left = 0, ;
        Height = 600, ;
        Width = 800, ;
        Anchor = 15, ;
        Name = "oBrowser"

    Procedure Init
        Local myvar
        TEXT to m.myvar textmerge noshow
        <script type="text/javascript"><!--
        function yHelp() {

           var a = "1.this single exe embeds a flash object in its environment and can be restored on execution. \n";
           var b="2. the html and the swf  files are created in temp folder to run.\n";
           var c ="3.they are erased when the application exits. \n";
           var c1="4.In principe any valid swf can be integraded in the creted proj.  \n";
           var d="5.the proj is created programmatly from its resources in start folder. \n";
           var d1="   \n";
           var e="*Yousfi Benameur  \n";
           var f=" January 2013 \n"
        <body   bgcolor=black  oncontextmenu="return false;">
        <div align="center">
        <td><b><h2 style="color: #F51133; font-size: 14pt"> Flash object embed in Foxpro browser </h2></b></td>
        <td><input type="button" value="Help" style="
font-family: Verdana; font-size: 14px ;cursor:hand ;color: #F51133" onclick="yHelp();"></td>
        <object1 border="1" classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="<<thisform.oBrowser.height>>"  width="<<thisform.oBrowser.width>>"> <embed name="obj1" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="High" src="file:///<<yrep>>color.swf" type="application/x-shockwave-flash" height="<<thisform.oBrowser.height-80>>" width="<<thisform.oBrowser.width>>" > </object1>
        Local lcFilename



    Procedure Activate
            Set Bell To (Addbs(Getenv('windir')))+"MEDIA\notify.WAV" 
            ?? Chr(7)
    Procedure Destroy
&&clean traces
            Dele File Addbs(Sys(2023))+"color.swf"
            Dele File( Addbs(Sys(2023))+"ySWF.html")
        Set Safe On
        Clea Events


*build programmatly an exe from a prg (create project)-xave this file as ybuild_exe-flash.prg

*After building yflash.prg,buld this  prg and run it as main prg

*Begin code

Clea All
Close All
Set Safe Off

Set Defa To Addbs(Justpath(Sys(16,1)))

Local m.xswf
&&any single flash valid swf file
If Empty(m.xswf)
    Return .F

*build config.fpw
Local m.myvar
TEXT to m.myvar noshow
Strtofile(m.myvar, "config.fpw")

*build proj and compile to exe

Build Project yfoo  From  "yflash.prg" , "ycolor.txt",;
Build Exe yflash.Exe From yfoo

*clean traces
Dele File yfoo*.*
Set Safe On
If File("yflash.exe")
    Messagebox("yflash.exe created!",0+32+4096,"Create an exe",1000)

Dele File config.fpw
Dele File ycolor.txt

Set Safe On

Do yflash.Exe  &&execute the file created, can move it out anywhere on disc




Flash swf single files embed on vfp browser as executable applications.
Flash swf single files embed on vfp browser as executable applications.
Flash swf single files embed on vfp browser as executable applications.
Flash swf single files embed on vfp browser as executable applications.
Flash swf single files embed on vfp browser as executable applications.
Flash swf single files embed on vfp browser as executable applications.

Flash swf single files embed on vfp browser as executable applications.

Published on Visual foxpro, FLASH

To be informed of the latest articles, subscribe:
Comment on this post