RMXP Flash Player and Add-ons [Updated:13/5/09]

Flash Player for RMXP Version: 0.3Mod
By: 灼眼的夏娜 Moded by Dahrkael

Updated! Added new add-on: animated Scene_Title
Updated! Added new add-on: Scene_IntroFlash
Updated! Added flash10a.ocx for better compatibility with all flash files.

Introduction

With this script you can play a flash file from a call in an event or in the menu or wherever you want.

Features


[*]Reproduces flash files
[*]The flash is played in the game, no on like the other flash script.
[*]Support interactive flash (need RGSS knownledge)
[*]Support transparent flash.
[*]Can play flash everywhere

Screenshots

Not necessary i think Oo

Scripts

Main Script

  1. #==============================================================================#
  2. #                                                                                                 Version 0.3   #
  3. #                                     RPG Maker XP Flash Player                                          #
  4. #                                                                                                                     #
  5. #   Author: 灼眼的夏娜                               Updated by: Dark_Wolf_Warrior/Dahrkael #
  6. #                                                                                                                     #
  7. #   How to Use:                                                                                                 #
  8. #                                                         Graphics.freeze                                     #
  9. #   1. Go to Main Script and add ---->   $flash = Play.new                                  #
  10. #                                                         $scene = Scene_Title.new                        #
  11. #                                                                                                                     #
  12. #   2. Copy the .dll and the .ocx to the game folder                                          #
  13. #                                                                                                                     #
  14. #   3. Make a folder called "Flash" in the folder "Graphics" -> Graphics/Flash/ #
  15. #                                                                                                                     #
  16. #   4. To play a flash file use:                                                                        #
  17. #      $flash.play("file.swf", button)                                                                #
  18. #                                                                                                                     #
  19. #      button can be 0 or 1, if 1 you can skip the flash using "Enter"                #
  20. #                                                                                                                     #
  21. #                                                                                                                     #
  22. #                                                                                                                     #
  23. #   Interactive flashes requires RGSS knownledge to make they work                     #
  24. #                                                                                                                     #
  25. #   Original Keyb module by HoundNinja                                                               #
  26. #                                                                                                                     #
  27. #==============================================================================#
  28.  
  29.  
  30.  
  31. class String
  32.  
  33.   CP_ACP = 0
  34.   CP_UTF8 = 65001
  35.  
  36.   def u2s
  37.      m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  38.      w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  39.     
  40.      len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
  41.      buf = "\0" * (len*2)
  42.      m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
  43.     
  44.      len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
  45.      ret = "\0" * len
  46.      w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
  47.     
  48.      return ret
  49.   end
  50.  
  51.   def s2u
  52.      m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  53.      w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  54.  
  55.      len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
  56.      buf = "\0" * (len*2)
  57.      m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
  58.  
  59.      len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  60.      ret = "\0" * len
  61.      w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  62.        
  63.      return ret
  64.   end
  65.  
  66.   def s2u!
  67.      self[0, length] = s2u
  68.   end   
  69.  
  70.   def u2s!
  71.      self[0, length] = u2s
  72.   end
  73.  
  74. end
  75.  
  76. class Bitmap
  77.  
  78.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  79.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  80.  
  81.   def address
  82.      buffer, ad = "xxxx", object_id * 2 + 16
  83.      RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
  84.      RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
  85.      RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  86.   end
  87.  
  88. end
  89.  
  90. class RMFlash
  91.  
  92.      API_NEW                = Win32API.new("RMFlash", "_new", "piil", "l")
  93.      API_UPDATE        = Win32API.new("RMFlash", "_update", "l", "v")
  94.      API_FREE              = Win32API.new("RMFlash", "_free", "l", "v")
  95.      API_PLAYING       = Win32API.new("RMFlash", "_is_playing", "l", "i")
  96.      API_PAUSE             = Win32API.new("RMFlash", "_pause", "l", "v")
  97.      API_RESUME        = Win32API.new("RMFlash", "_resume", "l", "v")
  98.      API_BACK              = Win32API.new("RMFlash", "_back", "l", "v")
  99.      API_REWIND        = Win32API.new("RMFlash", "_rewind", "l", "v")
  100.      API_FORWARD       = Win32API.new("RMFlash", "_forward", "l", "v")
  101.      API_CURFRAME        = Win32API.new("RMFlash", "_cur_frame", "l", "i")
  102.      API_TOTALFRAME  = Win32API.new("RMFlash", "_total_frames", "l", "i")
  103.      API_GOTOFRAME       = Win32API.new("RMFlash", "_goto_frame", "li", "v")
  104.      API_GETLOOP          = Win32API.new("RMFlash", "_get_loop", "l", "i")
  105.      API_SETLOOP          = Win32API.new("RMFlash", "_set_loop", "li", "v")
  106.      API_CLEARALL        = Win32API.new("RMFlash", "_clear_all", "v", "v")
  107.   API_VALID          = Win32API.new("RMFlash", "_valid", "l", "i")
  108.   API_SENDMSG       = Win32API.new("RMFlash", "_send_message", "liii", "l")
  109.     
  110.   CUR_PATH            = Dir.pwd
  111.  
  112.      def self.get_version
  113.  
  114.      end
  115.  
  116.      def self.clear_all
  117.            API_CLEARALL.call
  118.      end
  119.  
  120.   def self.load(name, width, height, v = nil)
  121.      new("#{CUR_PATH}/Graphics/Flash/#{name}".u2s, width, height, v)
  122.   end
  123.  
  124.   attr_reader    :valid
  125.  
  126.      def initialize(flash_name, flash_width, flash_height, viewport = nil)
  127.            @sprite = Sprite.new(viewport)
  128.            @sprite.bitmap = Bitmap.new(flash_width, flash_height)
  129.            @value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)
  130.            @loop = API_GETLOOP.call(@value) > 0
  131.      @valid = API_VALID.call(@value) > 0
  132.      end
  133.  
  134.      def viewport
  135.            @sprite.viewport
  136.      end
  137.  
  138.      def update
  139.            API_UPDATE.call(@value)
  140.      end
  141.  
  142.      def dispose
  143.            API_FREE.call(@sprite.bitmap.address)
  144.      end
  145.  
  146.      def playing?
  147.            API_PLAYING.call(@value) > 0
  148.      end
  149.  
  150.      def pause
  151.            API_PAUSE.call(@value)
  152.      end
  153.  
  154.      def resume
  155.            API_RESUME.call(@value)
  156.      end
  157.  
  158.      def back
  159.            API_BACK.call(@value)
  160.      end
  161.  
  162.      def rewind
  163.            API_REWIND.call(@value)
  164.      end
  165.  
  166.      def forward
  167.            API_FORWARD.call(@value)
  168.      end
  169.  
  170.      def current_frame
  171.            API_CURFRAME.call(@value)
  172.      end
  173.  
  174.      def total_frames
  175.            API_TOTALFRAME.call(@value)
  176.      end
  177.  
  178.      def goto_frame(goal_frame)
  179.            API_GOTOFRAME.call(@value, goal_frame)
  180.      end
  181.  
  182.      def x
  183.            @sprite.x
  184.      end
  185.  
  186.      def x=(v)
  187.            @sprite.x = v
  188.      end
  189.  
  190.      def y
  191.            @sprite.y
  192.      end
  193.  
  194.      def y=(v)
  195.            @sprite.y = v
  196.      end
  197.  
  198.      def z
  199.            @sprite.z
  200.      end
  201.  
  202.      def z=(v)
  203.            @sprite.z = v
  204.      end
  205.  
  206.      def width
  207.            @sprite.bitmap.width
  208.      end
  209.  
  210.      def height
  211.            @sprite.bitmap.height
  212.      end
  213.  
  214.      def loop?
  215.            @loop
  216.      end
  217.  
  218.      def loop=(v)
  219.            if @loop != v
  220.                  @loop = v
  221.                  API_SETLOOP.call(@value, v)
  222.            end
  223.      end
  224.  
  225.   def msg_to_flash(msg, wParam, lParam)
  226.      return API_SENDMSG.call(@value, msg, wParam, lParam)
  227.   end
  228.  
  229.   #   ä¾‹
  230.   WM_MOUSEMOVE   = 0x0200
  231.  
  232.   def make_long(a, b)
  233.      return (a & 0xffff ) | (b & 0xffff) << 16
  234.   end
  235.  
  236.   def on_mouse_move(x, y)
  237.      return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
  238.   end
  239.  
  240. end
  241.  
  242. module Kernel
  243.  
  244.   alias origin_exit exit unless method_defined? :exit
  245.  
  246.   def exit(*args)
  247.      RMFlash.clear_all
  248.      origin_exit(*args)
  249.   end
  250.  
  251. end
  252.  
  253. module Keyb
  254.   $keys = {}
  255.   $keys["Enter"] = 0x0D
  256.   GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
  257.   module_function
  258.   def trigger(rkey)
  259.      GetKeyState.call(rkey) & 0x01 == 1
  260.   end
  261. end
  262.  
  263. class Play
  264.  
  265.   def play(filename, button)
  266.      fondo = Sprite.new
  267.      fondo.bitmap = Bitmap.new(640, 480)
  268.      fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
  269.      fls = RMFlash.load(filename, 640, 480)
  270.      fls.loop = 1
  271.      fls.z = 9999
  272.      @button = button
  273.      @fr = Graphics.frame_rate
  274.      Graphics.frame_rate = 40
  275.  
  276.      while true
  277.         Graphics.update
  278.         #Input.update
  279.         fls.update
  280.         break if @button == 1 and Keyb.trigger($keys["Enter"])
  281.         break if !fls.playing?
  282.         end
  283.      fls.dispose
  284.      Graphics.frame_rate = @fr
  285.      fondo.dispose
  286.   end
  287.  
  288. end
  289.  
  290.  
