background image

98

Server-Side ActionScript Language Reference

LoadVars.onLoad

Availability

Flash Media Server 2.

Usage

myLoadVars

.onLoad(

success

){}

Parameters

success

 

A Boolean value indicating whether the 

LoadVars.load()

 operation ended in 

success (

true

) or failure (

false

).

Description

Event handler; invoked when a 

LoadVars.load()

 or 

LoadVars.sendAndLoad()

 operation 

has completed. If the variables load successfully, the 

success

 parameter is 

true

. If the 

variables were not received, or if an error occurred in receiving the response from the server, 
the 

success

 parameter is 

false

If the 

success

 parameter is 

true

, the 

loadVarsObject

 is populated with variables 

downloaded by the 

LoadVars.load()

 or 

LoadVars.sendAndLoad()

 operation, and these 

variables are available when the 

onLoad

 handler is invoked.

This method is undefined by default, but you can define it by assigning it a callback function.

Example

The following example creates a new LoadVars object, attempts to load variables into it from 
a remote URL, and prints the result:

myLoadVars = new LoadVars();
myLoadVars.onLoad = function(result){

trace("myLoadVars load success is " + result);

}
myLoadVars.load("http://www.someurl.com/somedata.txt");

LoadVars.send()

Availability

Flash Media Server 2.

Usage

myLoadVars

.send(

url

 [, 

target

method

])

Summary of Contents for FLASH MEDIA SERVER 2-SERVER-SIDE ACTIONSCRIPT...

Page 1: ...Server Side ActionScript Language Reference...

Page 2: ...does not imply that Macromedia endorses or accepts any responsibility for the content on those third party sites Sorenson Spark video compression and decompression technology licensed from Sorenson M...

Page 3: ...lass 63 getGlobal 86 load 87 LoadVars class 87 Log class 101 NetConnection class 102 protectObject 112 setAttributes 113 setInterval 115 SharedObject class 116 SOAPCall class 140 SOAPFault class 142 S...

Page 4: ...4 Contents...

Page 5: ...ipt server object model Server side ActionScript provides global methods and classes and exposes a rich object model for developing media applications You can also create classes properties and method...

Page 6: ...tion on server side script files see Developing Media Applications NO TE For large scale applications you may need to use multiple server side script files You can use the Flash Media Server archive c...

Page 7: ...rarchical naming system where a forward slash separates the elements in the hierarchy The first element specifies the application name The element following the application name specifies the applicat...

Page 8: ...ion instance that lasts until the application instance is unloaded Client class The Client class lets you handle each user or client connection to a Flash Media Server application instance File class...

Page 9: ...MLStreams class is a variation of the XMLSocket class It has all the same methods properties and events but it transmits and receives data in fragments Global function Description clearInterval Cancel...

Page 10: ...llowDebug Application allowDebug appendChild XML appendChild attributes XML attributes autoCommit SharedObject autoCommit broadcastMsg Application broadcastMsg bufferTime Stream bufferTime call Client...

Page 11: ...lt faultcode faultstring SOAPFault faultstring firstChild XML firstChild flush File flush SharedObject flush Stream flush gc Application gc get SharedObject get Stream get getBandwidthLimit Client get...

Page 12: ...fied length File length Stream length list File list load load LoadVars load XML load loaded LoadVars loaded XML loaded localName XML localName lock SharedObject lock mark SharedObject mark mkdir File...

Page 13: ...oad XML onLoad onLog Log onLog onResult SOAPCall onResult onStatus Application onStatus NetConnection onStatus SharedObject onStatus Stream onStatus onSync SharedObject onSync onXML XMLSocket onXML op...

Page 14: ...e seek getGlobal send LoadVars send SharedObject send Stream send XML send XMLSocket send sendAndLoad LoadVars sendAndLoad XML sendAndLoad server Application server setAttributes setAttributes setBand...

Page 15: ...ction to create the application object it is created automatically when an application is instantiated by the server Use the following syntax to call the methods properties and event handlers of the A...

Page 16: ...s all stream objects associated with the current instance Application disconnect Disconnects a client from the server Application gc Invokes the garbage collector to reclaim any unused resources for t...

Page 17: ...application instance Application server Read only the platform and version of the server Event handler Description Application onAppStart Invoked when the application is loaded by the server Applicati...

Page 18: ...ceptConnection or application rejectConnection the last line in order of execution of the onConnect event handler should be either application acceptConnection or application rejectConnection Also any...

Page 19: ...cription Method broadcasts a message to all connected clients This method is equivalent to looping through the Application clients array and calling Client call on each individual client but is more e...

Page 20: ...include a slash as a delimiter between directories in the path The last element in the path can contain wildcard patterns for example a question mark and an asterisk or a shared object name The applic...

Page 21: ...e application clearStreams streamPath Parameters streamPath A string that indicates the URI of a stream Returns A Boolean value of true if the stream at the specified path was deleted otherwise false...

Page 22: ...all recorded FLV streams associated with the instance report clears the stream file report flv from the application instance directory presentations intro clears the recorded stream file intro flv fr...

