Thursday 10 September 2009

Flash Trainer Code Snippets for VB6 [Tutorial]

COLLAB
Requirements;
-Eyes (To Read).
-It will probably help if you have basic knowledge of VB6.
-A heart of Gold.
________________________________________________________________
1. How To Set Variables?
2. How Do i use a Textbox to Set a Variable Value?
3. How do i Set a Variable with User Definable Variable and Value?
4. How do i get the value of a Variable?
5. How do i use an Input Box to Set a Variable?
6. How do i make a Drop Down Menu?
7. How do i make a Sub Drop Down Menu?
8. How do i make a Message Box?
9. How do i Force Load?
10. How do i set a Custom Swf?
11. How do i load a Swf from a file where my trainer is?
12. How do i Clean one SWF layer?
13. How do i clear all SWF layers?
14. How do i save my project as an .EXE
15. How do i make another Form?
16. How do i put a password on a Program? (Stupid)
17. How do i Freeze a Variables Value using a CheckBox?
18. How do i unload multiple Forms when i quit Form 1?
19. How can i have different Buttons from the Defult ones?
20. Is there a different way to have Customized Buttons?
21. How can i freeze a Variable Value using a timer?
22. How do i make my Form a circle?
23. How do i make my form See Through? (Transparent)
24. How do i use Hot-Keys to Set a Variable or Enable a Timer?
25. How can i shorten certain Commands?

1. How do i set a Variable?
-Put a button or whatever.
-In the buttons coding put
Code:
Call ShockwaveFlash1.SetVariable("variable here",value)


2. How Do i put a use a Textbox to set a Variable Value?
-Make a Textbox.
-Make a button.
-Double click the button.
-Put this in your buttons code.
Code:
Call ShockwaveFlash1.SetVariable("variable here", Textbox1.Text)


3. How do i set a variable with user definable Variable and Value?
-make 2 textboxes.
-Make a button.
-Put this code in the button
Code:
Call ShockwaveFlash1.SetVariable(Text1.Text,Text2.Text)


4. How do i Get the value of a Variable? (Textbox)
-Make 2 Textboxs and a Button.
-Double click the button and put in its coding
Code:
On Error Resume Next
Text1.Text = ShockwaveFlash1.GetVariable(Text2.Text)

If you want it to show the value in a Label put
Code:
Label1.Caption = ShockwaveFlash1.GetVariable(Text2.Text)


5. How Do i use a Input Box to Set a Variable?
-Make a Button
-Double Click the Button
-Put in this code. (Using Money as a Example)
Code:
Dim Money As String
Money = InputBox("How Much Money You Want?", "Set Money")
Call Flash.SetVariable("_root.TotalMoney", Money)


This Would show up as this.

