Add flash in winform

Source: Internet
Author: User
Tags file url rewind

I will not discuss how to add the Flash control here. I can find a lot
When VS2005 added Shockwave, many people encountered this problem, that is, ActiveX registration failed.
If this problem is not encountered, you can skip this step. Some people say that you can add a Windows Media Player control first, but I have not succeeded.
The solution on the Internet is not uniform.
After some efforts, I found a solution on an E-text jar.
First, use Regsvr32 to register ActiveX (run: Regsvr32 Control name)-u as the uninstall Parameter
For example, Regsvr32 C: \ WINDOWS \ system32 \ Macromed \ Flash \ Flash9f. ocx

You can also download ActiveX Manager for registration, which is much more convenient.

Problems often occur after successful registration.

It seems to be the reason for the CPU, because it is E-text, and the Level 4 has not passed yet. As for the reason, I have not understood it.
Under VS2005, change project-properties-generate-target platform to x86
Choose generate-clear solution and regenerate solution until the yellow exclamation point of AxShochwaveFlashObj under resource manager reference disappears

 

 

 

AxShockwaveFlashObjects exclamation point disappears

 

 

 

After it disappears, you can add the Flash control to the form.

The following describes some important attributes and methods of the Flash control (derived from the secret of the previous Flash control on the Internet (VB ))

Attribute:

1. AlignMode (read/write)
Syntax: AlignMode As Long
Note: Alignment mode (associated with the SAlign attribute ). When the length/width ratio of the control is different from that of the video and the WMode is not ExactFit
This attribute can be used to adjust the position displayed in the control. This attribute value is composed of flag spaces ., When the bits corresponding to the attribute value (Binary) are marked as 1, the corresponding alignment direction is set.
Alignment between the property value and the corresponding value (the binary value is in the brackets)
1: Left alignment (0001) 2: Right alignment (0010) 4: Top alignment
(0100) 8: Bottom alignment (1000)
You can also combine various alignment modes and Mark Two or more bits as 1, that is, add these four basic values. For example, if both the left alignment and the top alignment are performed, the attribute value is set to 5 (0101 ).
Example: set the right alignment of a video:
Movie. AlignMode = 2
2. BackgroundColor (read/write) Syntax: BackgroundColor As Long description: the background color of the video (associated with BGColor ). To
X 65536 + green x 256 + blue) Calculate the color value. The value range is 0-255 ). The default video background color is-1. If you set the background color or image as the background, you cannot see the effect of the attribute value change.
Example: Set the background color of a video to Blue:
Movie. BackgroundColor = 255
3. Base (read/write)
Syntax: Base As String
Description: Specifies the base address used to resolve all relative paths in the video. This attribute is particularly useful when a video is not in the same directory as other files you need. If this parameter is not specified, the Base Value defaults to ".", which is the path of the current video.
Example:
Movie. Base = "Http: // www.domain.com/pathname1/
Pathname2"
4. BGColor (read/write)
Syntax: BGColor As String
Description: the background color of the video (associated with BackgroundColor ). Unlike BackgroundColor, BGColor is a six-digit hexadecimal number. Each two represents a red, green, and blue color respectively. For example, FFEEAA indicates that the red value is FF, the green value is EE, and the blue value is AA.
Example: Set the background color of a video to Red:
Movie. BGColor = "FF0000"
5. DeviceFont (read/write)
Syntax: DeviceFont As Boolean
Determines whether to use the embedded font of the video. The default value is False. If this attribute value is set to True, the player is forced to use the local system font instead of the embedded font in the video.
Example: movie. DeviceFont = True
6. EmbedMovie (read/write)
Syntax: EmbedMovie As Boolean
Determines whether a video is stored in the container where the control is located. When you have loaded a video and set this attribute to True, you do not have to read the SWF file when playing the video. This makes it easier to use Flash videos in PowerPoint presentations or VB Programs. However, if this attribute is set to True, the Controller's Movie attribute will no longer accept new values. To play another video clip (assign a new value to the Movie attribute), set the attributes of EmbedMovie to False.
Example:
Movie. EmbedMovie = True
7. FrameNum (read/write)
Syntax: FrameNum As Long
Description: Number of the current video frame (counted from 0 ). Setting this attribute value will stop the video at the frame specified by FrameNum.
Example: display the current number of frames:
MsgBox "the current display is" & movie. FrameNum &
"Frame. "
Make the video display 10th frames: Bomovie. FrameNum = 9
8. Loop (read/write)
Syntax: Loop As Boolean
Indicates whether loop playback is enabled. If it is set to True, it indicates loop playback. If it is set to False, playback is performed only once.
Example:
Movie. Loop = True
9. Menu (read/write)
Syntax: Menu As Boolean
Indicates whether to display menus. If it is set to True, all menus are displayed. If it is set to False, the menu is blocked, but there is still an item "About Macromedia Flash Player ...". If you really don't like this menu, you should intercept the mouse message in the Process Order. Unlike the independent F l a s h player, click
"About..." will open the browser and go to Macromedia's website to see About.

