[an error occurred while processing this directive] [an error occurred while processing this directive]
 
home / tutorials / FS Command JavaScript Library
Tutorial details:

Written by: AshzFall / http://www.ashzfall.com/
Difficulty Level: Intermediate
Requirements: Flash 5

AF FSCommand JS library Quick Reference
Direct JavaScript calls and FSCommand calls use the same name and require the same arguments in the same order.

JavaScript in HTML:
In an event:
eventName="functionName('args')"
In a link:
<A HREF="JavaScript:functionName('args')"></A>
Multiple arguments should be separated by commas and each argument should be enclosed in its own set of single qoutes unless it is a number. The entire function call must be enclosed in a single set of double quotes.
In an event:
eventName="functionName('arg1','arg2','arg3')"
In a link:
<A HREF="JavaScript:functionName('arg1','arg2','arg3')"></A>


JavaScript via Flash Get URL:
Get URL ("JavaScript:functionName('args')")
Multiple arguments should be separated by commas and each argument should be enclosed in its own set of single qoutes unless it is a number. The entire function call must be enclosed in a single set of double quotes.
Get URL ("JavaScript:functionName('arg1','arg2','arg3')")


JavaScript via Flash FS Command:
FS Command ("functionName" , "args")
Multiple arguments should be separated by commas and enclosed in a single set of double quotes.
FS Command ("functionName" , "arg1,arg2,arg3")


Functions that involve the setting or getting of properties, must send the property number for the property that is to be set or gotten. It is highly recommended that you copy, print or bookmark the properties table from the Macromedia site.

movieObjNum and movieRefNum
All functions that create a movie reference require a movieObjNum argument. All functions that perform an action on a movie require a movieRefNum argument.

When you create a movie reference, you must send a number to the reference creation function as the movieObjNum (movie object number). A unique number should be used for each reference created even if different reference creation functions are used to create the references.

To control or otherwise communicate with a specific movie, you must send the movie object number (movieObjNum) used to create the specific movie reference as the movieRefNum (movie reference number) argument.

If you will be working with multiple movie references, it is suggested that you create all references to movies in an early keyframe of your animation or as a response to the onLoad event of the HTML page.

For more information on setting movie references, see the movie reference information page.

Functions with a return value
Functions that state that they return a value within JavaScript and also set a global value of a variable to the current value can be used in the following methods: In JavaScript:
myVar=functionName('args')
This will set the value of the variable myVar to the return value of the function functionName.
From FS Command:
Any argument sent with the value of one of the arguments set to the name of the global value will be replaced by the value of the global value. So, if you set the value of an argument to 'returnPlayStatus', it will switch the 'returnPlayStatus' for the actual value of the returnPlayStatus variable that was set during the last call to the playStatus() function.