Expand to see the code.


Add-ons

Animated Scene_Title with flash
  1.  
  2. #==============================================================================
  3. # ** Scene_Title with Flash Background                                                 Dahrkael
  4. #------------------------------------------------------------------------------
  5. #   You can put a picture with the title and a flash in the background.
  6. #   Requires the .dll and the .ocx
  7. #==============================================================================
  8.  
  9. class Scene_Title
  10.  
  11.   #--------------------------------------------------------------------------
  12.   # * Main Processing
  13.   #--------------------------------------------------------------------------
  14.   def main
  15.     
  16.      # Write the name of the flash file you want to use as background with the extension
  17.      # in the "/Graphics/Flash/" folder
  18.      @archivo_flash = "miku.swf"
  19.      # If battle test
  20.      if $BTEST
  21.         battle_test
  22.         return
  23.      end
  24.      # Load database
  25.      $data_actors            = load_data("Data/Actors.rxdata")
  26.      $data_classes          = load_data("Data/Classes.rxdata")
  27.      $data_skills            = load_data("Data/Skills.rxdata")
  28.      $data_items             = load_data("Data/Items.rxdata")
  29.      $data_weapons          = load_data("Data/Weapons.rxdata")
  30.      $data_armors            = load_data("Data/Armors.rxdata")
  31.      $data_enemies          = load_data("Data/Enemies.rxdata")
  32.      $data_troops            = load_data("Data/Troops.rxdata")
  33.      $data_states            = load_data("Data/States.rxdata")
  34.      $data_animations      = load_data("Data/Animations.rxdata")
  35.      $data_tilesets         = load_data("Data/Tilesets.rxdata")
  36.      $data_common_events = load_data("Data/CommonEvents.rxdata")
  37.      $data_system            = load_data("Data/System.rxdata")
  38.      # Make system object
  39.      $game_system = Game_System.new
  40.      # Make title graphic
  41.      @sprite = Sprite.new
  42.      @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  43.      @sprite.z = 5
  44.      # Flash background
  45.      @fondo = RMFlash.load(@archivo_flash, 640, 480)
  46.      @fondo.z = @sprite.z - 1
  47.      @fondo2 = Sprite.new
  48.      @fondo2.bitmap = Bitmap.new(640, 480)
  49.      @fondo2.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 255))
  50.      @fondo2.z = -1
  51.      #@fondo.loop = 1
  52.      @fr = Graphics.frame_rate
  53.      Graphics.frame_rate = 40
  54.     
  55.      # Make command window
  56.      s1 = "New game"
  57.      s2 = "Load game"
  58.      s3 = "Exit to Windows"
  59.      @command_window = Window_Command.new(192, [s1, s2, s3])
  60.      @command_window.back_opacity = 160
  61.      @command_window.x = 320 - @command_window.width / 2
  62.      @command_window.y = 288
  63.      @command_window.z = 6
  64.      # Continue enabled determinant
  65.      # Check if at least one save file exists
  66.      # If enabled, make @continue_enabled true; if disabled, make it false
  67.      @continue_enabled = false
  68.      for i in 0..3
  69.         if FileTest.exist?("Save#{i+1}.rxdata")
  70.            @continue_enabled = true
  71.         end
  72.      end
  73.      # If continue is enabled, move cursor to "Continue"
  74.      # If disabled, display "Continue" text in gray
  75.      if @continue_enabled
  76.         @command_window.index = 1
  77.      else
  78.         @command_window.disable_item(1)
  79.      end
  80.      # Play title BGM
  81.      $game_system.bgm_play($data_system.title_bgm)
  82.      # Stop playing ME and BGS
  83.      Audio.me_stop
  84.      Audio.bgs_stop
  85.      # Execute transition
  86.      Graphics.transition
  87.      # Main loop
  88.      loop do
  89.         # Update game screen
  90.         Graphics.update
  91.         # Update input information
  92.         Input.update
  93.         #Flash update
  94.         @fondo.update
  95.         # Frame update
  96.         update
  97.         # Abort loop if screen is changed
  98.         if $scene != self
  99.            break
  100.         end
  101.      end
  102.      # Prepare for transition
  103.      Graphics.freeze
  104.      # Dispose of command window
  105.      @command_window.dispose
  106.      # Dispose of title graphic
  107.      @sprite.bitmap.dispose
  108.      @sprite.dispose
  109.      @fondo.pause
  110.      @fondo.z = -2
  111.      @fondo.dispose
  112.      # Normal frame rate
  113.      Graphics.frame_rate = @fr
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # * Frame Update
  117.   #--------------------------------------------------------------------------
  118.   def update
  119.      # Update command window
  120.      @command_window.update
  121.      # If C button was pressed
  122.      if Input.trigger?(Input::C)
  123.         # Branch by command window cursor position
  124.         case @command_window.index
  125.         when 0   # New game
  126.            command_new_game
  127.         when 1   # Continue
  128.            command_continue
  129.         when 2   # Shutdown
  130.            command_shutdown
  131.         end
  132.      end
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Command: New Game
  136.   #--------------------------------------------------------------------------
  137.   def command_new_game
  138.      # Play decision SE
  139.      $game_system.se_play($data_system.decision_se)
  140.      # Stop BGM
  141.      Audio.bgm_stop
  142.      # Reset frame count for measuring play time
  143.      Graphics.frame_count = 0
  144.      # Make each type of game object
  145.      $game_temp               = Game_Temp.new
  146.      $game_system            = Game_System.new
  147.      $game_switches         = Game_Switches.new
  148.      $game_variables       = Game_Variables.new
  149.      $game_self_switches = Game_SelfSwitches.new
  150.      $game_screen            = Game_Screen.new
  151.      $game_actors            = Game_Actors.new
  152.      $game_party             = Game_Party.new
  153.      $game_troop             = Game_Troop.new
  154.      $game_map                = Game_Map.new
  155.      $game_player            = Game_Player.new
  156.      # Set up initial party
  157.      $game_party.setup_starting_members
  158.      # Set up initial map position
  159.      $game_map.setup($data_system.start_map_id)
  160.      # Move player to initial position
  161.      $game_player.moveto($data_system.start_x, $data_system.start_y)
  162.      # Refresh player
  163.      $game_player.refresh
  164.      # Run automatic change for BGM and BGS set with map
  165.      $game_map.autoplay
  166.      # Update map (run parallel process event)
  167.      $game_map.update
  168.      # Switch to map screen
  169.      $scene = Scene_Map.new
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # * Command: Continue
  173.   #--------------------------------------------------------------------------
  174.   def command_continue
  175.      # If continue is disabled
  176.      unless @continue_enabled
  177.         # Play buzzer SE
  178.         $game_system.se_play($data_system.buzzer_se)
  179.         return
  180.      end
  181.      # Play decision SE
  182.      $game_system.se_play($data_system.decision_se)
  183.      # Switch to load screen
  184.      $scene = Scene_Load.new
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # * Command: Shutdown
  188.   #--------------------------------------------------------------------------
  189.   def command_shutdown
  190.      # Play decision SE
  191.      $game_system.se_play($data_system.decision_se)
  192.      # Fade out BGM, BGS, and ME
  193.      Audio.bgm_fade(800)
  194.      Audio.bgs_fade(800)
  195.      Audio.me_fade(800)
  196.      # Shutdown
  197.      $scene = nil
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # * Battle Test
  201.   #--------------------------------------------------------------------------
  202.   def battle_test
  203.      # Load database (for battle test)
  204.      $data_actors            = load_data("Data/Actors.rxdata")
  205.      $data_classes          = load_data("Data/Classes.rxdata")
  206.      $data_skills            = load_data("Data/Skills.rxdata")
  207.      $data_items             = load_data("Data/Items.rxdata")
  208.      $data_weapons          = load_data("Data/Weapons.rxdata")
  209.      $data_armors            = load_data("Data/Armors.rxdata")
  210.      $data_enemies          = load_data("Data/Enemies.rxdata")
  211.      $data_troops            = load_data("Data/Troops.rxdata")
  212.      $data_states            = load_data("Data/States.rxdata")
  213.      $data_animations      = load_data("Data/Animations.rxdata")
  214.      $data_tilesets         = load_data("Data/Tilesets.rxdata")
  215.      $data_common_events = load_data("Data/CommonEvents.rxdata")
  216.      $data_system            = load_data("Data/System.rxdata")
  217.      # Reset frame count for measuring play time
  218.      Graphics.frame_count = 0
  219.      # Make each game object
  220.      $game_temp               = Game_Temp.new
  221.      $game_system            = Game_System.new
  222.      $game_switches         = Game_Switches.new
  223.      $game_variables       = Game_Variables.new
  224.      $game_self_switches = Game_SelfSwitches.new
  225.      $game_screen            = Game_Screen.new
  226.      $game_actors            = Game_Actors.new
  227.      $game_party             = Game_Party.new
  228.      $game_troop             = Game_Troop.new
  229.      $game_map                = Game_Map.new
  230.      $game_player            = Game_Player.new
  231.      # Set up party for battle test
  232.      $game_party.setup_battle_test_members
  233.      # Set troop ID, can escape flag, and battleback
  234.      $game_temp.battle_troop_id = $data_system.test_troop_id
  235.      $game_temp.battle_can_escape = true
  236.      $game_map.battleback_name = $data_system.battleback_name
  237.      # Play battle start SE
  238.      $game_system.se_play($data_system.battle_start_se)
  239.      # Play battle BGM
  240.      $game_system.bgm_play($game_system.battle_bgm)
  241.      # Switch to battle screen
  242.      $scene = Scene_Battle.new
  243.   end
  244. end
  245.  