Example:
Movie. Menu = False
10. Movie (read/write)
Syntax: Movie As String
Description: The Path of the video to be played (URL ). Setting this property as a SWF File URL will load the file and play it back. If the video is on a local hard disk, it must be written as the absolute path starting from the drive letter; if the video is on a website, it must also be written with a full URL address.
Example:
Movie. Movie = "http://www.domain.com/path1/
Path2/filename.swf "or
Movie. Movie = "C: \ temp \ test.swf"
11. Playing (read-only)
Syntax: playing as Boolean
Note: The current playback status. If the video is being played, the value of this attribute is true; otherwise, the value is false.
Example:
If movie. Playing = false then msgbox "the video has been stopped! "End if
12. Quality (read/write)
Syntax: quality as long
Note: Image Quality (associated with quality2 ). Quality can be taken as follows:
0 -- equivalent to taking "low" for quality2"
1 -- equivalent to "high" for quality2"
2 -- equivalent to quality2 to "autolow"
3 -- equivalent to taking "autohigh" for quality2:
Movie. Quality = 1
13. quality2 (read/write)
Syntax: quality as string
Note: Image Quality (associated with quality ). Quality2 can take: low: focuses on playback speed, regardless of the display effect, and is not enabled
This function can be used to remove teeth.
High: focuses on the screen, regardless of the playback speed, and always enables the anti-aliasing function. If an animation is not included in a video, the bitmap is processed smoothly. If an animation exists, the bitmap is not processed smoothly. (The animation here should be to translate or rotate an image)
Autolow: focuses on playback speed first, but improves the display performance as long as possible. The anti-aliasing function is disabled at the beginning of playback. If the player detects that the processor is able to withstand this problem, the anti-aliasing function is enabled.
Autohigh: At the beginning, the playback speed and display effect are both equal, but the image quality is sacrificed to ensure the speed if necessary. Enable the anti-aliasing function when playing the video. However, if the actual frame rate is slower than the specified frame rate at the design time, the playback speed will be improved by disabling the anti-aliasing function.
Example:
Movie. quality2 = "high"
14. readystate (read-only)
Syntax: readystate as long
Note: The Current Status of the video. Readystate can be set:
0 -- Loading
1 -- not initialized
2 -- loaded
3 -- interacting
4 -- Example of completion:
If movie. readystate = 4 then
Msgbox "the video has been loaded! "End if
15. salign (read/write)
Syntax: salign as string
Description: alignmode (associated with alignmode ). When alignmode
The salign value is also set
The combination of "L" (left), "T" (top), "R" (right), and "B" (bottom) characters. (The sequence of 'l', 't', 'R', and 'B' remains unchanged)
Example: Set the left and top alignment of a video:
Movie. salign = "LT"
16. Scale (read/write)
Syntax: scale as string
Description: Scaling mode (associated with scalemode ). Scale:
Showall -- display all the film regions in the control, and keep the film length and width ratio unchanged. The size of the film is determined by the side of the control length or width smaller.
Noborder-display part of the video area in the control to keep the length and width ratio unchanged. The size of the video is determined by the side of the control length or width.
Exactfit -- display all video regions in the control, and force the length-width ratio of the video to the length-width ratio of the control.

