Page 1 of 1

Embedding a flash player control Utalize the flash player control for viewing movies and games Rate Topic: -----

#1 RodgerB  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 66
  • View blog
  • Posts: 2,284
  • Joined: 21-September 07

Posted 30 December 2007 - 02:14 AM

Embedding a flash player control.

Welcome to this tutorial on embedding a flash player control. In this tutorial, we will learn how to add one to a form, play a movie, and position itself correctly in its container. This tutorial will require that you have a flash player installed on the computers you would like to use it on. In this tutorial, I am using Adobe Flash Player 9.0 r46, so results may vary on other versions, according to technological advances. We will also be covering going to a specified frame much like the gotoAndPlay() method, and dynamically changing the movie.

1) Adding the control to the form.

Visual Studio makes it easy to add the Flash Object to the project. Right Click in the General Category in the Toolbox, and a Context Menu will appear. Select "Choose Items...".

The Choose Toolbox Items dialog box should appear now. Click the COM tab at the top of the dialog and search down the list until you find "Shockwave Flash Object". Tick the Checkbox, and click Ok.

Posted Image

You should now have a Shockwave Flash Object control in the toolbox. Drag one onto the Form, and rename it to flashPlayer (sorta a personal preference thing really, I just can't stand how ugly AxShockwaveFlash1 looks :P ).

2) Playing a movie.

Playing a movie is very simple with the Flash Player, infact there really isn't much to it at all, its just changing the Movie property.

For the purpose of this example, lets make the Flash Player play Line Rider. Set the Movie property to:

Quote



We will now have the control playing this movie. But why is it not stretched to see the whole movie you ask? This will be explained in the next section.

3) Stretching the movie to see all the goods.

Sometimes when we load a new movie, the ScaleMode property changes. If you want it to show the whole movie for the control, you will need to have the ScaleMode equal zero. I have created this simple wrapper, for dynamically changing the movie and keeping it the right view.

''' <summary>
''' Sets the movie and keeps it stretched.
''' </summary>
''' <param name="strMovie">The path to set the player to view.</param>
''' <remarks></remarks>
Public Sub setMovie(ByRef strMovie As String)
	flashPlayer.Movie = strMovie
	flashPlayer.ScaleMode = 0
End Sub



Now resize the form and control in a comfortable playing manner if you haven't already, and continue to the next step.

4) Our own gotoAndPlay() method.

The Flash Player control has its own FrameNum property. In our case in Line Rider, we can make it skip those first two frames, one for the main scene and one for a tutorial about how to play. To do this, we can't just set the FrameNum property in the form designer, it seems to be all show and no go.

To combat this issue, we will change it programmatically. Here is the gotoAndPlay() method we will be using:

''' <summary>
''' Go to the frame number specified.
''' </summary>
''' <param name="frame">The frame number to goto.</param>
''' <remarks></remarks>
Public Sub gotoAndPlay(ByRef frame As Integer)
	flashPlayer.FrameNum = frame
End Sub



Add the following code to the Form1.Load event:

gotoAndPlay(1)



This will skip straight to the game, cutting the crap if you will. I'm sure you can think of many other awesome ways to do stuff, such as game cheating etc, but i'll leave that to you to think of. :P

Have fun playing with your newly created control, and thanks for reading this tutorial.

Is This A Good Question/Topic? 0
  • +

Replies To: Embedding a flash player control

#2 rk7070  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-July 09

Posted 29 July 2009 - 02:06 AM

Sir I used the below process but it is not displaying the "ShockwaveFlash Object" control on ToolBox.

Please send me solution for this on rk7070@gmail.com


View PostRodgerB, on 30 Dec, 2007 - 01:14 AM, said:

Embedding a flash player control.

Welcome to this tutorial on embedding a flash player control. In this tutorial, we will learn how to add one to a form, play a movie, and position itself correctly in its container. This tutorial will require that you have a flash player installed on the computers you would like to use it on. In this tutorial, I am using Adobe Flash Player 9.0 r46, so results may vary on other versions, according to technological advances. We will also be covering going to a specified frame much like the gotoAndPlay() method, and dynamically changing the movie.

1) Adding the control to the form.

Visual Studio makes it easy to add the Flash Object to the project. Right Click in the General Category in the Toolbox, and a Context Menu will appear. Select "Choose Items...".

The Choose Toolbox Items dialog box should appear now. Click the COM tab at the top of the dialog and search down the list until you find "Shockwave Flash Object". Tick the Checkbox, and click Ok.

Posted Image

You should now have a Shockwave Flash Object control in the toolbox. Drag one onto the Form, and rename it to flashPlayer (sorta a personal preference thing really, I just can't stand how ugly AxShockwaveFlash1 looks :P ).

2) Playing a movie.

Playing a movie is very simple with the Flash Player, infact there really isn't much to it at all, its just changing the Movie property.

For the purpose of this example, lets make the Flash Player play Line Rider. Set the Movie property to:

Quote



We will now have the control playing this movie. But why is it not stretched to see the whole movie you ask? This will be explained in the next section.

3) Stretching the movie to see all the goods.

Sometimes when we load a new movie, the ScaleMode property changes. If you want it to show the whole movie for the control, you will need to have the ScaleMode equal zero. I have created this simple wrapper, for dynamically changing the movie and keeping it the right view.

''' <summary>
''' Sets the movie and keeps it stretched.
''' </summary>
''' <param name="strMovie">The path to set the player to view.</param>
''' <remarks></remarks>
Public Sub setMovie(ByRef strMovie As String)
	flashPlayer.Movie = strMovie
	flashPlayer.ScaleMode = 0
End Sub



Now resize the form and control in a comfortable playing manner if you haven't already, and continue to the next step.

4) Our own gotoAndPlay() method.

The Flash Player control has its own FrameNum property. In our case in Line Rider, we can make it skip those first two frames, one for the main scene and one for a tutorial about how to play. To do this, we can't just set the FrameNum property in the form designer, it seems to be all show and no go.

To combat this issue, we will change it programmatically. Here is the gotoAndPlay() method we will be using:

''' <summary>
''' Go to the frame number specified.
''' </summary>
''' <param name="frame">The frame number to goto.</param>
''' <remarks></remarks>
Public Sub gotoAndPlay(ByRef frame As Integer)
	flashPlayer.FrameNum = frame
End Sub



Add the following code to the Form1.Load event:

gotoAndPlay(1)



This will skip straight to the game, cutting the crap if you will. I'm sure you can think of many other awesome ways to do stuff, such as game cheating etc, but i'll leave that to you to think of. :P

Have fun playing with your newly created control, and thanks for reading this tutorial.

Was This Post Helpful? 0
  • +
  • -

#3 gls0151  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-February 10

Posted 25 February 2010 - 11:25 AM

Hello. After following your steps I'm unable to find the Shockwave Flash Object within my Toolbox. Please advise. I'm using Visual Studio 2005.

Thank you in advance.
Was This Post Helpful? 0
  • +
  • -

#4 Guest_Danieli*


Reputation:

Posted 04 June 2010 - 07:39 AM

Hi I followd step one but like gls0151 I also couln't see the shockwave flash object in the toolbox
please help
Was This Post Helpful? 0

#5 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 330
  • Joined: 11-July 07

Posted 24 October 2011 - 12:00 PM

I can see the Flash Object, but when I tell it to load a movie, at runtime or in the properties, it's always a white screen: "Movie not loaded"

Any solutions?

~huzi
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1