package no;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.io.*;
// import the JFlashPlayer package
import com.jpackages.jflashplayer.*;
import com.sun.jna.examples.WindowUtils;
/**
* Example code demonstrating JFlashPlayer
*
* Copyright (c) 2001-2009
* Company: VersaEdge Software, LLC
* Site: http://www.jpackages.com/jflashplayer
*/
public class Example extends JFrame implements FlashPanelListener {
// handle to a FlashPanel instance
FlashPanel flashPanel;
/**
* An example Java method that will be called from Flash ActionScript code
* using ExternalInterface.call. These methods must be public to be accessible from Flash.
*
* For this method to be callable from Flash, you must use the
* FlashPanel.setFlashCallObject method as is done below in the creatFlashPanel method.
*/
public String[] testFunction(String text, boolean b, double d, String[] array) {
// output some of the demo variables
System.out.println("Flash has called testFunction");
System.out.println(" received text: " + text);
System.out.println(" received boolean: " + b);
System.out.println(" received double: " + d);
for (int i=0; i < array.length; i++) {
System.out.println(" received array[" + i + "]: " + array[i]);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String message = "Flash has executed ExternalInterface.call on Java testFunction method.";
JOptionPane.showMessageDialog(null, message,
"ExternalInterface.call executed", JOptionPane.PLAIN_MESSAGE);
}
});
return new String[] { "aloha" }; // change aloha to stop to cause the Flash movie to stop on this method call
}
/**
* Called from Flash by ExternalInterface.call to indicate mouse over and out events on a Flash symbol.
*/
public void notifyFlashMouseEvent(String event) {
System.out.println("Flash mouse event: " + event);
}
/**
* This method is called from Flash to launch a web site.
*/
public void launchIE(String site) {
try {
System.out.println("launching IE to " + site);
Runtime.getRuntime().exec("explorer " + site);
} catch (Exception e) {
}
}
/**
* FlashPanelListener event method which receives FSCommand Flash events.
*
* You should use ExternalInterface.call instead of FSCommand
* with the latest ActionScript version. Older ActionScript versions
* will only have access to FSCommand.
*/
public void FSCommand(String command, String arg) {
System.out.println("FSCommand event received: " + command + " " + arg);
if (command.equals("javaLink")) {
launchIE(arg);
} else if (command.equals("javaExecute")) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null,
"Flash FSCommand events can be received by Java");
}
});
}
}
/**
* Create a FlashPanel instance and add it to the frame
*/
void createFlashPanel() {
// install Flash 10 if Flash 6 or greater is not present
FlashPanel.installFlash("6");
String flashVersionRequired = "9";
try {
// if there is Flash 9 or greater present, show Movie.swf
// otherwise show Movie-FSCommand.swf
String flashFilePath = "example/Movie.swf";
if (!FlashPanel.hasFlashVersion("9")) {
flashFilePath = "example/Movie-FSCommand.swf";
flashVersionRequired = "10";
}
FlashPanel.setRequiredFlashVersion(flashVersionRequired);
// construct a FlashPanel displaying the SWF flash animation file
flashPanel = new FlashPanel(new File(flashFilePath));
} catch (JFlashLibraryLoadFailedException e) {
exitError("A required library (DLL) is missing or damaged.");
} catch (FileNotFoundException e) {
exitError("Failed to find SWF file specified.");
} catch (JFlashInvalidFlashException e) {
exitError("Required version " + flashVersionRequired + " of Flash is not installed.");
}
// add the FlashPanel to the frame
this.getContentPane().add(flashPanel, BorderLayout.CENTER);
// specify the object for Flash ExternalInterface.call events to search for the called method on
flashPanel.setFlashCallObject(this);
// specify the FlashPanelListener in case a movie is using the older FSCommand event
flashPanel.addFlashPanelListener(this);
// specify variables for a flash movie which are available from the start of the
// movie as long as this is called before the FlashPanel is visible
flashPanel.setVariables("myGreeting=hi&myNumber=1&myVar=good%20job");
flashPanel.setBackground(null);//.setVisible(false);
}
/**
* Constructor of Example Frame
*/
public Example() {
System.setProperty("sun.java2d.noddraw", "true");
// define some frame information
this.setTitle("JFlashPlayer Example from JPackages.com");
this.setSize(600, 400);
this.getContentPane().setLayout(new BorderLayout());
this.setUndecorated(true);
createButtons();
createFlashPanel();
// exit the application when the frame closes
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// make the Example Frame visible
centerAndDisplay();
// launch a thread to monitor the current frame
//WindowUtils.setWindowAlpha(this,0.5f);
WindowUtils.setWindowTransparent(this,true);
FrameMonitorThread fmt = new FrameMonitorThread(flashPanel);
fmt.start();
}
/**
* Select a different SWF file and display it in the FlashPanel
*/
void setMovieAction() {
// filter to only allow SWF file choices
FileFilter swfFileFilter = new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory() || f.toString().endsWith(".swf"))
return true;
return false;
}
public String getDescription() {
return "SWF Files";
}
};
JFileChooser chooser = new JFileChooser("example");
chooser.addChoosableFileFilter(swfFileFilter);
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
try {
if (file.toString().endsWith(".swf")) {
// specify the new SWF file to be displayed in the already visible FlashPanel
flashPanel.setMovie(file);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
/**
* Instruct the flash movie to play.
*/
void playAction() {
flashPanel.play();
System.out.println("isPlaying=" + flashPanel.isPlaying());
}
/**
* Instruct the flash movie to stop playing.
*/
void stopAction() {
flashPanel.stop();
System.out.println("isPlaying=" + flashPanel.isPlaying());
}
/**
* Instruct the flash movie to go back one frame.
* This will also stop the movie if it was playing.
*/
void backAction() {
flashPanel.back();
System.out.println("currentFrame=" + flashPanel.getCurrentFrame());
}
/**
* Instruct the flash movie to go forward one frame.
* This will also stop the movie if it was playing.
*/
void forwardAction() {
flashPanel.forward();
System.out.println("currentFrame=" + flashPanel.getCurrentFrame());
}
/**
* Instruct the flash movie to rewind to the first frame.
* This will also stop the movie if it was playing.
*/
void rewindAction() {
flashPanel.rewind();
System.out.println("currentFrame=" + flashPanel.getCurrentFrame());
}
/**
* Select and set the flash movie background color.
*/
void backgroundAction() {
Color c = JColorChooser.showDialog(this, "Choose Background",
flashPanel.getBackground());
flashPanel.setBackground(c);
}
/**
* Instruct the flash movie to loop or not.
*/
void loopAction(JCheckBox loopCheckBox) {
flashPanel.setLoop(loopCheckBox.isSelected());
}
/**
* Call a flash function and display the return value.
没有合适的资源?快使用搜索试试~ 我知道了~
用java窗口播放flash,java窗口可设置透明度
共48个文件
class:23个
swf:6个
java:5个
5星 · 超过95%的资源 需积分: 10 210 下载量 42 浏览量
2011-12-16
17:13:38
上传
评论 2
收藏 5.38MB ZIP 举报
温馨提示
其中test的几个类是播放flash的,只看flashTest01.java就行了! 里面还有jflashplayer.jar(FlashPanle类可以实现播放flash),jan.zip,examples.jar(WindowUtils可以实现窗口透明和穿透、改变窗口形状)
资源推荐
资源详情
资源评论
收起资源包目录
java让flash透明.zip (48个子文件)
jflashplayer.jar 1.9MB
jna.zip 777KB
flashTest.zip 1.36MB
test
.project 380B
jflash.dll 128KB
src
no
flashTest01.java 3KB
Example.java 13KB
example
Movie.swf 6KB
Movie.fla 73KB
Movie-FSCommand.swf 4KB
test
TransparentFrame02.java 4KB
test.java 697B
TransparentFrame.java 6KB
lib
examples.jar 276KB
jna.jar 925KB
example
Movie.swf 6KB
Movie.fla 73KB
Movie-FSCommand.swf 4KB
atl2k.dll 83KB
.settings
org.eclipse.jdt.core.prefs 629B
atl98.dll 100KB
.classpath 747B
bin
no
Example$3.class 873B
Example$FrameMonitorThread.class 1KB
Example$12.class 656B
Example$8.class 652B
Example.class 11KB
Example$2.class 721B
Example$1.class 875B
Example$9.class 651B
Example$FrameMonitorThread$1.class 1KB
Example$6.class 649B
Example$11.class 775B
Example$7.class 649B
flashTest01.class 3KB
Example$5.class 649B
Example$10.class 657B
Example$4.class 653B
example
Movie.swf 6KB
Movie.fla 73KB
Movie-FSCommand.swf 4KB
test
TransparentFrame02$1.class 737B
TransparentFrame$1.class 725B
TransparentFrame02$2.class 1KB
TransparentFrame02.class 4KB
TransparentFrame$2.class 1018B
TransparentFrame.class 5KB
test.class 1KB
共 48 条
- 1
bin94336673
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页