Example:
Msgbox "Current scaling mode is:" & movie. Scale
17. scalemode (read/write)
Syntax: scalemode as long
Description: Scaling mode (associated with scale ). Scalemode:
0 -- equivalent to scale to get "showall"
1 -- equivalent to scale to get "noborder"
2 -- equivalent to "exactfit" for Scale"
Example: Change the zoom mode of a video to "exactfit ":
Movie. scalemode = 2
18. Stacking (read/write)
Syntax: Stacking As String
Note: For HTML, when Flash Player is used as an "action" in HTML, this attribute determines how the Flash video is displayed relative to the HTML content referenced by it. (For more information about "behavior", see the style sheet ). Stacking can be used to obtain:
None -- "action" is not displayed.
Replaceall -- the display of "behavior" replaces the content of all other elements, including the background.
Content -- the display of "behavior" only replaces the content of other elements.
Background -- the display of "behavior" only replaces the background of other elements.
Below -- "action" is displayed below all other elements.
Belowflow -- "behavior" is displayed on the sub-objects of other elements in reverse Z order, but on the main content of the element.
Aboveflow -- "behavior" is displayed under the sub-objects of other elements in the forward Z sequence, but above the main content of the element.
Above -- "behavior" is displayed on the content of all other elements.
Top -- display of "behavior" is placed above the content of the entire page. Example:
Movie. Stacking = "below"
19. TotalFrames (read-only)
Syntax: TotalFrames As Long
Returns the total number of frames in a video. This parameter is valid only after the video is loaded (ReadyState = 4 ).
Example:
If movie. ReadyState = 4 Then
MsgBox "this video has a total of" & movie. TotalFrames & "frames. "
End If
20. WMode (read/write)
Syntax: WMode As String
Note: The control window mode. WMode can be set to the default value of Window -- WMode attribute. Press
A typical way to work is to play a video in the control's rectangular window, which can provide the fastest animation effect.
Opaque -- make the video opacity. Transparent -- create a Transparent video. If the video contains
Transparent fragment. When put here, you can see the background under the control. However, when this attribute value is used, the playback speed of the animation may be slower.
Example:
Movie. WMode = "Transparent"

Method:

1. Back
Syntax: Back ()
Note: The video is moved back and stops playing. Example:
Movie. Back
2. Forward
Syntax: Forward ()
Note: The video goes forward and stops playing. Example:
Movie. Forward
3. GotoFrame
Syntax: GotoFrame (FrameNum As Long) Description: redirects a video to a frame specified by FrameNum, and
Stop playing. If the specified frame has not been loaded, the player moves forward to the final available frame and stops. unexpected consequences may occur during the call process. It is best to use the PercentLoaded method to determine whether sufficient films have been loaded to execute this method. The parameter FrameNum starts from 0, which is different from the Goto action in Flash. It starts from 1.
Example: Jump to the 20th frame of a video:
Movie. GotoFrame 20
4. LoadMovie
Syntax: LoadMovie (layer As Long, url As String) Description: loads a video specified by the url to a layer specified by the layer. Example: Load movie.swf to layer 0:
Movie. LoadMovie 0, "movie.swf"
5. Pan
Syntax: Pan (x As Long, y As Long, mode As Long) Description: translate an enlarged film by the distance specified by x and y.
Both x and y are relative values. That is, the distance between the control and the video (you can imagine that the control is a window, and the video is a set that we see from the window outside, we can see that the windows have some translation distance from the set. That is, the outside set is moving, while the windows are not moving ). Use the mode parameter to specify whether the values of x and y are pixels or the percentage of windows. When mode = 0, the coordinate system is in pixels; when mode = 1, the coordinate system is calculated based on the percentage of the window. The pan operation cannot exceed the frame of the video. That is to say, the pan operation in one direction can reach the maximum degree of alignment between the edge of the video and the control.
Example: The control translates 5 pixels from the left to the right of the video (when the control does not move, the video is translated to the right ):
Movie. Pan 5, 5, 0
6. Play
Syntax: Play ()
Starts to play a video. Example:
Movie. Play
7. Rewind
Syntax: Rewind ()
Note: rewind. Returns the first frame of the video. Example:
Movie. Rewind
8. SetVariable
Syntax: SetVariable (name As String, value As String) Description: sets the Flash variable value specified by name to value. Example: movie. SetVariable "/Form: UserName", "John Smith"