This defines money as a string. If you dont know what this means use the mthod below.
The simple way
-Double click a Button.
-Put this in the coding
Code:
Call ShockwaveFlash1.SetVariable("Variable Here", InputBox("Your Message", "InputBox Title")


6. How do i make a Drop Down Menu?
-Click CTRL + E.
-Type in Caption what you want the Tab to say.
-Type in the Name what you want the Tab to show up as in the code.

7. How do i make a Sub Drop Down Menu?
-Click CTRL + E.
-Click the down arrow in the interface. You should be below the origional Drop Down Menu caption.
-Click the Arrow going right.
-Type in the Caption and Name.
It should look like this when you click on the Main Tab.


8. How do i make a Message Box?
-Make a button.
-Double Click it.
-In the code put
Code:
MsgBox "Put Your Text Here"

This will look like.


9. How do i Force Load?
-Double Click a button or your form.
-in the code put
Code:
ShockwaveFlash1.Playing = True


10. How do i set a custom SWF?
-Make a Textbox.
-Make a Button.
In the Buttons coding put
Code:
ShockwaveFlash1.LoadMovie 1, Text1.Text


11. How do i load a SWF from inside a folder where my trainer is?
Code:
ShockwaveFlash1.LoadMovie 1, App.Path & "\SWF.swf"


12. How do i Clear one SWF layer?
Code:
ShockWaveFlash1.LoadMovie 1, ""


13. How do i Clear all SWF layers?
-Example up to 100 layers
Code:
Dim layeri As Integer
layeri = 1 'if you put 0 it will clear main swf'
Do Until layeri = 100 'loop to 100'
ShockWaveFlash1.LoadMovie layeri, ""
layeri = layeri + 1 'prepare for next loop'
Loop


14. How Do i Save My Project as a .EXE?
-Click FILE.
-Then click Make Project1.Exe


15. How do i make another form?
-Go to Project.
-Click New Form.

16. How do i put a Password on a program i made?
-Make 2 Forms.
-Make a Textbox and Button on Form1.
-Double click the button and put
Code:
If Text1.Text = password here Then
Form2.Visible = True
Form1.Hide
End If


17. How do i freeze a variable using a checkbox?
-Make a checkbox
-make a timer double click it and put
Code:
Call ShockwaveFlash1.SetVariable("variable",value)

-Set the timers interval to 1
-double click the checkbox and put
Code:
If Check1.Value=1 Then
Timer1.Enabled=True
End If
If Check1.Value=0 Then
Timer1.Enabled=False
End If



18. How do i unload multiple forms when i click exit on form1?
-Double click Form1.
-Change the funtion so it says
Code:
Private Sub Form_Unload()

-Put below it
Code:
Call Unload (Form2)
Unload Me


You can use this on any form. So it could go up to Unload Form13 and beyond.

19. How can i have a different button from the normal ones?
-Download this
http://uploaded.to/?id=brn858
-Go to VB6
-Click CRTL + D
-Select all the contents of the Styler Buttons folder.
-Click the icon thats now in your tool bar.

20. Is there a different way to have customized buttons?
-You can make your own.
-Go to Paint, Gimp, Photoshop etc.
-Make a button.
-Go to VB.
-Click the picture button.
-Put in your code.

21. How can i freeze a Variable Value using a timer?
- Make a timer.
- Put in Set variable (value and everything else)
-Set the timers interval to 5.
-Put the timer.Enabled to false.
-Make a button that has Timer1.Enabled=True in it.
-Done.

22. How do i make my form a Circle?
Code:
Declarations
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long


Inside the form
Private Sub Form_Load()
Dim lngRegion As Long
Dim lngReturn As Long
Dim lngFormWidth As Long
Dim lngFormHeight As Long

lngFormWidth = Me.Width / Screen.TwipsPerPixelX
lngFormHeight = Me.Height / Screen.TwipsPerPixelY
lngRegion = CreateEllipticRgn(0, 0, lngFormWidth, lngFormHeight)
lngReturn = SetWindowRgn(Me.hWnd, lngRegion, True)
End Sub



23. How do i make my form See-Through? (Transparent)
Code:
Declarations
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TRANSPARENT = &H20&
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWME = SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_NOTOPMOST = -2

Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Inside the form
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, SWP_SHOWME



24. How do i use Hot-Keys to Set a Variable or Enable a Timer?
Put this in your Declarations.
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Then put this in to set a variable
Code:
Private Sub GetAsyncKeyState(vbKeyT)
Call Shockwaveflash1.SetVariable("var", Value)
End Sub


For a timer put in the timers sub.
Code:
If GetAsyncKeyState(vbKeyT) Then
Timer1.Enabled = True
End Sub



25. How can i shorten certain Commands?
Say you had 5 lines of code saying.
Code:
Call ShockwaveFlash1.SetVariable("_root.gun.1", 1)
Call ShockwaveFlash1.SetVariable("_root.gun.2", 1)
Call ShockwaveFlash1.SetVariable("_root.gun.3", 1)
Call ShockwaveFlash1.SetVariable("_root.gun.4", 1)
Call ShockwaveFlash1.SetVariable("_root.gun.5", 1)



You could shorten this by doing this.
Code:
dim num as byte
num = 0
do until num = 5
Call ShockwaveFlash1.SetVariable("gun." & num, 1)
num = num + 1
loop


An alternative method,
Code:
for x = 0 to 5
Call ShockwaveFlash1.SetVariable("gun." & x, 1)
next x




Credits;
SnowFox- Alternative code.
MatthewThe2- For a couple of commands
Someone Else Who Ive Forgotten- Ditto
Epic Cat Garfield- For reminding me of shortening command code.
-And a snippet of his code.

0 comments:

Post a Comment