com.jpackages.jflashplayer
Class FlashPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by com.jpackages.jflashplayer.FlashPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class FlashPanel
extends java.awt.Panel

This class provides functionality to display a Flash Player movie animation.

Example:

 // specify your registration key if you have purchased a registered version
 FlashPanel.setRegistrationKey("AAAA-BBBB-CCCC-DDDD-EEEE-FFFF");

 // install Flash 10 if that version is not already present
 FlashPanel.installFlash();

 // specify the required version in case its not available
 FlashPanel.setRequiredFlashVersion("9");
 FlashPanel flashPanel = new FlashPanel(new File("Movie.swf"));
 

Copyright (c) 2001-2009

Version:
2.1
Author:
JPackages.com

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
static int QUALITY_HIGH
           Animation high quality.
static int QUALITY_LOW
           Animation low quality.
static int SCALE_EXACTFIT
           Makes the entire movie visible in the specified area without trying to preserve the original aspect ratio.
static int SCALE_NOBORDER
           Scales the movie to fill the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the movie.
static int SCALE_SHOWALL
           Makes the entire movie visible in the specified area without distortion, while maintaining the original aspect ratio of the movie.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FlashPanel(java.io.File f)
          Constructs a FlashPanel given a flash animation (swf) File.
FlashPanel(java.io.File f, boolean autoplay)
          Constructs a FlashPanel given a flash animation (swf) File.
FlashPanel(java.io.File f, java.awt.Image image)
          Constructs a FlashPanel given a flash animation (swf) File and alternate Image.
FlashPanel(java.io.File f, java.awt.Image image, boolean autoplay)
          Constructs a FlashPanel given a flash animation (swf) File and alternate Image.
FlashPanel(java.net.URL u)
          Constructs a FlashPanel given a flash animation (swf) URL.
FlashPanel(java.net.URL u, boolean autoplay)
          Constructs a FlashPanel given a flash animation (swf) URL.
FlashPanel(java.net.URL u, java.awt.Image image)
          Constructs a FlashPanel given a flash animation (swf) URL and alternate Image.
FlashPanel(java.net.URL u, java.awt.Image image, boolean autoplay)
          Constructs a FlashPanel given a flash animation (swf) URL and alternate Image.
 
Method Summary
 void addFlashPanelListener(FlashPanelListener flashPanelListener)
          Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code. Use ExternalInterface.call() in Flash and setFlashCallObject(java.lang.Object) to call Java methods from Flash.
 void addNotify()
          This method should not be called.
 void back()
           Go back one frame in the animation.
 java.lang.Object callFlashFunction(java.lang.String methodName, java.lang.Object[] objects)
           Calls a function in Flash ActionScript.
 void callFrame(int framenumber)
          Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.
 void callFrame(java.lang.String label)
          Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.
 void callFrame(java.lang.String timeline, int framenumber)
          Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.
 void callFrame(java.lang.String timeline, java.lang.String label)
          Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.
 void dispose()
          Releases all of the native screen resources for this object.
 void forward()
           Go forward one frame in the animation.
 java.awt.Color getBackground()
           Retrieves the background Color.
 long getCurrentFrame()
           Retrieves the current frame being displayed.
 boolean getLoop()
           Retrieves if the animation is set to loop.
 boolean getMenuDisplay()
           Retrieves if the animation right-click menu functionality is displayed.
 int getQuality()
           Retrieves the animation quality as QUALITY_LOW or QUALITY_HIGH.
 long getTotalFrames()
           Retrieves the total number of frames in the flash animation.
 java.lang.String getVariable(java.lang.String variable)
          Deprecated. For ActionScript 3, please use the callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.
static boolean hasFlashVersion(java.lang.String version)
           Retrieves if the system has the specified flash version.
static boolean installFlash()
          Installs the latest Flash on the system if it is not already present.
static boolean installFlash(java.io.File flashocx, java.lang.String versionRequired)
           Installs flash from the specified ocx File.
