Picturebox array & flash movie

i am a beginner in vb and currently working on the game "battleship." I have made 100 picturebox arrays called ComShip(x). How would i make it so that by clicking on a SPECIFIC picturebox (eg. comship(2)), THAT picturebox would display an image. Currently, when i click on ANY of the pictureboxes, the image still shows up on the specified picturebox, but that's not what i want. Is there something i can fix, such as

          Private Sub comship(2)_Click(Index As Integer)        
       instead of the normal          Private Sub comship_Click(Index As Integer)


I also have tried to put a flash movie(.swf) instead of an image, but to no avail. Do I have to add the shockwave flash movie box separately, or can i create one when a picturebox is clicked?

Please help me since i am new to this.
Thank you.
thundergustAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dang123Commented:
thundergust,
    If you have ComShip as an array of 100 picture boxes, this should load a picture into the clicked one.

Private Sub ComShip_Click(Index As Integer)
    ComShip(Index).Picture = LoadPicture("C:\boat.bmp")
End Sub

Dang123
0
Dang123Commented:

Here is a sample of working with a flash movie.

http://www.freevbcode.com/ShowCode.Asp?ID=1443

Dang123

0
thundergustAuthor Commented:
i meant by clicking a specific picturebox, that picturebox will play a flash movie or image inside it. I do not want to click on any picturebox and the image still shows up.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Dang123Commented:
thundergust,
    Sorry, I guess I misunderstood you. After playing with the sample in the link I provided above, it looks like you would need to do one of two things. Put a flash movie player in each picture box, or replace the picture boxes with flash movie player controls. I was able to use the sample to create two flash movie players running at the same time, though performance was starting to become an issue.

    Because of the performance, you may want to use a picture box array. When one member is clicked, hide it and set the flash movie player to occupy the exact same place. Show your bomb exploding in the water or on a boat or what ever then hide the flash movie player and show the picture box again with a different picture in it.

    Let me know how you want to proceed, the sample in the link above should show you most of what you need to know about working with the flash movie.

    By the way, an image control takes less resources than a picturebox control; I would suggest using that if you just want to show pictures on the screen.

Dang123

0
Sector10Commented:
Hi,

Take a look at this, this will get you on your way:

Visual Basic Source Codes:

Private Sub Form_Load()
    SWFlash.Movie = App.Path & "\Movie1.swf"
    SWFlash.Menu = False        'I don't want to see Flash Player Menu
End Sub

