Code: Select all
;Coded by Ricardo
;Change the jpg file names by some that you have in the same folder, must be something small
Function CreateSwf(Texto)
Dim mv, obj, txt, font
Dim btn, act, txt1(100), font1(100)
Dim Fname
Fname = "sample.swf" ' The file that will be created
Set Movie = CreateObject("swfobjs.swfMovie")
Set obj = CreateObject("swfobjs.swfObject")
Set obj1 = CreateObject("swfobjs.swfObject")
Set btn = CreateObject("swfobjs.swfObject")
Set act = CreateObject("swfobjs.swfAction")
' Set moive attribute
With Movie
.SetSize 6000 * 1.3, 4000 * 1.3
.SetFrameBkColor 255, 255, 255
.SetFrameRate 20
End With
'Need to find a way that the outfile has the desire size
'Flash1.Width = 6000 * 1.3
'Flash1.Height = 4000 * 1.3
Set pic = CreateObject("swfobjs.swfObject")
pic.MakePicture 300, 300, 650, 650, 450, 450, "any.JPG"
'top, left, width,height (in twips inside the swf), the 2 last in pixels
'Los 2 primeros son top y left, los 2 siguientes son widht y height en twips dentro del swf y los 2 ultimos en pixeles el rectangulo que tomara del bmp o jpg
Movie.AddObject pic ' Add picture
'Making the blocks
With obj
.MakePolygon 500, 500
.AddStraightLine 0, 3000
.AddStraightLine 3000, 0
.AddStraightLine 0, -3000
.AddStraightLine -3000, 0
.SetSolidFill 128, 0, 128, 70
End With
obj.SetDepth 1
Movie.AddObject obj
With obj1
.MakePolygon 3000, 500
.AddStraightLine 0, 2500
.AddStraightLine 2500, 0
.AddStraightLine 0, -2500
.AddStraightLine -2500, 0
.SetSolidFill 18, 250, 18, 20
End With
Movie.AddObject obj1
For i = 0 To 320
Movie.GotoFrame i
Movie.RemoveObject pic
Movie.RemoveObject obj
'Here we make the image falling down, a very nice effect it fall very far away!!!
pic.Translate i * 20, i * 20
pic.scaleEx (65536 * 10) / (i + 1), (65536 * 10) / (i + 1)
pic.Rotate 65536 * (i * 10)
obj.Rotate -65536 * (i * 1)
Movie.AddObject pic
Movie.AddObject obj
Next
For i = 0 To 320
Movie.GotoFrame i
Movie.RemoveObject obj1
obj1.Rotate 65536 * (i * 1)
Movie.AddObject obj1
Next
Set font = CreateObject("swfobjs.swfObject")
With font
.MakeFont "Arial"
.AddGlyph "Arial", "Flash", Asc("Hp")
.AddGlyph "Arial", " Example", Asc("i")
.AddGlyph "Arial", "http://www.purebasic.com", Asc("A")
End With
Set txt = CreateObject("swfobjs.swfObject")
With txt
.MakeTextEx "Hpi", font, 1270, 870, 1000
.SetSolidFill 128, 128, 128, 100
End With
Movie.GotoFrame 0
Movie.AddObject txt
With txt
.MakeTextEx "Hpi", font, 1200, 800, 1000
.SetSolidFill 0, 0, 255, 255
End With
Movie.GotoFrame 0
Movie.AddObject txt
For i = 0 To 100
'On Error Resume Next
Movie.GotoFrame i
Movie.RemoveObject txt
If i * 5 < 255 Then
txt.SetSolidFill 0, 0, 255, 255 - (i * 5)
End If
Movie.AddObject txt
Next
'////////////////////////////////////
'---VAMOS A INTENTAR ANIMAR TEXTO
'We will try to animate some text!!!!!!!!!
Dim Cuantas
Dim Contador
Dim Letra
Dim Donde
Dim Transparencia
Dim LastLetra
Dim Espacio
Dim LetterSize
Dim FactorEscala
LetterSize = 300
Dim MYTEXT
MYTEXT = Texto
Cuantas = Len(MYTEXT)
For i = 1 To Cuantas
Set font1(i) = CreateObject("swfobjs.swfObject")
With font1(i)
.MakeFont "Arial"
End With
Set txt1(i) = CreateObject("swfobjs.swfObject")
Letra = Mid(MYTEXT, i, 1) 'Pick one letter at time
font1(i).AddGlyph "Arial", Letra, Asc(Letra) 'Add letter to the object
With txt1(i)
'Trying to mantain similar distance betwen different letters.. not all use the same space
If LastLetra = "l" Or LastLetra = "i" Or LastLetra = "j" Then
Espacio = Espacio + (LetterSize * 0.21)
ElseIf LastLetra = "f" Or LastLetra = "r" Then
'estas letras tienen menos espaciado
Espacio = Espacio + (LetterSize * 0.3)
ElseIf LastLetra = "t" Then
Espacio = Espacio + (LetterSize * 0.25)
ElseIf LastLetra = "s" Then
Espacio = Espacio + (LetterSize * 0.45)
ElseIf LastLetra = "o" Or LastLetra = "p" Or LastLetra = "q" Or LastLetra = "n" Then
Espacio = Espacio + (LetterSize * 0.5)
ElseIf LastLetra = "w" Then
Espacio = Espacio + (LetterSize * 0.65)
ElseIf LastLetra = "m" Then
Espacio = Espacio + (LetterSize * 0.75)
Else
'espaciado Normal
'Normal space
Espacio = Espacio + (LetterSize * 0.49)
End If
LastLetra = Letra
.MakeTextEx Letra, font1(i), Espacio, 2500, LetterSize
.SetSolidFill 255, 128, 128, 1
End With
Movie.GotoFrame Donde
Movie.AddObject txt1(i)
Transparencia = 1
FactorEscala = 155 '75 '155'310
'ADD THE TEXT TO THE FRAME WITH FX
'Wowwwwwwww here we go !!!!!!!!
For ii = Donde + 1 To Donde + 30
Transparencia = Transparencia + 7
Movie.GotoFrame ii
Movie.RemoveObject txt1(i)
txt1(i).scaleEx (65535 * 10) / FactorEscala + 1, (65535 * 10) / FactorEscala + 1
FactorEscala = FactorEscala - 10
txt1(i).SetSolidFill Transparencia, 0, Transparencia, Transparencia
txt1(i).Rotate -65536 * (ii * 50)
Movie.AddObject txt1(i)
Next
Movie.RemoveObject txt1(i)
txt1(i).scaleEx (LetterSize * 35.565) * 2, (LetterSize * 35.565) * 2
txt1(i).Rotate 0
Movie.AddObject txt1(i)
Donde = ii - 20
Next
'---FIN ANIMACION DE TEXTO
' END OF TEXT ANIMATION... WE DONE IT !!!! HURRA !!!
'//////////////////////////////////////////////////////////////// CREA LA PELICULA
'CREATE THE SWF
Movie.WriteMovie Fname
Set Movie = Nothing
Set obj = Nothing
Set txt = Nothing
Set font = Nothing
Set btn = Nothing
Set act = Nothing
CreateSwf = 1
msgbox "Done!"
End Function
CreateSwf("Flash from PureBasic")