Catagory
Function Name Arguments
Description
Movie Object Reference Settings
setMovieRef movieName,movieObjNum
Sets the movie reference to a movie on the same page with the NAME and ID of movieName. movieObjNum is the number to assign to the movie object.
setFrameRef frameName,movieName,movieObjNum
Sets the movie reference to a movie in another frame. The frameName is the name of the frame from the FRAME tag and movieName is the NAME and ID of the movie.
setWindowRef winNumber,movieName,movieObjNum
Sets the movie reference to a movie in another window. The window must have been created using the popupMaker() function. The windowNumber is the number used in popupMaker() to create the window. The movieName is the NAME and ID of the movie. movieObjNum is the number to assign to the movie object.
setWindowFrameRef windowNumber,frameName,movieName,movieObjNum
Sets the movie reference to a movie in a frame in another window. The window must have been created using the popupMaker() function. The windowNumber is the number used in popupMaker() to create the window. The frameName is the name of the frame from the FRAME tag and movieName is the NAME and ID of the movie. movieObjNum is the number to assign to the movie object.
setLayerRef layerName,movieName,movieObjNum
Sets the movie reference to a movie in the same page inside of a
or
setLayerFrameRef frameName,layerName,movieName,movieObjNum
Sets the movie reference to a movie in another frame inside of a
or
setLayerWindowRef windowNumber,layerName,movieName,movieObjNum
Sets the movie reference to a movie in another window inside of a
or
SetLayerWindowFrameRef winNumber,frameName,layerName,movieName,movieObjNum
Sets the movie reference to a movie in a frame inside of another window inside of a
or
Cookie Functions
setCookie theName,thePath,numberOfDays,theValue
Saves data to a cookie with a specific name. theName is the name of the cookie to create. thePath is the domain and path that can access the cookie. In most circumstances, you will wish to send the / character as thePath. The / enables cookie reading for the entire domain. numberOfDays is the number of days you would like the cookie to last before expiring. theValue is the string of characters to save to the cookie. Cookie data must be encoded, the setCookie function automatically encodes the data, so you will not need to create a routine to do this function.
getCookie theName,varName,movieRefNum
Retrives data from a cookie with a specific name and sends it to a Flash movie variable. theName is the name of the cookie to read from. varName is the name of the variable in the flash file that will receive the cookie data. movieRefNum is the movie reference number for the movie that receives the action. Cookie data is encoded, the getCookie function automatically unencodes the data, so you will not need to create a routine to do this function.
deleteCookie theName,thePath
Deletes a named cookie. theName is the name of the cookie to delete. thePath is the domain and path that can access the cookie and should be the same as the path used for the setCookie function.
Standard Playback
playMovie movieRefNum
Plays a movie. movieRefNum is the movie reference number for the movie that receives the action.
rewindMovie movieRefNum
Rewinds a movie. movieRefNum is the movie reference number for the movie that receives the action.
stopMovie movieRefNum
Stops a movie. movieRefNum is the movie reference number for the movie that receives the action.
playTargetMovie target,movieRefNum
Plays a movie in the target referenced in target. movieRefNum is the movie reference number for the movie that receives the action.
stopTargetMovie target,movieRefNum
Stops a movie in the target referenced in target. movieRefNum is the movie reference number for the movie that receives the action.
Movie Status
loadedPercent movieRefNum
Indicates the percentage of the movie that has downloaded. This function returns the value within JavaScript and also sets the global value of returnPercentLoaded to the current value. movieRefNum is the movie reference number for the movie that receives the action.
currentFrameNumber target,movieRefNum
Retrieves the current frame number for the movie in the target referenced in target. This function returns the value within JavaScript and also sets the global value of returnCurrentFrameNumber to the current value. movieRefNum is the movie reference number for the movie that receives the action.
currentFrameLabel target,movieRefNum
Retrieves the current frame label for the movie in the target referenced in target. This function returns the value within JavaScript and also sets the global value of returnCurrentFrameLabel to the current value. movieRefNum is the movie reference number for the movie that receives the action.
playStatus movieRefNum
Retrieves the playing status for the movie. If the movie is playing, the return value is true. If the movie is not playing, the return status is false. This function returns the value within JavaScript and also sets the global value of returnPlayStatus to the current value. movieRefNum is the movie reference number for the movie that receives the action.
loadPercentToVar varName,movieRefNum1,movieRefNum2
Retrieves the loaded percent value for the movie with the reference number specified in movieRefNum1 and sets the variable named varName in the movie with the reference number specified in movieRefNum2 equal to the retrieved value.
currentFrameToVar target,varName,movieRefNum1,movieRefNum2
Retrieves the current frame number for the movie with the reference number specified in movieRefNum1 in the target specified in target and sets the variable named varName in the movie with the reference number specified in movieRefNum2 equal to the retrieved value.
Load Movie
movieLoad layerNum,movieURL,movieRefNum
Loads a movie into the layer specified in layerNum. movieURL is the full or relative path for the movie file to load into the layer. movieRefNum is the movie reference number for the movie that receives the action.
Go To and Play
goToFrameNumber frameNumber,movieRefNum
Goes to the frame in the movie with the number specified in frameNumber. The frameNumber corresponds directly with the frame numbers from the Flash development environment, so 1 is the number of the first frame. movieRefNum is the movie reference number for the movie that receives the action.
goToFrameLabel frameLabel,movieRefNum
Goes to the frame in the movie with the label specified in frameLabel. movieRefNum is the movie reference number for the movie that receives the action.
goToTFrameNumber target,frameNumber,movieRefNum
Goes to the frame in the movie in the target referenced in target with the number specified in frameNumber. The frameNumber corresponds directly with the frame numbers from the Flash development environment, so 1 is the number of the first frame. movieRefNum is the movie reference number for the movie that receives the action.
goToTFrameLabel target,frameLabel,movieRefNum
Goes to the frame in the movie in the target referenced in target with the label specified in frameLabel . movieRefNum is the movie reference number for the movie that receives the action.
Call Frame Actions
callFrameNumber frameNumber,movieRefNum
Calls the frame in the movie with the number specified in frameNumber. Calling the frame executes the scripted actions in the frame. The frameNumber corresponds directly with the frame numbers from the Flash development environment, so 1 is the number of the first frame. movieRefNum is the movie reference number for the movie that receives the action.
callFrameLabel frameLabel,movieRefNum
Calls the frame in the movie with the label specified in frameLabel. Calling the frame executes the scripted actions in the frame. movieRefNum is the movie reference number for the movie that receives the action.
Pan and Zoom
panIt X,Y,zoomMode,movieRefNum
This pans a movie that is zoomed. The zoomed movie is panned by the coordinates in X and Y. If zoomMode is set to 0, X and Y must be sent as exact pixels. If zoomMode is set to 1, X and Y must be sent as a percentage of the movie window. movieRefNum is the movie reference number for the movie that receives the action.
setZoom Left,Top,Right,Bottom,movieRefNum
Zooms in on a specific area of the movie. The coordinates of the area to zoom in on are indicated by the Left,Top,Right, and Bottom in Points. To retrieve these Point coordinates in the Flash development environment, set the movie ruler units to Points from the modify ->movie dialogue box and turn the rulers on from the view menu. Use the rulers to determine the Point coordinates. movieRefNum is the movie reference number for the movie that receives the action.
zoomIt Percent,movieRefNum
Zooms a movie by the percent indicated in Percent. This is the standard resizing based on an item being at its full size when it is at 100 percent. So, 50 percent would make an object half the size of the original and 200 percent would make an object twice the size of the original. To reset the movie to 100 percent, send 0 as the value of Percent. movieRefNum is the movie reference number for the movie that receives the action.
Variables
getVar varName,movieRefNum
Retrieves the value of the variable named varName. This function returns the value within JavaScript and also sets the global value of returnVar to the current value. movieRefNum is the movie reference number for the movie that receives the action.
setVar varName,varValue,movieRefNum
Sets the value of the variable named varName to the value specified in varValue. movieRefNum is the movie reference number for the movie that receives the action.
varToVar varName1,varName2,movieRefNum1,movieRefNum2
Retrieves the value of the variable specified in varName1 from the movie referenced in movieRefNum1 and sets the variable named varName2 in the movie referenced in movieRefNum2 equal to the retrieved value.
Properties
getProperty target,propertyNumber,movieRefNum
Retrieves the value of the property indicated in propertyNumber in the movie in the target referenced in target. Properties are specified in numbers from 0 to 18 that correspond with the property being accessed. For a list of properties and their numbers, see the properties table on the Macromedia site. This function returns the value within JavaScript and also sets the global value of returnPropString to the current value. movieRefNum is the movie reference number for the movie that receives the action.
setProperty target,propertyNumber,propertyValue,movieRefNum
Sets the value of the property indicated in propertyNumber in the movie in the target referenced in target to the value specified in propertyValue. Properties are specified in numbers from 0 to 18 that correspond with the property being accessed. For a list of properties and their numbers, see the properties table on the Macromedia site. movieRefNum is the movie reference number for the movie that receives the action.
propToProp target1,target2,propertyNumber1,propertyNumber2, movieRefNum1,movieRefNum2
Retrieves the value for the property indicated in propertyNumber1 in the movie in the target referenced in target1 with the movie reference of movieRefNum1. The value of the property indicated in propertyNumber2 in the movie in the target referenced in target2 with the movie reference of movieRefNum2 is set to the retrieved value. Properties are specified in numbers from 0 to 18 that correspond with the property being accessed. For a list of properties and their numbers, see the properties table on the Macromedia site.
propToVar target,propertyNumber,varName, movieRefNum1,movieRefNum2
Retrieves the value for the property indicated in propertyNumber in the movie in the target referenced in target with the movie reference of movieRefNum1. The value of the variable indicated in varName in the movie referenced in movieRefNum2 is set to the retrieved value. Properties are specified in numbers from 0 to 18 that correspond with the property being accessed. For a list of properties and their numbers, see the properties table on the Macromedia site.
Popup Windows
popupMaker URL,windowName,Width,Height,Top,Left,Toolbar,Location, Status,Menubar,Scrollbars,Resizable,Fullscreen,windowNumber
Creates a new popup window with the number indicated in windowNumber and with the attributes specified in the other arguments. The windowNumber should be unique for each popup window created and is used as the windowNumber argument in movie reference setting functions that require that argument. It is also used by the closePopup() function to close the popup window with the specified windowNumber.