Page 23: ...ion The object is a custom object like an array but with only one property length Each element in the object is a reference to a Client object instance and you can use the length property to determine...

Page 24: ...side scripting in Managing Flash Media Server Example Use the following sample ApplicationObject tag in the Application xml file for this Application config example Application JSEngine ApplicationObj...

Page 25: ...er to terminate a client connection to the application When this method is called NetConnection onStatus is invoked on the client side with a status message of NetConnection Connection Closed The appl...

Page 26: ...ges sent and received the number of dropped messages the number of clients connected to the application instance and the number of clients who have disconnected from the application instance Example T...

Page 27: ...e application hostname Application name Availability Flash Communication Server MX 1 0 Usage application name Description Property read only contains the name of the Flash Media Server application ins...

Page 28: ...vailability Flash Communication Server MX 1 0 Usage application onAppStop function info Parameters info An information object that explains why the application stopped running See Server Side Informat...

Page 29: ...users that the application is exiting Example The following example defines a function to perform the shutdown operations on the application The function is then assigned to the event handler so that...

Page 30: ...r reject the connection For example you can perform external authentication by making a NetConnection call in your application onConnect event handler to an application server and having the reply han...

Page 31: ...dated You can use the application onConnect event in server side scripts to perform authentication All the information required for authentication should be sent to the server by the client as paramet...

Page 32: ...N Insert code here to call methods that do authentication The following code accepts the connection by returning true return true The following example verifies that the user has sent the password XXX...

Page 33: ...ability Flash Media Server with communication components only Usage application onConnectAccept function clientObj p1 pN Parameters clientObj A Client object the client connecting to the application p...

Page 34: ...n nc new NetConnection nc connect rtmp test jlopes nc onStatus function info trace info code nc doSomething function trace doSomething called The following example is server side code you can include...

Page 35: ...communication components are used that is when the components asc script is loaded into your server side script when NetConnection connect is called from the client side and a client fails to connect...

Page 36: ...d components asc load components asc application onConnect function client username trace onConnect called gFrameworkFC getClientGlobals client username username if username hacker application rejectC...

Page 37: ...y other users of this event This event handler is optional Example The following example uses an anonymous function and assigns it to the application onDisconnect event handler This code should be pla...

Page 38: ...is invoked You can also define a function that gives users specific feedback about the type of error that occurred appInstance onStatus function infoObject trace An application error occurred Applica...

Page 39: ...defined in the class Constructor functions should be used to initialize properties and methods they should not be used for executing server code Constructor functions are called automatically when me...

Page 40: ...reen 0 this blue 0 Color prototype getRed function return this red Color prototype getGreen function return this green Color prototype getBlue function return this blue Color prototype setRed function...

Page 41: ...parameter The server calls this method on the object specified by the proxyConnection parameter if proxyMethodName is different from the method specified by the methodName parameter Returns A value t...

Page 42: ...type that is sent to the client explaining the reason for rejection The errObj object is available in client side scripts as the application property of the information object that is passed to the a...

Page 43: ...This requirement exists only when you use components Example In the following example the client specified by client1 is rejected and provided with the error message contained in err message The messa...

Page 44: ...m and the server version information Example The following example checks the server property against a string before executing the code in the if statement if application server Flash Media Server Wi...

Page 45: ...nnected and Application onDisconnect is called for each client Calls made after calling shutdown may not execute Example In the following example the client specified by client1 is rejected and provid...

Page 46: ...le creates a function named callback and passes it to the setInterval method which is called every 1000 milliseconds and outputs the message interval called The setInterval method returns a unique ide...

Page 47: ...l from the client side script You can also call any methods you define in the server side script directly from the Client class instance in the server side script If all instances of the Client class...

Page 48: ...lass return this writeAccess function Client_createUniqueID var ipStr this ip The ip property is already built in to the client class var uniqueID re123mn You would need to write code in the above lin...

Page 49: ...h for the connection Property Description Client agent Read only the version and platform of the Flash client Client ip Read only the IP address of the Flash client Client protocol Read only the proto...

Page 50: ...owing example checks the agent property against the string WIN and executes different code depending on whether they match This code is written in an onConnect function function onConnect newClient na...

Page 51: ...rence to another ActionScript object These parameters are passed to the methodName parameter when the method executes on the Flash client If you use these optional parameters you must pass in some val...

Page 52: ...on Server MX 1 0 Usage function clientCommand p1 pN Parameters p1 pN Optional parameters passed to the command message handler if the message contains parameters you defined These parameters are the A...

Page 53: ...e sum method can also be called on the server side as shown here newClient sum The following example creates two functions that you can call from either a client side or server side script application...

Page 54: ...indicates a server to client direction Returns An integer indicating bytes per second Description Method returns the maximum bandwidth that the client or the server can use for this connection Use the...

Page 55: ...spond to a ping message Example The following example uses Client getStats to output a new client s statisitics application onConnect newClient stats newClient getStats trace Total bytes received stat...

Page 56: ...ent ping Availability Flash Communication Server MX 1 0 Usage clientObject ping Description Method sends a ping message to the client and waits for a response If the client responds the method returns...