static boolean installFlash(java.lang.String versionRequired)
          Installs the latest Flash on the system if it is not already present.
 boolean isNativeFlashDisplayed()
          Determine if the native Flash Player has been loaded and successfully displayed.
 boolean isPlaying()
           Retrieves if the flash animation is playing.
 void paint(java.awt.Graphics g)
           Overridden paint method to draw alternate image if necessary.
 void play()
           Play the animation from a stopped state.
static boolean registerFlash(java.io.File flashocx, java.lang.String versionRequired)
           This method differs from the installFlash methods in that it does not copy the flash.ocx file anywhere.
 void removeFlashPanelListener(FlashPanelListener flashPanelListener)
          Remove a FlashPanelListener from this FlashPanel.
 void rewind()
           Rewind the animation to the beginning.
 void setBackground(java.awt.Color c)
           Sets the background Color.
 boolean setCurrentFrame(long frame_index)
           Set the current frame index to be displayed.
 void setFlashCallListener(FlashCallListener listener)
          When the ActionScript function ExternalInterface.call() is executed in flash, the listener specified here will be notified.
 void setFlashCallObject(java.lang.Object object)
          When the ActionScript function ExternalInterface.call() is executed in flash, the method it will try to call is on the object set here.
 void setLoop(boolean b)
           Sets the animation to loop or not.
 void setMenuDisplay(boolean b)
           Sets the animation right-click menu functionality to be displayed.
 void setMovie(java.io.File f)
          Change the movie in this FlashPanel to a specified flash animation (swf) File.
 void setMovie(java.net.URL url)
          Change the movie in this FlashPanel to a specified flash animation (swf) URL.
 void setQualityHigh()
           Sets the animation quality to High.
 void setQualityLow()
           Sets the animation quality to Low.
static void setRegistrationKey(java.lang.String key)
          When you purchase a registered version of JFlashPlayer, you must programmatically specify your registration key by passing it to this method.
static void setRequiredFlashVersion(java.lang.String ver)
           Specify the required version of flash before creating a FlashPanel.
 void setScale(int i)
           Sets the movie scale behavior.
 void setVariable(java.lang.String variable, java.lang.String value)
          Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.
 void setVariables(java.lang.String variables)
          This method should be called after FlashPanel is instantiated but before it is visible.
 void stop()
           Stop the animation.
static boolean uninstallFlash()
           Uninstalls Flash if you used installFlash() or installFlash(String) to install.
static boolean uninstallFlash(java.io.File flashocx)
           Uninstalls flash using the specified ocx File.
 
Methods inherited from class java.awt.Panel
getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUALITY_LOW

public static final int QUALITY_LOW

Animation low quality.

See Also:
Constant Field Values

QUALITY_HIGH

public static final int QUALITY_HIGH

Animation high quality.

See Also:
Constant Field Values

SCALE_SHOWALL

public static final int SCALE_SHOWALL

Makes the entire movie visible in the specified area without distortion, while maintaining the original aspect ratio of the movie. Borders may appear on two sides of the movie.

See Also:
Constant Field Values

SCALE_NOBORDER

public static final int SCALE_NOBORDER

Scales the movie to fill the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the movie.

See Also:
Constant Field Values

SCALE_EXACTFIT

public static final int SCALE_EXACTFIT

Makes the entire movie visible in the specified area without trying to preserve the original aspect ratio. Distortion may occur.

See Also:
Constant Field Values
Constructor Detail

FlashPanel

public FlashPanel(java.net.URL u,
                  java.awt.Image image)

Constructs a FlashPanel given a flash animation (swf) URL and alternate Image.

This constructor will autoplay the flash animation.

If there are any missing libraries or lack of Flash, the alternate Image will be displayed instead and stretched to the size of Panel.

Parameters:
u - Flash animation (swf) URL which must be http
image - Alternate Image for display on error

FlashPanel

public FlashPanel(java.net.URL u,
                  java.awt.Image image,
                  boolean autoplay)

Constructs a FlashPanel given a flash animation (swf) URL and alternate Image.

If there are any missing libraries or lack of Flash, the alternate Image will be displayed instead and stretched to the size of Panel.

Parameters:
u - Flash animation (swf) URL which must be http
autoplay - Automatically begin the playing of the flash animation
image - Alternate Image for display on error

FlashPanel

public FlashPanel(java.io.File f,
                  java.awt.Image image)