Expand to see the code.

Scene_Intro using flash
  1.  
  2. #===============================================================================
  3. #
  4. # * Scene_IntroFlash by Dahrkael using 灼眼的夏娜 Flash Player
  5. #                                                                                                               v1.0
  6. #    Requires the .dll and .ocx
  7. #===============================================================================
  8. class Scene_IntroFlash
  9.  
  10.   def initialize
  11.      # Set the file which will be played
  12.      @file = "miku.swf"
  13.      # Choose if the player can skip the intro (0 => false, 1 => true)
  14.      @button = 1
  15.   end
  16.  
  17.   def main
  18.      # Black background
  19.      @fondo = Sprite.new
  20.      @fondo.bitmap = Bitmap.new(640, 480)
  21.      @fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
  22.      @fondo.z = -1
  23.      # Set flash video
  24.      fls = RMFlash.load(@file, 640, 480)
  25.      fls.loop = 1
  26.      fls.z = 2
  27.      # Save frame rate
  28.      @fr = Graphics.frame_rate
  29.      # Set new frame rate
  30.      Graphics.frame_rate = 40
  31.      # Main loop
  32.      Graphics.transition
  33.      while true
  34.         Graphics.update
  35.         #Input.update
  36.         fls.update
  37.         # Skip the video using Enter
  38.         break if @button == 1 and Keyb.trigger($keys["Enter"])
  39.         # Skip when finished
  40.         break if !fls.playing?
  41.      end
  42.      $scene = Scene_Title.new
  43.      Graphics.freeze
  44.      # Little solution for frozen images
  45.      fls.z = -2
  46.      fls.dispose
  47.      # Set old frame rate
  48.      Graphics.frame_rate = @fr
  49.   end
  50. end
  51.  