Private Sub SWFlash_FSCommand(ByVal command As String, ByVal args As String)
   
    If command = "ButtonClick" Then
        Select Case args
           
            Case "cmdBack": SWFlash.Back        'For Moving to Next Scene
            Case "cmdNext": SWFlash.Forward     'For Moving to Back Scene
           
            'Buttons on 2nd Scene
            Case "Page2.Command1": MsgBox "Command Button 1 Clicked.", vbInformation
            Case "Page2.Command2": MsgBox "Command Button 2 Clicked.", vbInformation
           
            'Buttons of Page3
            'Stop and Play a Movie Clip.
            'For Entrire Movie Play and Stop, Use Play and PlayStop Methods
            Case "Page3.cmdStop": SWFlash.TStopPlay "FishMovie"
            Case "Page3.cmdPlay": SWFlash.TPlay "FishMovie"
           
            'Buttons of Page4
            'SEtting and Getting Variable Values
            Case "Page4.ShowValue"
                Dim mVar As String
                On Local Error Resume Next      'There may be null value
                mVar = SWFlash.GetVariable("txtToGet")
                MsgBox "Text box Value is """ & mVar & """"
            Case "Page4.SetValue"
                mVar = InputBox("Enter Some Value.")
                If mVar <> "" Then _
                    SWFlash.SetVariable "txtToSet", mVar
           
            'Buttons of Page5
            'SEtting and Getting Object Properties
            ' 0 For X Pos
            ' 1 For Y Pos
            ' 2 and 8 For Rotate Horizantaly
            ' 3 and 9 For Rotate Vartically
            ' 6 For Alpha
            ' 10 For Rotations Clockwise/AntiClockwise
            ' 11 For Getting Object Name
            ' 15 Gives Movie Files Path (.swf)
            ' 19 For Quality
           
            Dim lVal As String
            'Move Up
            Case "Page5.cmdUp"
                lVal = SWFlash.TGetProperty("MyBall", 1)
                SWFlash.TSetProperty "MyBall", 1, CStr(CLng(lVal) - 5)
            'Move Down
            Case "Page5.cmdDown"
                lVal = SWFlash.TGetProperty("MyBall", 1)
                SWFlash.TSetProperty "MyBall", 1, CStr(CLng(lVal) + 5)
            'Move Left
            Case "Page5.cmdLeft"
                lVal = SWFlash.TGetProperty("MyBall", 0)
                SWFlash.TSetProperty "MyBall", 0, CStr(CLng(lVal) - 5)
            'Move Right
            Case "Page5.cmdRight"
                lVal = SWFlash.TGetProperty("MyBall", 0)
                SWFlash.TSetProperty "MyBall", 0, CStr(CLng(lVal) + 5)
           
           
            'Rotate Clockwise
            Case "Page5.cmdRotateDown"
                lVal = SWFlash.TGetProperty("MyBall", 10)
                SWFlash.TSetProperty "MyBall", 10, CStr(CLng(lVal) + 5)
               
            'Rotate AntiClockwise
            Case "Page5.cmdRotateUp"
                lVal = SWFlash.TGetProperty("MyBall", 10)
                SWFlash.TSetProperty "MyBall", 10, CStr(CLng(lVal) - 5)
               
            'Shrink Object Inside
            Case "Page5.cmdShrinkH"
                lVal = SWFlash.TGetProperty("MyBall", 8)
                SWFlash.TSetProperty "MyBall", 8, CStr(CLng(lVal) - 5)
            'Shrink Object OutSide
            Case "Page5.cmdDeShrinkH"
                lVal = SWFlash.TGetProperty("MyBall", 8)
                SWFlash.TSetProperty "MyBall", 8, CStr(CLng(lVal) + 5)
               
            'Shrink Object Inside Vertically
            Case "Page5.cmdDeShrinkV"
                lVal = SWFlash.TGetProperty("MyBall", 9)
                SWFlash.TSetProperty "MyBall", 9, CStr(CLng(lVal) + 5)
               
            'Shrink Object Inside Vertically
            Case "Page5.cmdShrinkV"
                lVal = SWFlash.TGetProperty("MyBall", 9)
                SWFlash.TSetProperty "MyBall", 9, CStr(CLng(lVal) - 5)
               
           
            'Set the Alpha Value of the Object
            Case "Page5.cmdAlphaUp"
                lVal = SWFlash.TGetProperty("MyBall", 6)
                If CInt(lVal) < 100 Then    'Max Value for Alpha is 100
                    SWFlash.TSetProperty "MyBall", 6, CStr(CLng(lVal) + 5)
                    'Set New Alpha to the TextBox (In Flash Movie named txtAlpha)
                    SWFlash.SetVariable "txtAlpha", CStr(CLng(lVal) + 5)
                End If
            Case "Page5.cmdAlphaDown"
                lVal = SWFlash.TGetProperty("MyBall", 6)
                If CInt(lVal) > 0 Then    'Min Value for Alpha is 0
                    SWFlash.TSetProperty "MyBall", 6, CStr(CLng(lVal) - 5)
                    'Set New Alpha to the TextBox (In Flash Movie named txtAlpha)
                    SWFlash.SetVariable "txtAlpha", CStr(CLng(lVal) - 5)
                End If

        End Select
    End If
End Sub


Flash ActionScript:

on (release) {
      fscommand("ButtonClick", "cmdBack");
}

on (release) {
      fscommand("ButtonClick", "cmdNext");
}

on (release) {
      fscommand("ButtonClick", "Page3.cmdStop");
}

on (release) {
      fscommand("ButtonClick", "Page3.cmdStop");
}

on (release) {
      fscommand("ButtonClick", "Page4.ShowValue");
}


Regards,


Paul
0
thundergustAuthor Commented:
i think the codes for flash are a little too advanced for me, currently taking computer science 11 in a secondary school. i am still experimenting how to hide the picturebox and put a flash movie in it. the playing of the flash movie has to be simple because i have about 200 pictureboxes(computer ships and player ships). Clicking on the picturebox still doesn't work for me, so i guess the only way is to give every picturebox a specific name.
0
Dang123Commented:
thundergust,
    Something like this should get you going.

Private Sub ComShip_Click(Index As Integer)
   ComShip(Index).Visible = False
   ShockwaveFlash1.Width = ComShip(Index).Width
   ShockwaveFlash1.Height = ComShip(Index).Height
   ShockwaveFlash1.Top = ComShip(Index).Top
   ShockwaveFlash1.Left = ComShip(Index).Left
   
   'logic here to show flash movie
   
   ComShip(Index).Picture = LoadPicture("C:\boat.bmp")
End Sub

Dang123

0
Dang123Commented:

Sory, minor change : )

Private Sub ComShip_Click(Index As Integer)
   ShockwaveFlash1.Width = ComShip(Index).Width
   ShockwaveFlash1.Height = ComShip(Index).Height
   ShockwaveFlash1.Top = ComShip(Index).Top
   ShockwaveFlash1.Left = ComShip(Index).Left
   ComShip(Index).Visible = False
   ShockwaveFlash1.Visible = True
   
   'logic here to show flash movie
   
   ComShip(Index).Picture = LoadPicture("C:\boat.bmp")
   ShockwaveFlash1.Visible = False
   ComShip(Index).Visible = True
End Sub


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thundergustAuthor Commented:
oh...i just figured it out. i didn't notice the "index" in ComShip(Index). i just keep putting in a integer i created. the flash movie was also a great help. Thanks Dang123!! :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.