URL is the full or relative path to the document to load into the new popup window. windowName is the name of the popup window. windowName must be unique for all calls to popupMaker or the document specified in URL will be loaded into the existing window with the same windowName without acknowledging any other window feature settings. windowName can be used as the TARGET attribute in HTML links and in the Get URL window argument in Flash scripting to load documents into a window created by popupMaker.

Attributes:
Width the width of the window in pixels.
Height the height of the window in pixels.
Top the positon of the window from the top of the screen in pixels. The topmost visible point on the screen is the pixel 0.
Left the position of the window from the left of the screen in pixels. The leftmost visible point on the screen is the pixel 0.
The remaining attributes all must be set to 0 or 1. The number 1 indicates that you want that window feature to exist or be true. The number 0 indicates that you want that window feature to not exist or be false.
Toolbar display the standard browser buttons.
Location display the location field to display url paths.
Status display the status bar on the bottom of the browser window.
Menubar display the menu bar with dropdowns for file, edit, etc.
Scrollbars display horizontal and vertical scrollbars.
Resizable allow the user to resize the window.
Fullscreen display the window as a fullscreen application. This is an IE only attribute.

All attributes must have a value and all values must be sent in the order specified for the popupMaker function to work correctly.

closePopup windowNumber
Closes the window that was created with the popupMaker function that has the window number specified in windowNumber.
Dialogue Boxes
alertIt message
Creates a JavaScript alert box with the message specified in message. To indicate line breaks, include /r/n in message text at the point of the line break. You must also escape single and double quotes in the message text (She said, /"I can/'t go with you./")
promptToVar varName,message,defaultValue,movieRefNum
Creates a JavaScript prompt box with the message specified in message. The defaultValue will be placed into the text box intended for user input and serves as the default response to the query. The value of the text box is returned within JavaScript and set as the value of the variable named varName in the movie provided that the user does not cancel or close the dialogue box window without providing an answer. If the user cancels or closes the dialogue box without providing an answer, the function will return the text string CANCEL to JavaScript and the variable in the movie. movieRefNum is the movie reference number for the movie that receives the action. To indicate line breaks, include /r/n in message text at the point of the line break. You must also escape single and double quotes in the message text (She said, /"I can/'t go with you./")
confirmToVar varName,message,movieRefNum
Creates a JavaScript confirmation box with the message specified in message. The confirmation box gives the user the option of selecting between an OK and a Cancel button. If the user selects OK, the function returns True within JavaScript and as the value of the variable named in varName in the movie clip. If the user selects Cancel or uses any other method to close the dialogue box besides selecting OK, the function returns False to JavaScript and the variable in the movie. movieRefNum is the movie reference number for the movie that receives the action. To indicate line breaks, include /r/n in message text at the point of the line break. You must also escape single and double quotes in the message text (She said, /"I can/'t go with you./")
Time and Date
quickTime movieRefNum
Retrieves the numbers for the current hour, minutes, seconds, and milliseconds according to the user's system clock. The hour is sent to a variable named jsHour in the movie, the minutes are sent to a variable named jsMinutes in the movie, the seconds are sent to a variable named jsSeconds in the movie, and the milliseconds are sent a variable named jsMilliseconds in the movie. If the variables do not exist, they are created. If you would like these values sent to a text boxes, assign the specified names to the text boxes under their properties dialogue boxes. movieRefNum is the movie reference number for the movie that receives the action.
quickDate movieRefNum
Retrieves the numbers for current month, day and year according to the user's system date. The month is sent to a variable named jsMonth in the movie, the day is sent to a variable named jsDay in the movie, and the year is sent to a variable named jsYear in the movie. If the variables do not exist, they are created. If you would like these values sent to a text boxes, assign the specified names to the text boxes under their properties dialogue boxes. movieRefNum is the movie reference number for the movie that receives the action.
quickTimeDate movieRefNum
This function executes both the quickTime() and the quickDate() functions. Please see the specifics for both of those functions for information on the variables set during this operation. movieRefNum is the movie reference number for the movie that receives the action.
theYear varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current year. movieRefNum is the movie reference number for the movie that receives the action.
theMonth varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current month. movieRefNum is the movie reference number for the movie that receives the action.
theDay varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current day. movieRefNum is the movie reference number for the movie that receives the action.
theHour varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current hour. movieRefNum is the movie reference number for the movie that receives the action.
theMinutes varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current minutes. movieRefNum is the movie reference number for the movie that receives the action.
theSeconds varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current seconds. movieRefNum is the movie reference number for the movie that receives the action.
theMilliseconds varName,movieRefNum
Sets the value of the variable named varName in the movie to the number for the current milliseconds. movieRefNum is the movie reference number for the movie that receives the action.


[an error occurred while processing this directive]
[an error occurred while processing this directive]