Expand to see the code.


Demos

Main script demo:
http://ofarts.rpgmaker.es/scripts/Flashv0.3Mod.zip

Scene_Title demo:
http://ofarts.rpgmaker.es/scripts/Scene_TitleFlash.zip

Scene_Intro demo:
http://ofarts.rpgmaker.es/scripts/Scene_IntroFlash.zip

Flash ocx

Use Flash10a.ocx for the best performance, if you use old flash files and have problems try using another ocx.

http://ofarts.rpgmaker.es/scripts/Flash10a.ocx

http://ofarts.rpgmaker.es/scripts/Flash9.ocx

http://ofarts.rpgmaker.es/scripts/Flash6.ocx

Instructions

Use $flash.play("file.swf", button) to reproduce the flash file..

If you want to play an intro in the Main script change "$scene = Scene_Title.new" with "$scene = Scene_IntroFlash.new"

FAQ

Q: Are you the original author of teh script?
A: No, the original script author is 灼眼的夏娜, but the script was only a core, im making it useful.

Q: Can i put a flash video anywhere in the game?

A: Yes.

Q: Can i ask for an add-on?
A: Sure, post your idea.

Q: Can i use interactive flash files?
A: Yes, but if you want to interactuact with it you must know how with RGSS.

Compatibility

Unkown problems with other scripts.
Works in fullscreen mode.