9. SetZoomRect
Syntax: SetZoomRect (left As Long, top As Long, right
As Long, bottom As Long)
Note: enlarge the rectangle area specified in the video to the control size. The coordinate values of left, top, right, and bottom are calculated for the effective position of the video in the control. Note that this function is calculated from the upper left corner of the effective area of the video, rather than the upper left corner of the control.
Example: enlarge the Moment Area of the video starting from the upper left corner of the video at 200 × 200:
PointsToTwips = 20;
Movie. SetZoomRect 0, 0,200 * pointsToTwips, 200
* PointsToTwips
10. Stop
Syntax: Stop ()
Stops playing a video. Example: movie. Stop
11. StopPlay
Syntax: StopPlay ()
Stops playing a video. Example: movie. stopplay
12. tcallframe
Syntax: tcallframe (target as string, framenum
As long)
Note: In the timeline specified by t a r g e t, the action in the frame specified by framenum is executed.
Example: To run the 5th-frame action in the main timeline:
Movie. tcallframe "/", 4
13. tcalllabel
Syntax: tcalllabel (target as string, label as string) Description: In the timeline specified by target
The action in the specified frame. Example: To Run "handlescriptpolicy" in the main timeline"
Action in the frame:
Movie. tcalllabel "/", "handlescriptpolicy"
14. tgotoframe
Syntax: tgotoframe (target as string, framenum
As long)
NOTE: For the timeline specified by t a r g e t, it is transferred to the frame specified by framenum.
Example:
Movie. tgotoframe "/movieclip", 2
15. tgotolabel
Syntax: tgotolabel (target as string, label as string) Description: For the timeline specified by the target
Fixed Frame.
Example: movie. tgotolabel "/movieclip", "mylabel"
16. tplay
Syntax: tplay (target as string) Description: Specifies the timeline of the target. Example: movie. tplay "/movieclip"
17. tsetproperty
Syntax: tsetproperty (target as string, property
Long, value as string)
NOTE: For the timeline specified by target, set the attribute specified by property to the value (string ). Property is a number representing the corresponding property (see the appendix for details ).
Example:
Dim nameindex as long
Nameindex = 13
Movie. tsetproperty "/movieclip", nameindex,
"Newname"
18. tsetpropertynum
Syntax: tsetpropertynum (target as string, property
As long, value as double)
NOTE: For the timeline specified by the target, set the attribute specified by the property to the value (number ). Property is a number representing the corresponding property (see the appendix for details ).
Example:

Dim visibilityindex as long visibilityindex = 7
Movie. TSetProperty "/MovieClip", visibilityIndex, 1
19. TStopPlay
Syntax: TStopPlay (target As String) Description: The timeline specified by target to stop playing. Example:
Movie. TStopPlay "/movi1_tostop"
20. Zoom
Syntax: Zoom (factor As Long) Description: scales the view by the relative percentage specified by factor. Factor
It can be understood as the percentage of the video displayed in the control window to the actual size. Set
If factor is set to 0, the view will be restored to the 100% size. The current view is already
It cannot be reduced in 100%.
Example: double the video size: movie. Zoom 50. The following methods return values:
21. CurrentFrame
Syntax: CurrentFrame () As Long description: returns the current number of frames of a video. The first frame of the video is 0. Example:
Dim frameNow As Integer frameNow = movie. currentFrame
22. FlashVersion
Syntax: FlashVersion () As Long
Note: The control version number is returned. The value consists of three bytes, namely the main version number, minor version number, and revision version number. For example, if I use the Flash Player controller, the returned value is 3 2 7 7 2 2, which is equivalent to hexadecimal
& H05002A, equivalent to 5.00.42.
Example: The following program displays the version number of the control you are using:
Dim vernum, majornum, minornum, revisionnum
As long vernum = movie. flashversion majornum = vernum \ 65536
Minornum = (vernum-majornum * 65536) \ 256
Revisionnum = vernum mod 256.
Msgbox "version number of your Flash Player control :"&
Majornum & "." & minornum & "." & revisionnum
23. getvariable
Syntax: getvariable (name as string) as string
Description: return the value of the flash variable specified by name. If the variable does not exist, null is returned.
Example:
Dim firstname, radiobuttonvalue as string firstname = movie. getvariable "firstname" radiobuttonvalue = movie. getvariable ("/form/
Radiobutton: Value ")
24. isplaying
Syntax: isplaying () as Boolean
Returns true if the video is being played. Example:
If movie. isplaying then
Msgbox "video playing! "End if
25. PercentLoaded
Syntax: PercentLoaded () As Long
Description: returns the percentage of films currently loaded. The value range is from 0 to 100.
Example:
Dim loaded As Boolean
If movie. PercentLoaded = 100 Then loaded = true
End If
26. TCurrentFrame
Syntax: TCurrentFrame (target As String) As Long description: returns the number of the current frame in the timeline specified by target. The returned frame number starts from 0, that is, the first frame of the video is 0
The second frame is 1, and so on. Example:
Dim currentFrame As Long
CurrentFrame = movie. TCurrentFrame ("/MovieClip ")
27. TCurrentLabel
Syntax: TCurrentLabel (target As String) As String
Returns the tag of the current frame in the timeline specified by the target. If there is no tag for the current frame, an empty string is returned.
Example:
Dim currentLabel As String
CurrentLabel = movie. TCurrentLabel ("/MovieClip ")
28. TGetProperty
Syntax: TGetProperty (target As String, property
As long) as string
NOTE: For the timeline specified by the target, the attribute value (string) specified by the property is returned ). Here, property is a number representing the corresponding property (see the appendix for details ).
Example:
Dim nameindex as long dim name as string nameindex = 13
Name = movie. tgetproperty ("/", nameindex)
29. tgetpropertynum
Syntax: tgetpropertynum (target as string, property
As long) as double
NOTE: For the timeline specified by the target, the attribute value (number) specified by the property is returned ). Here, property is a number representing the corresponding nature (see the appendix for details ).
Example:
Dim framesloadedindex as long dim framesloaded as double framesloadedindex = 12
Framesloaded = movie. tgetproperty ("/", framesloadedindex)
Appendix: Obtain and set attributes. The numbers of each attribute can be used in tgetproperty, tgetpropertyasnumber, tsetproperty, or tsetpropertynum to indicate the attribute to be accessed.

