Open Source Platform
for interconnected virtual worlds

Content Scripting Python Flash Animation

From RexWiki

Usage

  • Upload an swf file to the server from 'File' menu -> 'Upload Flash Animation'.
  • Make sure the swf file can be played back using Adobe Flash Player version 9.
  • Use the example script below to launch the flash animation from Python script when an event occurs. Remember to change the flash animation name and the position of the flash control on the client's screen.
  • While the animation is playing back on the client, the client controls are disabled and only the animation is visible.
  • It's good form to set timeToDeath parameter in the sample script to the length of the flash animation, even if C++ callbacks are used in the animation.


Creating The Flash Animation

ExternalInterface.call("exit")
  • You can use the above C++ callback function to exit the flash animation on the client.
  • You should call 'exit' at the end of the flash animation, looped/continuous flash animations are not recommended/supported.
  • It is also recommended to create 'Exit' button that calls the 'exit' function when clicked.


Sample Script

The sample script below demonstrates how to launch flash animation from server:

import rxactor
import rxavatar
import sys
import clr

asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3

import random
import math


class FlashAnim(rxactor.Actor):
    def GetScriptClassName():
        return "sampleflashanimation.FlashAnim"

    def EventCreated(self):
        super(self.__class__,self).EventCreated()
        print "sampleflashanimation.FlashAnim EventCreated"

    def EventTouch(self,vAvatar):
        vAvatar.rexPlayFlashAnimationByUUID("42afa922-0e8a-4a11-bfce-48d5d56d249e",0,0,1,1,36)
def rexPlayFlashAnimationByUUID(self,assetId,left,top,right,bottom, timeToDeath):

Where:

  • assetId: LLUUID of the swf asset to play or
  • left: left border of the rectangle
  • top: top border of the rectangle
  • right: right border of the rectangle
  • bottom: bottom border of the rectangle
  • timeToDeath: time in seconds from start of animation playback until the flash control is destroyed

You must use the LLUUID of the Flash animation asset because nnames not supported anymore. Left, top, right and bottom specifies a rectangle in relative coordinates on the client screen where the flash animation should be displayed.