Page 57: ...l rtmps RTMP over an SSL connection For more information about the HTTP tunneling feature in Flash Communication Server MX 1 0 see the NetConnection connect entry in the Client Side ActionScript Langu...

Page 58: ...ssible for example myMedia mp3s Similarly any files or directories in the myMedia mp3s directory are also accessible and so on Clients with read access to a directory that contains streams can play st...

Page 59: ...Availability Flash Communication Server MX 1 0 Usage Client __resolve function propName Parameters propName The name of an undefined property Returns The value of the undefined property which is speci...

Page 60: ...iption Property read only a Boolean value that indicates whether an Internet connection is secure true or not false See also NetConnection connect Client setBandwidthLimit Availability Flash Communica...

Page 61: ...to the onConnect function application onConnect function newClient serverToClient clientToServer newClient setBandwidthLimit serverToClient clientToServer application acceptConnection newClient Clien...

Page 62: ...to directories containing application resources list directories in a string delimited by semicolons By default all clients have full write access and the writeAccess property is set to slash For exa...

Page 63: ...on instance is running The server administrator can set up the sandbox for all applications within a virtual host and can provide additional control to individual applications if required The followin...

Page 64: ...applications VirtualDirectory FileObject JSEngine This example specifies two additional directory mappings in addition to the default application directory Any path specified with videos xyz vacation...

Page 65: ...string File readAll Reads the file and returns an array with an element for each line of the file File readByte Reads the next byte from the file and returns the numeric value of the next byte or 1 i...

Page 66: ...ctory exists true or not false File isDirectory Read only a Boolean value indicating whether the file is a directory true or not false File isFile Read only a Boolean value indicating whether the file...

Page 67: ...th is invalid the name property of the object is set to an empty string and no file operation can be performed Returns A File object if successful otherwise null Description Constructor to create an i...

Page 68: ...whether a file can be read true or not false File canReplace Availability Flash Media Server 2 Usage fileObject canReplace Description Property read only a Boolean value indicating whether a file was...

Page 69: ...ot false Description Method closes the file Returns false if the file is not open This method is called automatically on an open File object when the object is out of scope Example The following code...

Page 70: ...s and the method returns false Returns A Boolean value indicating whether the file as copied successfully true or not false Description Method copies a file to a different location or copies it to the...

Page 71: ...end of file true or not false If the file is closed the method returns true Example The following while statement lets you insert code that executes until the file pointer is at the end of a file whil...

Page 72: ...f statement lets you insert code that executes if myFileObj flushes successfully if myFileObj flush Do something here File isDirectory Availability Flash Media Server 2 Usage fileObject isDirectory De...

Page 73: ...leObject isFile Description Property read only a Boolean value indicating whether a file is a data file true or not false File isOpen Availability Flash Media Server 2 Usage fileObject isOpen Descript...

Page 74: ...Object list filter Parameters filter A Function object that determines the files in the returned array If the function returns true when a file s name is passed to it as a parameter the file is added...

Page 75: ...irectory Example The following example creates a logs directory in the myFileObject instance if myFileObject mkdir logs Do something if a logs directory is created successfully File mode Availability...

Page 76: ...y Opens the file for binary access utf8 Opens the file for UTF 8 access mode A string indicating the mode in which to open the file The following modes are valid and can be combined modes are case sen...

Page 77: ...tes when a text file is opened in read mode if myFileObject open text read Do something here File position Availability Flash Media Server 2 Usage fileObject position Description Property the current...

Page 78: ...e and a byte if myFileObject open text read strVal myFileObject read 100 strLine myFileObject readln strChar myFileObject readByte See also File readAll File readByte File readln File readAll Availabi...

Page 79: ...fails if file is not opened in binary mode See also File read File readAll File readln File readln Availability Flash Media Server 2 Usage fileObject readln Parameters None Returns A string Descripti...

Page 80: ...ry was removed successfully true or not false Description Method removes the file or directory specified to by the File object The method returns false if the file is open the path points to a root fo...

Page 81: ...se Description Method moves or renames a file The operation fails if the file is open or the directory points to the root directory Example The following code lets you execute code when myFileObject i...

Page 82: ...e seek call is successful the code in the if statement runs if fileObj seek 10 1 Do something here File toString Availability Flash Media Server 2 Usage fileObject toString Parameters None Returns A s...

Page 83: ...am0 param1 paramN Parameters param0 param1 paramN Parameters to write to the file Returns A Boolean value indicating whether the write was successful true or not false Description Method writes data t...

Page 84: ...Method takes an array as a parameter and calls the File writeln method on each element in the array The file contents are buffered internally The File flush method writes the buffer to the file on dis...

Page 85: ...param0 param1 paramN Parameters param0 param1 paramN Strings to write to the file Returns A Boolean value indicating whether the write was successful true or not false Description Method writes data...

Page 86: ...two script execution modes secure and normal In secure mode only the secure asc file if it exists is loaded and evaluated no other application scripts are loaded Also the global getGlobal and protectO...

Page 87: ...d is useful for loading ActionScript libraries Example The following example loads the myLoadedFile as file load myLoadedFile as LoadVars class Availability Flash Media Server 2 The LoadVars class let...