Credits and Thanks

To 灼眼的夏娜 for make the script and the dlls.
Thanks to myself for add the call methods and make the add-ons xD

Author's Notes

You can make awesome things with this script if you know RGSS.

Terms and Conditions

Must include original scripter's name (灼眼的夏娜).
If you want to include mine too is your decision.

PD: Sorry for my bad english, im spanish.
Nice, really nice I think !

but I havn't tested the script.
The first thing that comes to mind is that the programmer likes to torture his brain for nothing: The first two functions are almost the same, and they could be merged. And then many APIs are declared without being used...

regards,
berka
Hey, I'm very interested in this script, but why does it keep posting random numbers when playing a file? Is there any way I can remove that? Also, in order for it to close automatically, I just have to put a few black frames? Sounds easy, then I won't have to worry about those popups.

Also, A+ for it also working in fullscreen with no problems (In the demo, haven't tried it with my game yet). Is there a button that I can assign to close the movie before it ends?
Nice, this will be very useful for me since I will have Flash FMV's in my project. Very good job.
berka wrote:
many APIs are declared without being used...

Because the author wanted the maximum of possibilities with this script, if you know RGSS you can use the unused calls for make cool things :D

Yin wrote:
why does it keep posting random numbers when playing a file? Is there any way I can remove that?


Oo what do you mean? can you put a screenshot or something?

Yin wrote:
Is there a button that I can assign to close the movie before it ends?

Yes, i updated the script (and the demo) you can choose if is possible to skip the flash with Enter key.

Added things for better performance.
- When flash is played the frame rate is 40, after play the flash the frame rate will be the same of before.
- Added the "skip with button" function using another input module, so you wont have problems of pressing keys. by default the skip key is Enter.
- Now the flash stops automatically so you dont need to specificate the duration in some flashes.
Ok, before I post a screenshot, let me check to see if you fixed it in the updated one.

EDIT: It's fixed because it only happened with the playt call. But just so you know, before little Windows boxes were popping up with random numbers for every frame. It's perfect now!
I've got a question. Can the script handle intro videos? I'd like to get a video to appear before the title screen does. I have almost zero knowledge on RGSS, but I imagine it would have to deal with Scene_Title. Any way to code it to do that?
Sure you can, only use
$flash.play("filename", button) below $flash = Play.new in the Main Script.
Beautiful! I works! For some reason it doesn't want to play the video (it plays audio, but no video) but I'm sure that this is the fault of the file I'm using. Thanks a bunch, you've really helped me out by posting this here! 😀

EDIT: Ok, another problem.So it doesn't play the video, only the audio. I skipped the animation with the enter key and then a still of the video (that didn't play) was stuck over the game and I couldn't see, though I could still move. The same happens when I wait it out and let the music finish normally. Now this completely blows my mind!

