How to use the button to open the video locally in Flash

Source: Internet
Author: User
Tags command line variables versions
Button

Many people have asked this question (of course, there is also a part of the members of the Flash bar), so I intend to write a tutorial, hoping to solve problems for everyone. Everyone's question is probably: in the local, how to click a button in Flash, with a video player to open a video (such as RM movie) Here are three programs: Flash, video player. Then, because Flash cannot directly pass the file name data to the player, So also need a middle of the program to communicate (the author used Vb wrote a).

Then we'll write the tutorial to you.
Working principle:
In MX or above, an application can be invoked through Fscommand, but due to security issues, the invoked application cannot be given command-line arguments for the Fscommand EXEC command, and for command line arguments, Maybe some people don't know very well. Here is a question for you to explain the command-line arguments.

In Flash3~5, we can open a file using the GreenMPC.exe program in the following ways A.RM
Fscommand ("exec", "GreenMPC.exe a.rm")
In which, a.rm become GreenMPC.exe command-line parameters, flash through the statement, first open the GreenMPC.exe, and then through the command line parameters to tell GREENMPC, to it open a.rm this file.
So, in 5, it's very convenient to do this.

It is now commonly used in 7 or more versions. Fscommand ("exec", "GreenMPC.exe a.rm") is invalid, only with Fscommand ("exec", "GreenMPC.exe"), which is not up to the goal, Because it can only open GreenMPC.exe, and cannot open a.rm with GreenMPC.exe.

So, there are two biggest problems at the moment:
1 to pass the a.rm out.
2 to let a.rm this parameter to GreemMPC.exe receive.

Flash puts variables in memory, at least for most flash designers, and is not available in other programs. So try to save the a.rm to the hard drive.
However, in the local, Flash6 and 7 version of the data can only be found in the Sharedobject, its save path is very complex (with the system, user name and other factors related), inadvertently will be wrong, so, local hard drive or not.

Then whether there is no way, "the mountains of water and doubt no way"?
Back to think of memory, will think of a very lively area: Clipboard, flash can send data to the Clipboard, this is "Vista"!

The first problem is solved. Here is the second question.
How do I get greenmpc to get information about the clipboard?
Flash is not capable of directly telling GREENMPC to get the Clipboard data directly as command-line arguments, so we are going through an intermediary.
The author used VB to write a program to get the Clipboard data, and the data in the form of command line parameters to GreenMPC.exe.

In this way, the problem is completely solved, the following is a concrete approach

Here's how it's done.

1 because it involves more than one file, the first step is to put the file in first.

1.1 Create a new directory, your future files are in this directory.

1.2 Create a new flash document in this directory.

1.3 because 6 or 7 of the version can only call the Fscommand directory of the program, so create a new folder Fscommand, put the player and video files in (note that in the player, the player related to the system files should be put in.

1.4 into the middle of the program, the file in the roof of the compressed package inside the Fscommand folder, called OpenMovie.exe.

The program is written by VB, the code is as follows (because this is the place to discuss flash, so do not give detailed explanations, readers are interested, you can refer to the books related to VB).

Private Sub Form_Load () ' child procedure, running when a program form is loaded
On error GoTo Openerr ' The program ends after a mistake occurred
Dim Filnam as String ' defines Filnam variables
If app.previnstance Then End to avoid confusion at run time, only one instance is allowed to run
Filnam = Clipboard.gettext ' stores the clipboard data in a variable named Filnam.
Clipboard.clear ' empty clipboard
Shell "GreenMPC.exe" & "" "& Filnam &" "" "" "" Run GreenMPC.exe and pass the filename to the player in the form of command-line arguments, allowing the player to open the Filnam.
Openerr:

End ' program ended

2 files are ready, edit the Flash document below

2.1 Create a new Component button, which is used to open the video,

2.2 To add code inside

On (release) {
System.setclipboard ("a.rm")//This sentence is used to upload the file name data to the Clipboard,
Fscommand ("exec", "openMovie.exe")//Clipboard After you get the data, you can open the OpenMovie.exe and let the program get the Clipboard data and transmit it to GreenMPC.exe
}

2.3 Now, the test film, you are now do not see any effect.

2.4 However, if you open Notepad now, "Paste", you will find that the paste is a.rm, visible, the Clipboard has been obtained from the flash data.

The failure to run after 2.5 is because Fscommand ("exec", args) can only be used in a standalone player (the view is not entirely correct and, if it is larger in scope), debugging is ineffective.

2.6 In a standalone player (please use 7 or more versions) to open the generated flash, or no response, why?
Because of security, SWF can not invoke EXE, need EXE to invoke EXE. Therefore, when flash playback, select "File"-"Create the player", save the EXE file to the current path. Then, run the exe file, click on the button, A.rm was GreenMPC.exe open .

2.7 If you block the menu, you must generate the EXE in Flash design mode
"File"-"Publish Settings", put "Windows show file (*.exe) on the hook, press" Publish ", you can.



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.