Page 88: ...POST actions LoadVars decode Converts the query string to properties of the specified LoadVars object LoadVars getBytesLoaded Returns the number of bytes loaded from the last or current LoadVars load...

Page 89: ...scription LoadVars contentType The MIME type sent to the server when you call the LoadVars send or LoadVars sendAndLoad method LoadVars loaded A Boolean value that indicates whether a LoadVars load or...

Page 90: ...er name each successive value will replace the value set in the previous call The following standard HTTP headers cannot be added or changed with this method Accept Ranges Age Allow Allowed Connection...

Page 91: ...rs contentType Description Property the MIME type that is sent to the server when you call the LoadVars send or LoadVars sendAndLoad method The default is application x www urlform encoded Example The...

Page 92: ...e three variables Create a new LoadVars object var my_lv new LoadVars Convert the variable string to properties my_lv decode name Mort score 250000 trace my_lv toString Iterate over properties in my_l...

Page 93: ...s initiated but the server did not transmit an HTTP content length Description Method returns the total number of bytes loaded into an object during all LoadVars load or LoadVars sendAndLoad method ca...

Page 94: ...aded variables are overwritten The downloaded data must be in the MIME content type and be application x www urlform encoded The LoadVars load method call is asynchronous Example The following code de...

Page 95: ...ded from the server or when an error occurs while data is downloading from a server This handler is invoked before the data is parsed and can be used to call a custom parsing routine instead of the on...

Page 96: ...he requested URI HTTP status codes can be found in sections 10 4 and 10 5 of the HTTP specification Description Event handler invoked when Flash Media Server receives an HTTP status code from the serv...

Page 97: ...Vars onHTTPStatus function httpStatus this httpStatus httpStatus if httpStatus 100 this httpStatusType flashError else if httpStatus 200 this httpStatusType informational else if httpStatus 300 this h...

Page 98: ...ver the success parameter is false If the success parameter is true the loadVarsObject is populated with variables downloaded by the LoadVars load or LoadVars sendAndLoad operation and these variables...

Page 99: ...object to the specified URL All enumerable variables in the myLoadVars object are concatenated into a string that is posted to the URL using the HTTP POST method The MIME content type sent in the HTT...

Page 100: ...dVars load See also LoadVars send LoadVars toString Availability Flash Media Server 2 Usage myLoadVars toString Parameters None Returns A string Description Method returns a string containing all enum...

Page 101: ...of the following if not set explicitly the level defaults to Log BRIEF Log BRIEF Primary life cycle event and error notifications are received Log VERBOSE All life cycle event and error notifications...

Page 102: ...application server another Flash Media Server or another Flash Media Server application instance on the same server You can use NetConnection objects to create powerful applications for example you ca...

Page 103: ...dHeader Adds a context header NetConnection call Invokes a method or operation on a remote server NetConnection close Closes a server connection NetConnection connect Connects to an application server...

Page 104: ...ActionScript object Returns Nothing Description Method adds a context header to the AMF packet structure This header is sent with every future AMF packet If you call NetConnection addHeader using the...

Page 105: ...reference to another ActionScript object These parameters are passed to the methodName specified above when the method is executed on the remote application server Returns For RTMP connections return...

Page 106: ...This allows Flash Media Server to connect to an application server and then invoke the quote method The Java adaptor dispatches the call by using the identifier to the left of the dot as the class nam...

Page 107: ...lue of true for success false otherwise For AMF connections to application servers true is always returned Description Method connects to an application server or another Flash Media Server The host U...

Page 108: ...te Similarly a regular RTMP connection to port 443 fails because the server tries to perform an SSL handshake that the client cannot complete You can determine whether a connection to the server is ov...

Page 109: ...et connection Escaping URIs is especially important when creating a debugging connection because there are special characters in the debugging property that must be appended to the URI Use the followi...

Page 110: ...erver It s a good idea to check this property value in an onStatus callback function This property is always true for AMF connections to application servers Example The following example uses NetConne...

Page 111: ...event handler to check for connectivity Example The following example defines a function for the onStatus handler that outputs messages to indicate whether the NetConnection was successful nc new Net...

Page 112: ...ectObject functions are only available in secure mode These are very powerful because they provide complete access to the script execution environment and let you create system objects Once the secure...

Page 113: ...he global object var global getGlobal Now protect our sysobj and make it available as system globally Also set its attributes so that it is read only and not deletable global system protectObject syso...

Page 114: ...akes a property permanent nondeletable if true or deletable if false a null value leaves this attribute unchanged Any attempt to delete a permanent property by calling delete obj prop is ignored Descr...

Page 115: ...r method at a specified time interval until the clearInterval method is called This method allows a server side script to run a generic routine The setInterval method returns a unique ID that you can...

Page 116: ...objects as real time data transfer devices The following list describes common ways to use shared objects in server side ActionScript Storing and sharing data on a server A shared object can store da...

Page 117: ...application s state Every RSO is identified by a unique name and contains a list of name value pairs called properties like any other ActionScript object A name must be a unique string and a value ca...