Content Hidden Show
Here is a screenshot of what I mean. The animation is a dummy test animation of Sonic. I think his face kinda suits the situation, huh.
Image
@Emerald Lance, this script uses Flash 6. If you are using a compression method not supported, this could happen. try replacing Flash.ocx with this one, it uses Flash 9. I compress my flash videos using flash 8 and the flash.ocx that was included could not support it, but flash 9 does. Everything else works the same.

@Dahrkael, Is there anyway you could add an option to change the volume? Also, maybe you could replace the flash.ocx with the one I provided if you want.

Thank you,
Draycos Goldaryn
I'm using Flash 9 and it works just fine. If I do have any problems down the line, I will be sure to try your file out.
Emerald Lance wrote:
Beautiful! I works! For some reason it doesn't want to play the video (it plays audio, but no video) but I'm sure that this is the fault of the file I'm using. Thanks a bunch, you've really helped me out by posting this here! 😀

EDIT: Ok, another problem.So it doesn't play the video, only the audio. I skipped the animation with the enter key and then a still of the video (that didn't play) was stuck over the game and I couldn't see, though I could still move. The same happens when I wait it out and let the music finish normally. Now this completely blows my mind!

Content Hidden Show
Here is a screenshot of what I mean. The animation is a dummy test animation of Sonic. I think his face kinda suits the situation, huh.
Image


The first problem is easy, if you see the line above the flash play is Graphics.freeze, without a Graphics.transition the screen wont display anything, put the code like this:

  1. Graphics.freeze
  2.   $flash = Play.new
  3. Graphics.transition(1)
  4.   $flash.play("file.swf", button)
  5. Graphics.freeze
  6.   $scene = Scene_Title.new
Expand to see the code.


I had problem of the frozen image when i was making the animated Scene_Title, the solution was setting the .z of the flash to -2 and drawing a black rect at -1, i didnt find another solution, for make that take a look in the code of the Scene_Title.

DraycosGoldaryn wrote:
@Dahrkael, Is there anyway you could add an option to change the volume? Also, maybe you could replace the flash.ocx with the one I provided if you want.

Sure, thanks, this repair a problem with long flash files i had yesterday.
Can you search for the flash.ocx v10? i cant find it.

I have free time so i will make a Scene_Intro using flash now, im sure it will be useful for someone.

EDIT: Updated thread and ocx and added the Scene_Intro script
An even cooler add on to your Scene_Intro
  1. class Scene_Cutscene
  2.  
  3.   def initialize(file, button)
  4.     # Set the file which will be played
  5.     @file = file
  6.     # Choose if the player can skip the intro (0 => false, 1 => true)
  7.     @button = button
  8.   end
  9.  
  10.   def main
  11.     # Black background
  12.     @fondo = Sprite.new
  13.     @fondo.bitmap = Bitmap.new(640, 480)
  14.     @fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
  15.     @fondo.z = -1
  16.     # Set flash video
  17.     fls = RMFlash.load(@file, 640, 480)
  18.     fls.loop = 1
  19.     fls.z = 2
  20.     # Save frame rate
  21.     @fr = Graphics.frame_rate
  22.     # Set new frame rate
  23.     Graphics.frame_rate = 40
  24.     # Main loop
  25.     Graphics.transition
  26.     while true
  27.       Graphics.update
  28.       #Input.update
  29.       fls.update
  30.       # Skip the video using Enter
  31.       break if @button == 1 and Keyb.trigger($keys["Enter"])
  32.       # Skip when finished
  33.       break if !fls.playing?
  34.     end
  35.     $scene = Scene_Title.new
  36.     Graphics.freeze
  37.     # Little solution for frozen images
  38.     fls.z = -2
  39.     fls.dispose
  40.     # Set old frame rate
  41.     Graphics.frame_rate = @fr
  42.   end
  43. end
Expand to see the code.


