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
Add-ons
Animated Scene_Title with flash
Scene_Intro using flash
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.
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
- #==============================================================================#
- # Version 0.3 #
- # RPG Maker XP Flash Player #
- # #
- # Author: ç¼çœ¼çš„å¤å¨œ Updated by: Dark_Wolf_Warrior/Dahrkael #
- # #
- # How to Use: #
- # Graphics.freeze #
- # 1. Go to Main Script and add ----> $flash = Play.new #
- # $scene = Scene_Title.new #
- # #
- # 2. Copy the .dll and the .ocx to the game folder #
- # #
- # 3. Make a folder called "Flash" in the folder "Graphics" -> Graphics/Flash/ #
- # #
- # 4. To play a flash file use: #
- # $flash.play("file.swf", button) #
- # #
- # button can be 0 or 1, if 1 you can skip the flash using "Enter" #
- # #
- # #
- # #
- # Interactive flashes requires RGSS knownledge to make they work #
- # #
- # Original Keyb module by HoundNinja #
- # #
- #==============================================================================#
- class String
- CP_ACP = 0
- CP_UTF8 = 65001
- def u2s
- m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
- w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
- len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
- buf = "\0" * (len*2)
- m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
- len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
- ret = "\0" * len
- w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
- return ret
- end
- def s2u
- m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
- w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
- len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
- buf = "\0" * (len*2)
- m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
- len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
- ret = "\0" * len
- w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
- return ret
- end
- def s2u!
- self[0, length] = s2u
- end
- def u2s!
- self[0, length] = u2s
- end
- end
- class Bitmap
- RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
- RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
- def address
- buffer, ad = "xxxx", object_id * 2 + 16
- RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
- RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
- RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
- end
- end
- class RMFlash
- API_NEWÂ = Win32API.new("RMFlash", "_new", "piil", "l")
- API_UPDATEÂ = Win32API.new("RMFlash", "_update", "l", "v")
- API_FREEÂ = Win32API.new("RMFlash", "_free", "l", "v")
- API_PLAYING = Win32API.new("RMFlash", "_is_playing", "l", "i")
- API_PAUSEÂ = Win32API.new("RMFlash", "_pause", "l", "v")
- API_RESUMEÂ = Win32API.new("RMFlash", "_resume", "l", "v")
- API_BACKÂ = Win32API.new("RMFlash", "_back", "l", "v")
- API_REWINDÂ = Win32API.new("RMFlash", "_rewind", "l", "v")
- API_FORWARDÂ = Win32API.new("RMFlash", "_forward", "l", "v")
- API_CURFRAMEÂ = Win32API.new("RMFlash", "_cur_frame", "l", "i")
- API_TOTALFRAMEÂ = Win32API.new("RMFlash", "_total_frames", "l", "i")
- API_GOTOFRAMEÂ = Win32API.new("RMFlash", "_goto_frame", "li", "v")
- API_GETLOOPÂ = Win32API.new("RMFlash", "_get_loop", "l", "i")
- API_SETLOOPÂ = Win32API.new("RMFlash", "_set_loop", "li", "v")
- API_CLEARALLÂ = Win32API.new("RMFlash", "_clear_all", "v", "v")
- API_VALID = Win32API.new("RMFlash", "_valid", "l", "i")
- API_SENDMSG = Win32API.new("RMFlash", "_send_message", "liii", "l")
- CUR_PATH = Dir.pwd
- def self.get_version
- end
- def self.clear_all
- API_CLEARALL.call
- end
- def self.load(name, width, height, v = nil)
- new("#{CUR_PATH}/Graphics/Flash/#{name}".u2s, width, height, v)
- end
- attr_reader :valid
- def initialize(flash_name, flash_width, flash_height, viewport = nil)
- @sprite = Sprite.new(viewport)
- @sprite.bitmap = Bitmap.new(flash_width, flash_height)
- @value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)
- @loop = API_GETLOOP.call(@value) > 0
- @valid = API_VALID.call(@value) > 0
- end
- def viewport
- @sprite.viewport
- end
- def update
- API_UPDATE.call(@value)
- end
- def dispose
- API_FREE.call(@sprite.bitmap.address)
- end
- def playing?
- API_PLAYING.call(@value) > 0
- end
- def pause
- API_PAUSE.call(@value)
- end
- def resume
- API_RESUME.call(@value)
- end
- def back
- API_BACK.call(@value)
- end
- def rewind
- API_REWIND.call(@value)
- end
- def forward
- API_FORWARD.call(@value)
- end
- def current_frame
- API_CURFRAME.call(@value)
- end
- def total_frames
- API_TOTALFRAME.call(@value)
- end
- def goto_frame(goal_frame)
- API_GOTOFRAME.call(@value, goal_frame)
- end
- def x
- @sprite.x
- end
- def x=(v)
- @sprite.x = v
- end
- def y
- @sprite.y
- end
- def y=(v)
- @sprite.y = v
- end
- def z
- @sprite.z
- end
- def z=(v)
- @sprite.z = v
- end
- def width
- @sprite.bitmap.width
- end
- def height
- @sprite.bitmap.height
- end
- def loop?
- @loop
- end
- def loop=(v)
- if @loop != v
- @loop = v
- API_SETLOOP.call(@value, v)
- end
- end
- def msg_to_flash(msg, wParam, lParam)
- return API_SENDMSG.call(@value, msg, wParam, lParam)
- end
- # 例
- WM_MOUSEMOVE = 0x0200
- def make_long(a, b)
- return (a & 0xffff ) | (b & 0xffff) << 16
- end
- def on_mouse_move(x, y)
- return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
- end
- end
- module Kernel
- alias origin_exit exit unless method_defined? :exit
- def exit(*args)
- RMFlash.clear_all
- origin_exit(*args)
- end
- end
- module Keyb
- $keys = {}
- $keys["Enter"] = 0x0D
- GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
- module_function
- def trigger(rkey)
- GetKeyState.call(rkey) & 0x01 == 1
- end
- end
- class Play
- def play(filename, button)
- fondo = Sprite.new
- fondo.bitmap = Bitmap.new(640, 480)
- fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
- fls = RMFlash.load(filename, 640, 480)
- fls.loop = 1
- fls.z = 9999
- @button = button
- @fr = Graphics.frame_rate
- Graphics.frame_rate = 40
- while true
- Graphics.update
- #Input.update
- fls.update
- break if @button == 1 and Keyb.trigger($keys["Enter"])
- break if !fls.playing?
- end
- fls.dispose
- Graphics.frame_rate = @fr
- fondo.dispose
- end
- end
Expand to see the code.
Add-ons
Animated Scene_Title with flash
- #==============================================================================
- # ** Scene_Title with Flash Background Dahrkael
- #------------------------------------------------------------------------------
- # You can put a picture with the title and a flash in the background.
- # Requires the .dll and the .ocx
- #==============================================================================
- class Scene_Title
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Write the name of the flash file you want to use as background with the extension
- # in the "/Graphics/Flash/" folder
- @archivo_flash = "miku.swf"
- # If battle test
- if $BTEST
- battle_test
- return
- end
- # Load database
- $data_actors = load_data("Data/Actors.rxdata")
- $data_classes = load_data("Data/Classes.rxdata")
- $data_skills = load_data("Data/Skills.rxdata")
- $data_items = load_data("Data/Items.rxdata")
- $data_weapons = load_data("Data/Weapons.rxdata")
- $data_armors = load_data("Data/Armors.rxdata")
- $data_enemies = load_data("Data/Enemies.rxdata")
- $data_troops = load_data("Data/Troops.rxdata")
- $data_states = load_data("Data/States.rxdata")
- $data_animations = load_data("Data/Animations.rxdata")
- $data_tilesets = load_data("Data/Tilesets.rxdata")
- $data_common_events = load_data("Data/CommonEvents.rxdata")
- $data_system = load_data("Data/System.rxdata")
- # Make system object
- $game_system = Game_System.new
- # Make title graphic
- @sprite = Sprite.new
- @sprite.bitmap = RPG::Cache.title($data_system.title_name)
- @sprite.z = 5
- # Flash background
- @fondo = RMFlash.load(@archivo_flash, 640, 480)
- @fondo.z = @sprite.z - 1
- @fondo2 = Sprite.new
- @fondo2.bitmap = Bitmap.new(640, 480)
- @fondo2.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 255))
- @fondo2.z = -1
- #@fondo.loop = 1
- @fr = Graphics.frame_rate
- Graphics.frame_rate = 40
- # Make command window
- s1 = "New game"
- s2 = "Load game"
- s3 = "Exit to Windows"
- @command_window = Window_Command.new(192, [s1, s2, s3])
- @command_window.back_opacity = 160
- @command_window.x = 320 - @command_window.width / 2
- @command_window.y = 288
- @command_window.z = 6
- # Continue enabled determinant
- # Check if at least one save file exists
- # If enabled, make @continue_enabled true; if disabled, make it false
- @continue_enabled = false
- for i in 0..3
- if FileTest.exist?("Save#{i+1}.rxdata")
- @continue_enabled = true
- end
- end
- # If continue is enabled, move cursor to "Continue"
- # If disabled, display "Continue" text in gray
- if @continue_enabled
- @command_window.index = 1
- else
- @command_window.disable_item(1)
- end
- # Play title BGM
- $game_system.bgm_play($data_system.title_bgm)
- # Stop playing ME and BGS
- Audio.me_stop
- Audio.bgs_stop
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- #Flash update
- @fondo.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of command window
- @command_window.dispose
- # Dispose of title graphic
- @sprite.bitmap.dispose
- @sprite.dispose
- @fondo.pause
- @fondo.z = -2
- @fondo.dispose
- # Normal frame rate
- Graphics.frame_rate = @fr
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update command window
- @command_window.update
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Branch by command window cursor position
- case @command_window.index
- when 0 # New game
- command_new_game
- when 1 # Continue
- command_continue
- when 2 # Shutdown
- command_shutdown
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Command: New Game
- #--------------------------------------------------------------------------
- def command_new_game
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Stop BGM
- Audio.bgm_stop
- # Reset frame count for measuring play time
- Graphics.frame_count = 0
- # Make each type of game object
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # Set up initial party
- $game_party.setup_starting_members
- # Set up initial map position
- $game_map.setup($data_system.start_map_id)
- # Move player to initial position
- $game_player.moveto($data_system.start_x, $data_system.start_y)
- # Refresh player
- $game_player.refresh
- # Run automatic change for BGM and BGS set with map
- $game_map.autoplay
- # Update map (run parallel process event)
- $game_map.update
- # Switch to map screen
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # * Command: Continue
- #--------------------------------------------------------------------------
- def command_continue
- # If continue is disabled
- unless @continue_enabled
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to load screen
- $scene = Scene_Load.new
- end
- #--------------------------------------------------------------------------
- # * Command: Shutdown
- #--------------------------------------------------------------------------
- def command_shutdown
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Fade out BGM, BGS, and ME
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- # Shutdown
- $scene = nil
- end
- #--------------------------------------------------------------------------
- # * Battle Test
- #--------------------------------------------------------------------------
- def battle_test
- # Load database (for battle test)
- $data_actors = load_data("Data/Actors.rxdata")
- $data_classes = load_data("Data/Classes.rxdata")
- $data_skills = load_data("Data/Skills.rxdata")
- $data_items = load_data("Data/Items.rxdata")
- $data_weapons = load_data("Data/Weapons.rxdata")
- $data_armors = load_data("Data/Armors.rxdata")
- $data_enemies = load_data("Data/Enemies.rxdata")
- $data_troops = load_data("Data/Troops.rxdata")
- $data_states = load_data("Data/States.rxdata")
- $data_animations = load_data("Data/Animations.rxdata")
- $data_tilesets = load_data("Data/Tilesets.rxdata")
- $data_common_events = load_data("Data/CommonEvents.rxdata")
- $data_system = load_data("Data/System.rxdata")
- # Reset frame count for measuring play time
- Graphics.frame_count = 0
- # Make each game object
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # Set up party for battle test
- $game_party.setup_battle_test_members
- # Set troop ID, can escape flag, and battleback
- $game_temp.battle_troop_id = $data_system.test_troop_id
- $game_temp.battle_can_escape = true
- $game_map.battleback_name = $data_system.battleback_name
- # Play battle start SE
- $game_system.se_play($data_system.battle_start_se)
- # Play battle BGM
- $game_system.bgm_play($game_system.battle_bgm)
- # Switch to battle screen
- $scene = Scene_Battle.new
- end
- end
Expand to see the code.
Scene_Intro using flash
- #===============================================================================
- #
- # * Scene_IntroFlash by Dahrkael using ç¼çœ¼çš„å¤å¨œ Flash Player
- # v1.0
- # Requires the .dll and .ocx
- #===============================================================================
- class Scene_IntroFlash
- def initialize
- # Set the file which will be played
- @file = "miku.swf"
- # Choose if the player can skip the intro (0 => false, 1 => true)
- @button = 1
- end
- def main
- # Black background
- @fondo = Sprite.new
- @fondo.bitmap = Bitmap.new(640, 480)
- @fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
- @fondo.z = -1
- # Set flash video
- fls = RMFlash.load(@file, 640, 480)
- fls.loop = 1
- fls.z = 2
- # Save frame rate
- @fr = Graphics.frame_rate
- # Set new frame rate
- Graphics.frame_rate = 40
- # Main loop
- Graphics.transition
- while true
- Graphics.update
- #Input.update
- fls.update
- # Skip the video using Enter
- break if @button == 1 and Keyb.trigger($keys["Enter"])
- # Skip when finished
- break if !fls.playing?
- end
- $scene = Scene_Title.new
- Graphics.freeze
- # Little solution for frozen images
- fls.z = -2
- fls.dispose
- # Set old frame rate
- Graphics.frame_rate = @fr
- end
- end
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.