Page 118: ...ect instances that are marked dirty SharedObject flush Saves the current state of a persistent shared object SharedObject get Static creates a shared object or returns a reference to an existing share...

Page 119: ...persistent shared objects to be stored true or not false SharedObject isDirty A Boolean value indicating whether the persistent SharedObject has been modified since the last time it was stored true o...

Page 120: ...O clear Parameters None Returns Returns true if successful false otherwise Description Method deletes all the properties of a single shared object and sends a clear event to all clients that subscribe...

Page 121: ...proxy a shared object any longer Example In the following example mySO is attached as a reference to shared object foo When you call mySO close you detach the reference mySO from the shared object foo...

Page 122: ...dObject commit SharedObject flush Availability Flash Communication Server MX 1 0 Usage mySO flush Parameters None Returns A Boolean value of true if successful false otherwise Description Method saves...

Page 123: ...onnection object that is used as the netConnection parameter does not need to be connected when you call SharedObject get The server connects to the remote shared object when the NetConnection state c...

Page 124: ...m connected to disconnected the proxied shared object is set to idle and any messages received from subscribers are discarded The NetConnection onStatus handler is called when a connection is lost You...

Page 125: ...e master and gives the client a reference to this shared object The following code is in the main asc file application appStart function nc new NetConnection nc connect rtmp master_server master_insta...

Page 126: ...y of strings that contain all the property names of a shared object Description Method enumerates all the property names for a given shared object Example The following example calls getPropertyNames...

Page 127: ...andler onBroadcastMsg in the Usage example above the handler is invoked when a shared object receives a broadcast message with the same name You must define a function object and assign it to the even...

Page 128: ...stores shared objects with an isDirty property that is true This property is always false for non persistent shared objects Example The following example saves the so shared object if it has been chan...

Page 129: ...aredObject lock method on proxied shared objects Example The following example locks the myShared shared object executes the code that is to be inserted and then unlocks the object var myShared Shared...

Page 130: ...ht not be sent in the same order as they were in the code Use the mark method when you want to execute code after all the properties in a set have been updated If an application calls the lock method...

Page 131: ...ow x onActChange function str Shared Object has been updated can look at the account property now SharedObject name Availability Flash Communication Server MX 1 0 Usage mySO name Description Property...

Page 132: ...erties of a shared object that have changed since the last time the onSync handler was called The notifications for proxied shared objects are different than for shared objects that are owned by the l...

Page 133: ...red object or if another subscriber deletes a property clear All the properties of a shared object are deleted This can happen when the server s shared object is out of sync with the master shared obj...

Page 134: ...an array of objects containing information about successfully of unsuccessfully changed properties from the last time onSync was called so onSync function list for var i 0 i list length i switch list...

Page 135: ...rver MX 1 0 Usage mySO resyncDepth Description Property an integer that indicates when the deleted properties of a shared object should be permanently deleted You can use this property in a server sid...

Page 136: ...O if the revision number difference is greater than 10 mySo SharedObject get foo mySo resyncDepth 10 SharedObject send Availability Flash Communication Server MX 1 0 Usage mySO send methodName p1 pN P...

Page 137: ...nnect connection x doSomething function str Process the str object SharedObject setProperty Availability Flash Communication Server MX 1 0 Usage mySO setProperty name value Parameters name The name of...

Page 138: ...thod is called The SharedObject onSync handler on the client side is invoked when the local copy of the shared object is updated Example The following example uses the SharedObject setProperty method...

Page 139: ...k count 0 or greater if successful 1 otherwise For proxied shared objects this method always returns 1 Description Method unlocks a shared object instance It causes the script to relinquish exclusive...

Page 140: ...ility Flash Media Server 2 The SOAPCall class is the object type that is returned from all web service calls These objects are most typically constructed automatically when a WSDL is parsed and a stub...

Page 141: ...on Event handler invoked when a method has failed and returned an error SOAPCall onResult Availability Flash Media Server 2 Usage mySOAPCall onResult result Parameters result The decoded ActionScript...

Page 142: ...class Availability Flash Media Server 2 The SOAPFault class is the object type of the error object returned to WebService onFault and SOAPCall onFault functions This object is returned as the result...

Page 143: ...e mySOAPFault faultactor Description Property a string indicating the source of the fault This property is optional if an intermediary is not involved SOAPFault faultcode Availability Flash Media Serv...

Page 144: ...event stockService onLoad function wsdl wsdlField text wsdl If the wsdl fails to load the onFault event is fired stockService onFault function fault wsdlField text fault faultstring Stream class Avail...

Page 145: ...lass Property read only Description Stream bufferTime Indicates how long to buffer messages before a stream is played Stream name The unique name of a live stream Stream syncWrite A Boolean value that...

Page 146: ...ly To set this property use Stream setBuffertime A message is data that is sent back and forth between Flash Media Server and Flash Player The data is divided into small packets messages and each mess...

Page 147: ...successfully if info code NetStream Clear Failed trace Failed to clear stream s clear See also Stream get Stream flush Availability Flash Media Server 2 Usage myStream flush Parameters None Returns A...