To call use
$scene = Scene_Cutscene.new("file.swf, button type)

that way you can have 3-D animated or whatever cutscenes in your game like FF games do.
gameguy27 wrote:
An even cooler add on to your Scene_Intro
  1. class Scene_Cutscene
  2.  
  3.   def initialize(file, button)
  4.      # Set the file which will be played
  5.      @file = file
  6.      # Choose if the player can skip the intro (0 => false, 1 => true)
  7.      @button = button
  8.   end
  9.  
  10.   def main
  11.      # Black background
  12.      @fondo = Sprite.new
  13.      @fondo.bitmap = Bitmap.new(640, 480)
  14.      @fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
  15.      @fondo.z = -1
  16.      # Set flash video
  17.      fls = RMFlash.load(@file, 640, 480)
  18.      fls.loop = 1
  19.      fls.z = 2
  20.      # Save frame rate
  21.      @fr = Graphics.frame_rate
  22.      # Set new frame rate
  23.      Graphics.frame_rate = 40
  24.      # Main loop
  25.      Graphics.transition
  26.      while true
  27.         Graphics.update
  28.         #Input.update
  29.         fls.update
  30.         # Skip the video using Enter
  31.         break if @button == 1 and Keyb.trigger($keys["Enter"])
  32.         # Skip when finished
  33.         break if !fls.playing?
  34.      end
  35.      $scene = Scene_Title.new
  36.      Graphics.freeze
  37.      # Little solution for frozen images
  38.      fls.z = -2
  39.      fls.dispose
  40.      # Set old frame rate
  41.      Graphics.frame_rate = @fr
  42.   end
  43. end
Expand to see the code.


To call use
$scene = Scene_Cutscene.new("file.swf, button type)

that way you can have 3-D animated or whatever cutscenes in your game like FF games do.


and the difference is? Oo

Edit: added flash10.ocx to download, the demos have the flash6 and flash9 so if you use adobe flash cs4 or you have problems with some files use the v10.

http://ofarts.rpgmaker.es/scripts/Flash10a.ocx
Dahrkael wrote:
gameguy27 wrote:
An even cooler add on to your Scene_Intro
  1. class Scene_Cutscene
  2.  
  3.   def initialize(file, button)
  4.      # Set the file which will be played
  5.      @file = file
  6.      # Choose if the player can skip the intro (0 => false, 1 => true)
  7.      @button = button
  8.   end
  9.  
  10.   def main
  11.      # Black background
  12.      @fondo = Sprite.new
  13.      @fondo.bitmap = Bitmap.new(640, 480)
  14.      @fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
  15.      @fondo.z = -1
  16.      # Set flash video
  17.      fls = RMFlash.load(@file, 640, 480)
  18.      fls.loop = 1
  19.      fls.z = 2
  20.      # Save frame rate
  21.      @fr = Graphics.frame_rate
  22.      # Set new frame rate
  23.      Graphics.frame_rate = 40
  24.      # Main loop
  25.      Graphics.transition
  26.      while true
  27.         Graphics.update
  28.         #Input.update
  29.         fls.update
  30.         # Skip the video using Enter
  31.         break if @button == 1 and Keyb.trigger($keys["Enter"])
  32.         # Skip when finished
  33.         break if !fls.playing?
  34.      end
  35.      $scene = Scene_Title.new
  36.      Graphics.freeze
  37.      # Little solution for frozen images
  38.      fls.z = -2
  39.      fls.dispose
  40.      # Set old frame rate
  41.      Graphics.frame_rate = @fr
  42.   end
  43. end
Expand to see the code.


To call use
$scene = Scene_Cutscene.new("file.swf, button type)

that way you can have 3-D animated or whatever cutscenes in your game like FF games do.


and the difference is? Oo

Edit: added flash10.ocx to download, the demos have the flash6 and flash9 so if you use adobe flash cs4 or you have problems with some files use the v10.

http://ofarts.rpgmaker.es/scripts/Flash10a.ocx



The difference is that Scene_Intro only played one swf. My mod allows you to play any swf.
lol, for that you can use the default call of the script.
this is Sweet.. i think it might come in handy
Wow, I'll be testing this soon. I'll tell you what I think after that.
Thanks much Draycos for pointing me in the right direction, and Dahrkael for the update. Everything works perfectly now. 😀

But now, I have a real challenge. Don't worry, I am more than content with what you've given us so far, so not having this little bit extra won't shatter my hopes and dreams or anything. But it would be kinda spiffy, I think, to have this ability:

In the Wild Arms series, the intro video doesn't play until after the player has selected to load or start a new game. Instead of going in the classic "intro, title, play" format that most RPGs have, it works in a "title, intro, play" format. Meaning, first the title screen appears, then you'd click Load (or New Game) and after you've loaded your game is when the intro plays. Immediately after the intro, the game begins. I was wondering if something like that was possible with this script? I've always thought that kind of opening sequence was cool, and sometimes I found myself loading a game just so I could see the intro, then I'd turn it off. So, can it be done? :boo:
i think you can make it with the default call:
$flash.play(filename, button)
putted in the
command_newgame
and in the
Scene_Load
just before the line
$scene = Scene_Map.new
Dahrkael wrote:
i think you can make it with the default call:
$flash.play(filename, button)
putted in the
command_newgame
and in the
Scene_Load
just before the line
$scene = Scene_Map.new

I thought thats what I should do, but when I tried it, nothing happened. I'll keep trying though, maybe I'm just not doing it right... Thanks.
It is also possible to make the starting point of your game in a blank map and call your intro with an auto event... (that way no scripting is needed)

I have another question though. I tried to use transparent flashes but it makes the background black and I cannot see the map. It would be cool if we could use it that way.

Also, as you mentioned you are open for requests about the script I have some for you:

Flash as Icons
Flash as Battlers
Flash as Panorama
Flash on maps

But my main question is about Transparency. Please Can you Help me?
IM using this script and it works fine up until the point I put some battle scripts into my game.

The only problem is that when I play the flash video, it plays well and ends well, but it does not disposed of.

I have the flash's last frame (or if I set it so I can skip it, then the frame it was skipped at) on my nose and it does not want to get disposed.

I only need a code snippet to be able to dispose of the flash itself if it is possible.

EDIT: for all you who are wondering:
I have the anser to be able to use transparent flash. Make your flash transparetn and change the code in the script

fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))

to

fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,0))

This way the map you are in can be in the background of your flash enabling you to do some very nice stuff such as weather effects or anything else...
Hello! It is working so cool.