Constructs a FlashPanel given a flash animation (swf) File and alternate Image.

This constructor will autoplay the flash animation.

If there are any missing libraries, lack of Flash, or file errors, the alternate Image will be displayed instead and stretched to the size of Panel.

Parameters:
f - Flash animation (swf) File
image - Alternate Image for display on error

FlashPanel

public FlashPanel(java.io.File f,
                  java.awt.Image image,
                  boolean autoplay)

Constructs a FlashPanel given a flash animation (swf) File and alternate Image.

If there are any missing libraries, lack of Flash, or file errors, the alternate Image will be displayed instead and stretched to the size of Panel.

Parameters:
f - Flash animation (swf) File
autoplay - Automatically begin the playing of the flash animation
image - Alternate Image for display on error

FlashPanel

public FlashPanel(java.net.URL u)
           throws JFlashLibraryLoadFailedException,
                  JFlashInvalidFlashException

Constructs a FlashPanel given a flash animation (swf) URL.

This constructor will autoplay the flash animation.

Parameters:
u - Flash animation (swf) URL which must be http
Throws:
JFlashLibraryLoadFailedException - A necessary library is missing (JFlash DLL or ATL DLL)
JFlashInvalidFlashException - Required Flash version is not available

FlashPanel

public FlashPanel(java.net.URL u,
                  boolean autoplay)
           throws JFlashLibraryLoadFailedException,
                  JFlashInvalidFlashException

Constructs a FlashPanel given a flash animation (swf) URL.

Parameters:
u - Flash animation (swf) URL which must be http
autoplay - Automatically begin the playing of the flash animation
Throws:
JFlashLibraryLoadFailedException - A necessary library is missing (JFlash DLL or ATL DLL)
JFlashInvalidFlashException - Required Flash version is not available

FlashPanel

public FlashPanel(java.io.File f)
           throws JFlashLibraryLoadFailedException,
                  JFlashInvalidFlashException,
                  java.io.FileNotFoundException

Constructs a FlashPanel given a flash animation (swf) File.

This constructor will autoplay the flash animation.

Parameters:
f - Flash animation (swf) File
Throws:
JFlashLibraryLoadFailedException - A necessary library is missing (JFlash DLL or ATL DLL)
JFlashInvalidFlashException - Required Flash version is not available
java.io.FileNotFoundException - The specified File cannot be found

FlashPanel

public FlashPanel(java.io.File f,
                  boolean autoplay)
           throws JFlashLibraryLoadFailedException,
                  JFlashInvalidFlashException,
                  java.io.FileNotFoundException

Constructs a FlashPanel given a flash animation (swf) File.

Parameters:
f - Flash animation (swf) File
autoplay - Automatically begin the playing of the flash animation
Throws:
JFlashLibraryLoadFailedException - A necessary library is missing (JFlash DLL or ATL DLL)
JFlashInvalidFlashException - Required Flash version is not available
java.io.FileNotFoundException - The specified File cannot be found
Method Detail

addFlashPanelListener

public void addFlashPanelListener(FlashPanelListener flashPanelListener)
Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code. Use ExternalInterface.call() in Flash and setFlashCallObject(java.lang.Object) to call Java methods from Flash.

Add a FlashPanelListener to this FlashPanel.

Parameters:
flashPanelListener - The listener to add

removeFlashPanelListener

public void removeFlashPanelListener(FlashPanelListener flashPanelListener)

Remove a FlashPanelListener from this FlashPanel.

Parameters:
flashPanelListener - The listener to remove

setRegistrationKey

public static final void setRegistrationKey(java.lang.String key)

When you purchase a registered version of JFlashPlayer, you must programmatically specify your registration key by passing it to this method.

This static method should be called before anything else is done with this API as follows:

 FlashPanel.setRegistrationKey("AAAA-BBBB-CCCC-DDDD-EEEE-FFFF");
 

Parameters:
key - Registration Key

dispose

public void dispose()

Releases all of the native screen resources for this object. This is done automatically when this object is garbage collected but under some circumstances, it is preferable to not have to wait for garbage collection to destroy native resources.


addNotify

public void addNotify()