Page 148: ...plication myStream send test hello world application myStream flush Stream get Availability Flash Communication Server MX 1 0 Usage myStream get name Parameters name The name of the stream instance to...

Page 149: ...not associated with a client but connects to a stream on the server you may need to specify a virtual key to identify the correct stream For more information about keys see Client virtualKey This para...

Page 150: ...ssociated with it function getStreamName myStream return myStream name Stream onStatus Availability Flash Communication Server MX 1 0 Usage myStream onStatus function infoObject Parameters infoObject...

Page 151: ...eloping Media Applications startTime The start time of the stream playback in seconds If no value is specified it is set to 2 If startTime is 2 the server tries to play a live stream with the name spe...

Page 152: ...ich the messages were originally recorded the default behavior For more information on Flash Media Server logging see TechNote 16464 on the Macromedia Flash Media Server Support Center at www macromed...

Page 153: ...r calls a play method on the same stream In general if any recorded streams are included in a server playlist you cannot play the server stream as a live stream If you require a value to begin a strea...

Page 154: ...is used as a hub to switch between live streams and recorded streams Set up the server stream application myStream Stream get foo if application myStream This server stream plays Live1 Record1 and Liv...

Page 155: ...1 In the following example data messages in the recorded stream file log flv are returned all at once rather than at the intervals which they were originally recorded application myStream Stream get d...

Page 156: ...name of a method relative to the subscribing Stream object For example if handlerName is doSomething the doSomething method at the stream level is invoked with all the p1 pN parameters Unlike the met...

Page 157: ...MX 1 0 Usage myStream setBufferTime Description Method increases the message queue length When you play a stream from a remote server the Stream setBufferTime method sends a message to the remote ser...

Page 158: ...Path method to dynamically serve Flash Player 8 clients a better version of a video stream When Flash Player requests a stream from Flash Media Server the Flash Player version determines the server si...

Page 159: ...streams To set up several virtual directories for different Flash Player versions use the same virtual path with different physical directories for each Streams tag as shown in the following example...

Page 160: ...e them in different physical directories and use the VirtualDirectory section and VirtualKeys section of the vhost xml file to direct clients to the appropriate stream Because the Stream size method i...

Page 161: ...shed to the FLV file immediately It is highly recommended that user should only set syncWrite to true in a stream that contains only data Synchronization problems might occur when syncWrite is set to...

Page 162: ...ting a file The trace function is similar to the alert function in JavaScript WebService class Availability Flash Media Server 2 Description You can use the WebService class to create and access a WSD...

Page 163: ...llback callback stockService doCompanyInfo anyuser anypassword MACR NOTE callback is undefined if the service itself is not created and service onFault is also invoked 7 Handle either the output or th...

Page 164: ...hods Example The following example prepares the WSDL location and passes it to the WebService constructor to create a new WebService object stockService var wsdlURI http www flash db com services ws c...

Page 165: ...tockService onLoad function wsdl wsdlField text wsdl If the wsdl fails to load the onFault event is fired stockService onFault function fault wsdlField text fault faultstring WebService onLoad Availab...

Page 166: ...XML class lets you load parse send build and manipulate XML document trees You must use the constructor new XML to create an XML object before calling any method of the XML class An XML document is r...

Page 167: ...the specified XML object has loaded XML localName Read only the local name portion of the XML node s name XML namespaceURI Read only if the XML node has a prefix namespaceURI is the value of the xmln...

Page 168: ...turns the namespace URI that is associated with the specified prefix for the node XML getPrefixForNamespace Returns the prefix that is associated with the specified namespace URI for the node XML hasC...

Page 169: ...from the server or when an error occurs downloading XML text from a server XML onHTTPStatus Invoked when Flash Media Server receives an HTTP status code from the server This handler lets you capture...

Page 170: ...with the resulting XML document tree var other_xml new XML state name California city San Francisco city state See also XML createElement XML createTextNode XML addRequestHeader Availability Flash Me...

Page 171: ...y Authenticate Proxy Authorization Public Range Retry After Server TE Trailer Transfer Encoding Upgrade URI Vary Via Warning and WWW Authenticate Example The following example adds a custom HTTP heade...

Page 172: ...nt named doc1 3 Shows how to move a node using the appendChild method by moving the root node from doc1 to doc2 4 Clones the root node from doc2 and appends it to doc1 5 Creates a new node and appends...

Page 173: ...t attribute s value by using the color as the key index as shown in the following code var myColor doc firstChild attributes color Example The following example shows the XML attribute names Create a...

Page 174: ...ample The following example shows how to use the XML childNodes property to return an array of child nodes Create a new XML document var doc new XML Create a root node var rootNode doc createElement r...

Page 175: ...rns a new XMLNode object of the same type name management console value and attributes as the specified XML object If deep is set to true all child nodes are recursively cloned resulting in an exact c...

Page 176: ...odes as children of rootNode rootNode appendChild oldest rootNode appendChild middle rootNode appendChild youngest Create a copy of the middle node using cloneNode var middle2 middle cloneNode false I...