I am testing with success mixed with ZTBS "zenith tactical battle system"

But i have no idea how to mend this:

#==============================================================================
# Zenith Tactical Battle System
# Skill Range
#------------------------------------------------------------------------------
# This scene defines skill range, such as distance, size etc
#==============================================================================

module RPG
class Skill
def range
case @id
#==============================================================================
# ↓↓Add your skills below to make them fully defined in battle↓↓
#==============================================================================
#------------------------------------------------------------------------------
# when Skill ID
# targetarea = [direction, range, enemy passibility, long range]
# cursor = [direction, range, enemy passibility, selected cursor]
#------------------------------------------------------------------------------
#
# Set Up
#
# Direction
# 0 : . Shape
# 1 : + Shape
# 2 : Filled 十 Shape
# 3 : Surround 十 Shape
#
# Range
# 0 = Square your characters on
# 1 = 1 more onto 0
# 2 = 1 more onto 1
# 3 = 1 more onto 2
# Etc etc
#
# Enemy Passibility
# true : The Skill Can Pass Through The Enemny
# false : The Skill Cannot Pass Through The Enemy
#
# Long Range
# true : Stops you from using the spell on people right next to you
# false : Allows you to use spells next to you
#
# Enemy Passibility (Only activated if the target are one is)
# Note: This really doesn't matter at all aslong aas you set it for the
# target area Enemy Passibility
#
# true : As above
# false : As above
#
# Selected Cursor
# true : This will make it so that the main cursor has to be selected on
# a character to use the spell rather then its range.
#
# false : This makes sure that the spell can be used by the cursors range
# instead of having to put the main cursor on a character to use.
#
#==============================================================================
# Define your spells, just use the format above to define your spells
#==============================================================================




Here I will play "pirate.swf" When you choose skill id 1 in tactical battle.
I Think this is not best room for the call script. Maybe its better when the player press Enter selecting the skill id1 But I have no clue how to do that.


when 1 # When Skill ID 1
targetarea = [0, 3, true, false] <--- Shows the skill area...
$flash.play("Pirate.swf", 1)
$game_switches[1579] = true


HERE i call teh script and its working but the video is playing two times.
How can i modify that to play only one time.?

I have no scripting skills so please any help will be great.




when 3 # When Skill ID 1
targetarea = [3, 3, true, false]

when 7 # When Skill ID 7
targetarea = [0, 3, true, false]
cursor = [0, 1, false, false]

when 6 # When Skill ID 6
targetarea = [0, 5, true, false]

when 16 # When Skill ID 16
targetarea = [0, 3, true, false]
cursor = [0, 1, false, false]

when 57 # When Skill ID 57
targetarea = [1, 2, false, false]
cursor = [1, 1, false, true]

when 73 # When Skill ID 73
targetarea = [0, 4, true, true]

#==============================================================================
# If not defined, use as default
#==============================================================================
end
targetarea = [0, 1, false, false] if targetarea == nil
cursor = [0, 0, true, true] if cursor == nil
return [targetarea, cursor]
end
end
end

THANKS IN ADVANCED.
HEY guys, i have discover another form to do that easily,,,

calling a common event that reproduces the swf archive when using one skill...

The problem:

ZTBS isn´t calling common event after using skills asociated.

So help me please.
superfanqui wrote:
HEY guys, i have discover another form to do that easily,,,

calling a common event that reproduces the swf archive when using one skill...

The problem:

ZTBS isn´t calling common event after using skills asociated.

So help me please.


the problem with common events in battle is that they are executed after the skill. But I think there was a script that fixed that..
Dani, you mean there´s a modification for ztbs or what?

thanks for the tip but i haven´t found that script.

Gubid tactical battle system can use common events using skill. i hope he can aid me.

Bye
Hey I have found the solution:

If you like to put video (avi or flash) when casting skills or items you only need to edit the skill or item and associate a common event in Database.

Then edit the common event called with:

$flash.play("pirate.swf", 1) <-- this is flash player script for example. Dark_Wolf_Warrior/Dahrkael ---> By.
the common event must be "nothing"

After using the skill in battle you can watch "pirate.swf"

My problem was that I have ZTBS battle system and was unable to activate those common events after using skills.

NOW THANKS TO GUBID: Awrad winner of scripting contest recently, and creator of Gubid tactical battle system. WE can Fix this issue in ztbs.

We only need to put a small script below ZTBS:

CREDITS TO GUBID.

class Scene_Map
alias make_skill_action_res_ztbs_common_event_fix make_skill_action_result
def make_skill_action_result
make_skill_action_res_ztbs_common_event_fix
if @skill.common_event_id > 0
$game_temp.common_event_id = @skill.common_event_id
end
end

alias make_item_action_res_ztbs_commmon_event_fix make_item_action_result
def make_item_action_result
make_item_action_res_ztbs_commmon_event_fix
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
end
end
end

---------------------------------------------------------------------------------

I hope someone is looking for put Video instead of Animations and look for this on google for example.

THANKS TO ALL and gubid. Bye.
But can I insert flash battlebacks???
Hey, just wondering... is it possible to run some actionscript within the flash file?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=64396