This method should not be called. It is used internally to properly create a FlashPanel.

Overrides:
addNotify in class java.awt.Panel

paint

public void paint(java.awt.Graphics g)

Overridden paint method to draw alternate image if necessary. Should not be called by developer.

Overrides:
paint in class java.awt.Container

setRequiredFlashVersion

public static void setRequiredFlashVersion(java.lang.String ver)

Specify the required version of flash before creating a FlashPanel. If the required flash version is unavailable, the constructor will throw a JFlashInvalidFlashException.

Example:

 FlashPanel.setRequiredFlashVersion("7");
 

Parameters:
ver - Flash version such as "7"

setMovie

public void setMovie(java.io.File f)
              throws java.io.FileNotFoundException

Change the movie in this FlashPanel to a specified flash animation (swf) File.

Parameters:
f - Flash animation (swf) File
Throws:
java.io.FileNotFoundException - The specified File cannot be found

setMovie

public void setMovie(java.net.URL url)

Change the movie in this FlashPanel to a specified flash animation (swf) URL.

Parameters:
url - Flash animation (swf) URL

play

public void play()

Play the animation from a stopped state.

NOTE: Animations start playing when a FlashPanel is created.


stop

public void stop()

Stop the animation.


back

public void back()

Go back one frame in the animation. The animation will also stop so if you would like it to restart, use the play() method.


forward

public void forward()

Go forward one frame in the animation. The animation will also stop so if you would like it to restart, use the play() method.


rewind

public void rewind()

Rewind the animation to the beginning. The animation will also stop so if you would like it to restart, use the play() method.


isPlaying

public boolean isPlaying()

Retrieves if the flash animation is playing.

Returns:
true if the animation is playing, false otherwise

setCurrentFrame

public boolean setCurrentFrame(long frame_index)

Set the current frame index to be displayed.

This method will fail if the animation has not yet been visually displayed.

The animation will also stop so if you would like it to restart, use the play() method.

Parameters:
frame_index - Index of the flash frame to display.
Returns:
true if successfully set current frame, false otherwise

getTotalFrames

public long getTotalFrames()

Retrieves the total number of frames in the flash animation.

Returns:
The total frames in the animation or -1 if the animation has not yet been displayed

getCurrentFrame

public long getCurrentFrame()

Retrieves the current frame being displayed.

Returns:
The index of the currently displayed flash frame or -1 if the animation has not yet been displayed

setQualityLow

public void setQualityLow()

Sets the animation quality to Low.

The default image quality is High.


setQualityHigh

public void setQualityHigh()

Sets the animation quality to High.

The default image quality is High.


getQuality

public int getQuality()

Retrieves the animation quality as QUALITY_LOW or QUALITY_HIGH.

Returns:
animation quality

callFrame

public void callFrame(java.lang.String timeline,
                      int framenumber)
Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.

Call the frame actions for a specified frame in a given timeline.

Parameters:
timeline - The timeline the frame is in. "/" is the main timeline.
framenumber - The index of the frame

callFrame

public void callFrame(int framenumber)
Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.

Call the fram actions for a specified frame in the main timeline.

Parameters:
framenumber - The index of the frame

callFrame

public void callFrame(java.lang.String timeline,
                      java.lang.String label)
Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.

Call the frame actions for a specified frame by its label in a given timeline.

Parameters:
timeline - The timeline the frame is in. "/" is the main timeline.
label - The label of the frame

callFrame

public void callFrame(java.lang.String label)
Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.

Call the frame actions for a specified frame by its label in the main timeline.

Parameters:
label - The label of the frame

isNativeFlashDisplayed

public boolean isNativeFlashDisplayed()

Determine if the native Flash Player has been loaded and successfully displayed.

Many methods such as setVariable and getVariable will only work once the native Flash Player has been successfully displayed.

Returns:
true if the native Flash Player has been loaded and displayed, false otherwise

setVariable

public void setVariable(java.lang.String variable,
                        java.lang.String value)
Deprecated. For ActionScript 3, please use callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.

Set the value of a Flash variable.

Parameters:
variable - Flash variable
value - The value assigned to the specified variable name

setVariables

public void setVariables(java.lang.String variables)

This method should be called after FlashPanel is instantiated but before it is visible. These variables will then be available at startup of the flash movie in ActionScript.

In ActionScript 3, you can access the variable name myVariable by root.loaderInfo.parameters.myVariable.

The string of variables should look like this:

 myVariable=horse&myOtherVariable=1&myLastVariable=good%20job
 

For more information on setting this variables string, please visit this Adobe document.

Parameters:
variables - Variables defined before the FlashPanel is visible
Since:
2.0

getVariable

public java.lang.String getVariable(java.lang.String variable)
Deprecated. For ActionScript 3, please use the callFlashFunction(java.lang.String, java.lang.Object[]) to communicate with Flash ActionScript code.

Get the value of a Flash variable.

Parameters:
variable - Flash variable
Returns:
The value of the specified variable or null if no such variable

setScale

public void setScale(int i)

Sets the movie scale behavior.

Default is FlashPanel.SCALE_SHOWALL.

Parameters:
i - int Scale

setBackground

public void setBackground(java.awt.Color c)

Sets the background Color.

Overrides:
setBackground in class java.awt.Component
Parameters:
c - Background Color

getBackground

public java.awt.Color getBackground()

Retrieves the background Color.

Overrides:
getBackground in class java.awt.Component
Returns:
Background Color

setLoop

public void setLoop(boolean b)

Sets the animation to loop or not.

Parameters:
b - set loop

getLoop

public boolean getLoop()

Retrieves if the animation is set to loop.

Returns:
true if the animation is set to loop, false otherwise

installFlash

public static boolean installFlash()

Installs the latest Flash on the system if it is not already present. As of JFlashPlayer 2.0, the included latest version is Flash 10.

It is highly recommended to receive user permission before using this method.

Use the uninstallFlash() method to unregister.

This method will only work on Windows XP/Vista.

This method requires the resource installflash.zip included in jflashplayer.jar to be included with your Java resources as well (such as in your application jar).

Keep in mind that Flash 10 does not work on older versions of Windows so be sure you are installing the right Flash version on the right OS.

Returns:
true if the latest version is already present or successfully registered, false otherwise
Since:
2.0

installFlash

public static boolean installFlash(java.lang.String versionRequired)

Installs the latest Flash on the system if it is not already present. As of JFlashPlayer 2.0, the included latest version is Flash 10.

It is highly recommended to receive user permission before using this method.

Use the uninstallFlash() method to unregister.

This method will only work on Windows XP/Vista.

This method requires the resource installflash.zip included in jflashplayer.jar to be included with your Java resources as well (such as in your application jar).

Keep in mind that Flash 10 does not work on older versions of Windows so be sure you are installing the right Flash version on the right OS.

Parameters:
versionRequired - Flash version such as "9" that you require to be present
Returns:
true if the version is already present or successfully registered, false otherwise
Since:
2.0

installFlash

public static boolean installFlash(java.io.File flashocx,
                                   java.lang.String versionRequired)

Installs flash from the specified ocx File.

As of Flash Player 10, the ocx file is Flash10a.ocx and is located in the [WINDOWS SYSTEM32]\Macromed\Flash directory. JFlashPlayer does not include a Flash ocx file.

This method will copy the Flash ocx file to the above mentioned directory and register it to Windows for system-wide use.

If you do not want the file copied to the above mentioned directory, use the registerFlash method instead.

Example:

 
 boolean installed = installFlash(new File("Flash10a.ocx", "10"));
 

It is highly recommended to receive user permission before using this method.

This method requires the resource installflash.zip included in jflashplayer.jar to be included with your Java resources as well (such as in your application jar) for it to work on Windows XP/Vista. For older versions of Windows, installflash.zip is not necessary.

Keep in mind that Flash 10 does not work on older versions of Windows to be sure you are installing the right Flash version on the right OS.

Parameters:
flashocx - Flash.ocx File
versionRequired - Flash version such as "9" that you require to be present
Returns:
true if the version is already present or successfully installed, false otherwise

uninstallFlash

public static boolean uninstallFlash(java.io.File flashocx)

Uninstalls flash using the specified ocx File.

Flash is unregistered from Windows. No files are deleted.

Parameters:
flashocx - Flash.ocx File
Returns:
true if the uninstallation was successful, false otherwise

uninstallFlash

public static boolean uninstallFlash()

Uninstalls Flash if you used installFlash() or installFlash(String) to install.

Flash is unregistered from Windows.

Returns:
true if the uninstallation was successful, false otherwise
Since:
2.0

registerFlash

public static boolean registerFlash(java.io.File flashocx,
                                    java.lang.String versionRequired)

This method differs from the installFlash methods in that it does not copy the flash.ocx file anywhere. That is up to the developer to do first as they see fit. This is a more manual approach that only registers the specified flash.ocx file with Windows for system-wide use.

It is highly recommended to receive user permission before using this method.

Use the uninstallFlash method to unregister.

Parameters:
flashocx - Flash.ocx File
versionRequired - Flash version such as "9"
Returns:
true if the version is already present or successfully registered, false otherwise
Since:
2.0

hasFlashVersion

public static boolean hasFlashVersion(java.lang.String version)
                               throws JFlashLibraryLoadFailedException

Retrieves if the system has the specified flash version.

Example:

 if (!hasFlashVersion("6"))
   installFlash(new File("Flash.ocx"));
 

Parameters:
version - Flash version such as "7"
Returns:
true if specified flash version or greater is available, false otherwise
Throws:
JFlashLibraryLoadFailedException - A necessary library is missing (JFlash DLL or ATL DLL)

setMenuDisplay

public void setMenuDisplay(boolean b)

Sets the animation right-click menu functionality to be displayed.
The default is for the menu functionality to not be displayed.

NOTE: Even when set to false, there is a minimal right-click menu that cannot be removed.

Parameters:
b - display menu

getMenuDisplay

public boolean getMenuDisplay()

Retrieves if the animation right-click menu functionality is displayed.

Returns:
true if the menu functionality is displayed, false otherwise

setFlashCallObject

public void setFlashCallObject(java.lang.Object object)

When the ActionScript function ExternalInterface.call() is executed in flash, the method it will try to call is on the object set here.

If the method is not found within the object, the ExternalInterface.call() function will receive a null response. An error message to standard error output will also be sent to help the developer see what method definition is needed.

Only setFlashCallObject or setFlashCallListener should be specified, not both. Setting this method will remove the FlashCallListener.

Parameters:
object - The object where methods will be called from flash ActionScript code
Since:
2.0

setFlashCallListener

public void setFlashCallListener(FlashCallListener listener)
When the ActionScript function ExternalInterface.call() is executed in flash, the listener specified here will be notified.

Only setFlashCallObject or setFlashCallListener should be specified, not both. Setting this method will remove remove the setFlashCallObject.

Only use this method if you understand the XML format passed back and forth from Flash. The recommended approach is to use setFlashCallObject.

Parameters:
listener - FlashCallListener to deal with ExternalInterface.call() function calls
Since:
2.0

callFlashFunction

public java.lang.Object callFlashFunction(java.lang.String methodName,
                                          java.lang.Object[] objects)

Calls a function in Flash ActionScript.

That function needs to be defined with ExternalInterface.addCallback(methodName, Object, flashFunction) in ActionScript.

The objects argument types correspond from Java objects to Flash data types in the following way.

Java Object TypeFlash Type
BooleanBoolean
DoubleNumber
StringString
String[]Array

Example:

 String response = (String) flashPanel.callFlashFunction("flashFunctionName", new Object[] { "a string as first arg", new Boolean(false) });
 

For the above java code to work, your flash ActionScript would need to have the following example code:

 var methodName:String = "flashFunctionName"; 
 var method:Function = actualFunction;
 ExternalInterface.addCallback(methodName, method);
 
 function actualFunction(examplestring, exampleboolean):String {
   return "Howdy from flash: " + examplestring;
 }
 

Parameters:
methodName - the name of the Flash ActionScript method defined with ExternalInterface.addCallback
objects - Arguments to pass to the Flash function in the form of Boolean, Integer, Long, Double, String, or String[]
Returns:
the return value from the Flash function or null if void
Since:
2.0