Page 177: ...content type used for most HTML forms Example The following example creates a new XML document and checks its default content type Create a new XML document var doc new XML Trace the default content...

Page 178: ...eTextNode method are the constructor methods for creating nodes for an XML object Example The following example creates three XMLNode objects using the createElement method Create an XML document var...

Page 179: ...nodes for an XML object Example The following example creates two XML text nodes using the createTextNode method and places them into existing XML nodes Create an XML document var doc new XML Create...

Page 180: ...n XMLNode object The ActionScript XML parser is not a validating parser The DOCTYPE declaration is read by the parser and stored in the XML docTypeDecl property but no DTD validation is performed If n...

Page 181: ...owing example shows how to use XML firstChild to loop through a node s child nodes Create a new XML document var doc new XML Create a root node var rootNode doc createElement rootNode Create three chi...

Page 182: ...loaded Description Method returns the number of bytes loaded streamed for the XML document You can compare the value of getBytesLoaded with the value of getBytesTotal to determine what percentage of...

Page 183: ...he namespace that is associated with the specified prefix Description Method returns the namespace URI that is associated with the specified prefix for the node To determine the URI getPrefixForNamesp...

Page 184: ...h Media Server 2 Usage my_xml getPrefixForNamespace nsURI Parameters nsURI A String the namespace URI for which the method returns the associated prefix Returns A String the prefix associated with the...

Page 185: ...o defines a namespace URI http www example com child but does not assign it to a prefix Calling this method on the defined but unassigned namespace URI returns an empty string function createXML var s...

Page 186: ...L packet If the root node has child nodes the code loops over each child node to display the name and value of the node var my_xml new XML login username hank username password rudolph password login...

Page 187: ...e 1 You can set the ignoreWhite property for individual XML objects as shown in the following code my_xml ignoreWhite true Usage 2 You can set the default ignoreWhite property for XML objects as shown...

Page 188: ...o the flooring object flooring load flooring xml output line breaks added for clarity house kitchen ceramic tile kitchen bathroom linoleum bathroom foyer house If you change the setting of flooring ig...

Page 189: ...llowing example is an excerpt from the XML cloneNode example Create a copy of the middle node using cloneNode var middle2 middle cloneNode false Insert the clone node into rootNode between the middle...

Page 190: ...oc createElement oldest var middle doc createElement middle var youngest doc createElement youngest Add the rootNode as the root of the XML document tree doc appendChild rootNode Add each of the child...

Page 191: ...lastChild aNode null aNode aNode previousSibling trace aNode output youngest middle oldest See also XML appendChild XML insertBefore XML removeNode XML load Availability Flash Media Server 2 Usage my...

Page 192: ...object previously contained any XML trees they are discarded You can define a custom function that executes when the onLoad event handler of the XML object is invoked Example The following simple exam...

Page 193: ...true my_xml onLoad function success trace success success trace loaded my_xml loaded trace status my_xml status my_xml load http www flash mx com mm problems products xml Information writes to the lo...

Page 194: ...ame Example This example uses a SWF file and an XML file located in the same directory The XML file named SoapSample xml contains the following xml version 1 0 soap Envelope xmlns soap http www w3 org...

Page 195: ...efault namespace the value of the namespaceURI property is the value of the default namespace If there is no default namespace the namespaceURI property for that node is an empty string You can use th...

Page 196: ...org 2001 12 soap envelope var soapBodyNode xmlDoc childNodes 0 childNodes 0 trace soap Envelope namespaceURI soapBodyNode namespaceURI Output http www w3 org 2001 12 soap envelope The following examp...

Page 197: ...that references the next sibling in the parent node s child list This property is null if the node does not have a next sibling node This property cannot be used to manipulate child nodes use the app...

Page 198: ...g If the XML object is a text node nodeType 3 nodeName is null Example The following example creates an element node and a text node and checks the node name of each Create an XML document var doc new...

Page 199: ...extSibling if aNode nodeType 1 trace aNode nodeName t aNode firstChild nodeValue The following node names appear username hank password rudolph See also XML nodeType XML nodeType Availability Flash Me...

Page 200: ...L tree doc appendChild myNode Create an XML text node using createTextNode var myTextNode doc createTextNode textNode Place the new node into the XML tree myNode appendChild myTextNode trace myNode no...

Page 201: ...and read only Example The following example creates an element node and a text node and checks the node value of each Create an XML document var doc new XML Create an XML node using createElement var...

Page 202: ...var i 0 i my_xml firstChild childNodes length i trace t my_xml firstChild childNodes i firstChild nodeValue The following information is written to the log file using firstChild morton good evil using...

Page 203: ...XML onData event handler with custom behavior but XML onLoad is not called unless you call it in your XML onData implementation Example The following example shows what the XML onData event handler lo...

Page 204: ...communicate with the server the default value of 0 is passed to your ActionScript code Example The following example shows how to use onHTTPStatus to help with debugging The example collects HTTP sta...

Page 205: ...lue that is true if the XML object successfully loads with a XML load or XML sendAndLoad operation false otherwise Returns Nothing Description Event handler invoked by Flash Media Server when an XML d...