Event:

1. fscommand
Syntax: fscommand (command as string, argS
String)
Note: The FSCommand Action added to the video in Flash can be used to pass information from the video to the Flash Player, when a video is played by a Flash player or a webpage or program that contains a player control, the corresponding action is performed based on the obtained information to enable interoperation between the video and external applications. For example, in F l a s h, add the following Action to a button image:
On (release ){
Fscommand ("fullscreen", "true ");
}
When the Flash player plays this file, click the button to switch to full screen mode. The following are the commands and their parameters that Flash players can recognize:
Command: quit
Parameter: No Parameter
Purpose: Disable the player command: fullscreen parameter: true or false
Purpose: Set true to enable the player to play in full screen mode. Set false to enable the player to play back in normal window mode.

Command: allowscale
Parameter: true or false
Purpose: if it is set to false, the video will not change with the player size, and the original size will always be maintained, equivalent to 100% in the player menu; if it is set to true, the size of the video that changes with the player size is restored, which is equivalent to Show All in the player menu.

Command: showmenu
Parameter: true or false
Purpose: Set true to display all menus, including the Right-click menu of the menu bar and the playback area. Set false to not display the menu bar, there is only one "About Macromedia Flash Player... ".

Command: exec
Parameter: the path and name of the application. It is used to execute a specified application. For example, in a flash video
The Add action is as follows:
Fscommand ("EXEC", "Regedit ");
When the player plays a video, the Registry Editor is enabled. Note: The player that comes with flash will execute the corresponding action after receiving these command, but there will be no response in the control, only the command and ARGs received by the program in the fscommand event can be analyzed and programmed for corresponding processing.
2. onprogress
Syntax: Event onprogress (percentdone as long) Description: occurs when a Flash video is downloaded. Percentdone is a shadow
The percentage of downloaded parts. The value ranges from 0 to 100.
Example: display the download progress in the title bar of the form:
Private sub movie_onprogress (byval percentdone
As long)
Form1.caption = "downloaded:" & percentdone
& "%"
End sub
3. onreadystatechange
Syntax: Event onreadystatechange (newstate
Long)
Note: This happens when the preparation status of the control changes. Listed below
Possible newstate values:
0 -- Loading
1 -- not initialized
2 -- loaded
3 -- interacting
4 -- complete
Example: after the video is loaded, a prompt is displayed, and then the video is played:
Private Sub movie_OnReadyStateChange (newState
Long)
If newState = 4 Then
MsgBox "the video has been loaded! "& VbCrLf &" Total number of video frames: "& movie. TotalFrames
Movie. Play
End If
End Sub

Some examples are based on VB, but you can still understand them. It won't be enough if you don't write flash players.
Only one Movie attribute and the Play () method can be used to put flash in the From file.
Article Source: http://www.diybl.com/course/4_webprogram/asp.net/netjs/2008530/118068.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.