Page 206: ...Reply_xml onLoad function success if success if myLoginReply_xml firstChild nodeName packet myLoginReply_xml firstChild attributes success true gotoAndStop loggedIn else gotoAndStop loginFailed else g...

Page 207: ...de parentNode nodeName trace contents of the parent node are n targetNode parentNode output line breaks added for clarity the parent node of username is login contents of the parent node are login use...

Page 208: ...tr trace my1_xml firstChild attributes name output California Defining the XML source using the XML parseXML method var my2_xml new XML my2_xml parseXML xml_str trace my2_xml firstChild attributes nam...

Page 209: ...noreWhite true xmlDoc load SoapSample xml xmlDoc onLoad function success var tempNode xmlDoc childNodes 0 childNodes 0 childNodes 0 trace w GetTemperature prefix tempNode prefix Output w var soapEnvNo...

Page 210: ...rootNode lastChild aNode null aNode aNode previousSibling trace aNode See also XML appendChild XML insertBefore XML removeNode XML removeNode Availability Flash Media Server 2 Usage my_xml removeNode...

Page 211: ...California city San Francisco city state after XML removeNode state name California XML send Availability Flash Media Server 2 Usage my_xml send url fileObj Parameters url A string the destination URL...

Page 212: ...com mm highscore cfm myFile See also XML sendAndLoad XML sendAndLoad Media Server 2 Usage my_xml sendAndLoad url targetXMLobject Parameters url A string the destination URL for the specified XML obje...

Page 213: ...ad method transmits an XML element that contains the user s name and password and uses an onLoad handler to process the reply from the server var login_str login username username_txt text password pa...

Page 214: ...omment was not properly terminated 6 An XML element was malformed 7 Out of memory 8 An attribute value was not properly terminated 9 A start tag was not matched with an end tag 10 An end tag was encou...

Page 215: ...ut of memory break case 8 errorMessage An attribute value was not properly terminated break case 9 errorMessage A start tag was not matched with an end tag break case 10 errorMessage An end tag was en...

Page 216: ...claration stored in the XML xmlDecl property followed by the document s DOCTYPE declaration stored in the XML docTypeDecl property followed by the text representation of all XML nodes in the object Th...

Page 217: ...e property is set to undefined XML The XML toString method outputs the contents of the XML xmlDecl property before any other text in the XML object If the XML xmlDecl property contains the undefined t...

Page 218: ...tion Each XML message is a complete XML document terminated by a zero 0 byte An unlimited number of XML messages can be sent and received over a single XMLSocket connection The following restriction a...

Page 219: ...or a new XMLStreams object stream The XMLSocket and XMLStreams objects are not initially connected to any server You must call XMLSocket connect to connect the object to a server Method Description X...

Page 220: ...XMLStreams object var stream new XMLSocket stream XMLSocket close Availability Flash Media Server 2 Usage myXMLSocket close Parameters None Returns Nothing Description Method closes the connection spe...

Page 221: ...ng on whether a connection is successfully established If you don t know the port number of the Internet host computer contact your network administrator If you specify null for the host parameter the...

Page 222: ...ee also XMLSocket onConnect XMLSocket onClose Availability Flash Media Server 2 Usage myXMLSocket onClose function Parameters None Returns Nothing Description Event handler invoked only when an open c...

Page 223: ...e indicating whether a socket connection is successfully established true or false Returns Nothing Description Event handler invoked by Flash Media Server when a connection request initiated through X...

Page 224: ...y the server Returns Nothing Description Event handler invoked when a message has been downloaded from the server terminated by a zero 0 byte You can override XMLSocket onData to intercept the data se...

Page 225: ...nlimited number of XML documents between the client and the server Each document is terminated with a zero 0 byte When Flash Media Server receives the zero byte it parses all the XML received since th...

Page 226: ...followed by a zero 0 byte If object is an XML object the string is the XML textual representation of the XML object The send operation is asynchronous it returns immediately but the data may be trans...

Page 227: ...stream tag contains fragments of XML content and concludes with a stream stream closing tag The onData event is invoked and returns complete XML tags whenever it receives them The stream stream tag cl...

Page 228: ...228 Server Side ActionScript Language Reference...

Page 229: ...u pass to the function You need to place this code in the main asc file only once function showStatusForClass for var i 0 i arguments length i arguments i prototype onStatus function infoObj trace inf...

Page 230: ...re set filename name of the offending ASC file lineno line number where the error occurred linebuf source code of the offending line Application Resource LowMemory Warning The ActionScript engine is l...

Page 231: ...shut down NetConnection call BadVersion Error The URI specified in the NetConnection connect method did not specify rtmp as the protocol rtmp must be specified when connecting to Flash Communication...

Page 232: ...ss Status An attempt to unpublish was successful NetStream Record Start Status Recording was started NetStream Record NoAccess Error An attempt was made to record a read only stream NetStream Record S...

Page 233: ...s useful for multiple plays The details property shows the name of the stream when switching from one element in the playlist to the next element By default outgoing messages are monitored at 5 second...

Page 234: ...234 Server Side Information Objects...

Reviews: