Results 1 to 16 of 16

Thread: reload shockwave component issue.

  1. #1

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    reload shockwave component issue.

    How can I reload the shockwave component or how do I get the same shockwave component to play different swf files?

    Currently the only solution I have found is to place the sockwave component in its own form and reload the form.
    He who never made a mistake never made a discovery?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    Are you doing your component load in the Form_Load?

  3. #3

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    No.

    here is my main form code. The vb app writes an XML file that records the path of the flv file. The swf reads in the path and plays the flv. So on my File1_Click event I couldn't find a means to reload or refresh the component with each click.

    I ended up placing it in its own form and reloading the form. It works rather nicely until you go to click on the File1 again. Then the shockwave form disappears. I found some code that would let me keep the swf form always on top, but I keep saying there must be away to reload "something" and play a different flv.


    VB Code:
    1. Option Explicit
    2. 'makes it necessary to specify variables
    3. 'and makes sure no variable used twice
    4.  
    5. Private Function CreateDOM()
    6.     Dim dom
    7.     Set dom = New DOMDocument30
    8.     dom.async = False
    9.     dom.validateOnParse = False
    10.     dom.resolveExternals = False
    11.     dom.preserveWhiteSpace = True
    12.     Set CreateDOM = dom
    13. End Function
    14.  
    15. Private Sub File1_Click()
    16.  
    17.     Dim dom, node, frag, cd, attr
    18.     Dim sReplaceChar As String
    19.     sReplaceChar = ""
    20.            
    21.     'On Error GoTo ErrorHandler
    22.     Set dom = CreateDOM
    23.    
    24.     ' Create a processing instruction targeted for xml.
    25.     Set node = dom.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
    26.     dom.appendChild node
    27.     Set node = Nothing
    28.    
    29.     ' Create a comment for the document.
    30.     Set node = dom.createComment("sample xml file created using XML DOM object.")
    31.     dom.appendChild node
    32.     Set node = Nothing
    33.    
    34.     ' Create the root element.
    35.     Dim root
    36.     Set root = dom.createElement("videos")
    37.    
    38.     ' Add the root element to the DOM instance.
    39.     dom.appendChild root
    40.     ' Insert a newline + tab.
    41.     root.appendChild dom.createTextNode(vbNewLine + vbTab)
    42.     ' Create and add more nodes to the root element just created.
    43.     ' Create a text element.
    44.     Set node = dom.createElement("video")
    45.    
    46.     'find and replace \ with / for flash
    47.      sReplaceChar = (File1.Path & "\" & File1.FileName)
    48.      sReplaceChar = Replace(sReplaceChar, "\", "/")
    49.     'node.Text = "some character data"
    50.     'node.Text = File1.Path & "/" & File1.FileName
    51.     node.Text = sReplaceChar
    52.     'MsgBox (node.Text)
    53.    
    54.     ' Add text node to the root element.
    55.     root.appendChild node
    56.     Set node = Nothing
    57.       ' Add a newline plus tab.
    58.     root.appendChild dom.createTextNode(vbNewLine + vbTab)
    59.    
    60.     ' Save the XML document to a file.
    61.     dom.save App.Path + "\flv.xml"
    62.     Set root = Nothing
    63.     Set dom = Nothing
    64.    
    65.     Shape1.Visible = False
    66.    
    67.     'load shockwave form
    68.     Unload frmshockwave
    69.     Load frmshockwave
    70.     frmshockwave.Show
    71.     frmhome.txtInfo.Text = ""
    72.  
    73.     Exit Sub
    74.        
    75.    
    76. ErrorHandler:
    77.     MsgBox Err.Description
    78. End Sub
    79.  
    80.  
    81. 'search for flv file
    82. Private Sub Drive1_Change()
    83.     Dir1.Path = Drive1.Drive
    84. End Sub
    85.  
    86. Private Sub Dir1_Change()
    87.     File1.Path = Dir1.Path
    88.     File1.Pattern = "*.flv"
    89. End Sub
    90.  
    91.  
    92. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    93.     If UnloadMode = 0 Then
    94.             Dim Msg   ' Declare variable.
    95.             'Set the message text.
    96.             Msg = "Do you really want to exit?"
    97.             'If user clicks the No button, stop QueryUnload.
    98.             If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbYes Then
    99.                 Call closeAllForms
    100.                 'Unload frmIntro
    101.                 Cancel = False
    102.             Else
    103.                 Cancel = True
    104.             End If
    105.         End If
    106.        
    107. End Sub

    --edited----
    code for shockwave form

    VB Code:
    1. Private Sub Form_Load()
    2.     Call FormOnTop(Me.hWnd, True)
    3.     ShockwaveFlash1.Movie = App.Path & "\XML_FLV_player.swf"
    4.     frmshockwave.Caption = frmhome.File1.FileName
    5.    
    6. End Sub
    7.  
    8. Private Sub ShockwaveFlash1_FSCommand(ByVal command As String, ByVal args As String)
    9.  
    10.     If (command = "info") Then
    11.         'frmhome.txtInfo.Text = (args)
    12.         frmhome.txtInfo.Text = frmhome.txtInfo.Text & args & vbNewLine
    13.     Else
    14.        MsgBox (args)
    15.     End If
    16.    
    17. End Sub
    Last edited by Navarone; May 9th, 2006 at 10:53 AM.
    He who never made a mistake never made a discovery?

  4. #4

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    I guess the form load and unload is the most pratical solution fo rmy situation.
    He who never made a mistake never made a discovery?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    I would avoid strickly using the Form_Load as the code in there would only be run once, when the form loaded.

    Perhaps a better approach would be to put the required code in a Private Sub on the form. This sub could be called from the Form_Load, but also, because it is a sub, it could be called again after the form is loaded, and the parameters have changed.

  6. #6

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    I am not sure I understand, of course I have only had one sip of morning coffee Can you explain a little more?
    He who never made a mistake never made a discovery?

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    A simple example. Lets say you have the following in the Form_Load
    VB Code:
    1. Private Sub Form_Load()
    2. Text1.Text = "Hack"
    3. Text2.Text = "Navarone"
    4. End Sub
    Now, after some more processing on the forms which occasions the values of these textboxes to change, you need to reset them to their original values (just pretend you need the routine to run again in order to do this).

    Well, without unloading the form and reloading, you can't. However, if you create a sub routine on the form, you can simply call the sub again.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub SetDefaultTextValues()
    4. Text1.Text = "Hack"
    5. Text2.Text = "Navarone"
    6. End Sub
    7.  
    8. Private Sub Form_Load()
    9. SetDefaultTextValues
    10. End Sub
    The form is loaded, and the textboxes have their values. You do stuff which changes those values. Now you need to reset them. Instead of unloading and reloading the form, all you have to do is call the SetDefaultTextValues sub again.

    Make sense?

  8. #8

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    Sorta makes sense. So if I understand, when my form loads, the default values are blank or they would be blank in my case. When I click the File1_Click, the new values would be added and I would then in this same File1_Click sub run the SetDefaultTextValues, correct?

    Can I get away with just having one form?
    He who never made a mistake never made a discovery?

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    Quote Originally Posted by Navarone
    Sorta makes sense. So if I understand, when my form loads, the default values are blank or they would be blank in my case. When I click the File1_Click, the new values would be added and I would then in this same File1_Click sub run the SetDefaultTextValues, correct?

    Can I get away with just having one form?
    I don't see why you couldn't have just one form.

    Also, you probably don't want to call your Sub SetDefaultTextValues. You aren't dealing with text. You are dealing with swf files.

    Let me see if I understand the flow of your program.

    Your form loads, but at that time, nothing is happening.

    After the form loads, an swf file is selected using your File1 control.

    The name of the selected file is passed onto code that will actually play, or display, or do whatever it is you do, with swf files.

    Once this is done, you would like the ability to repeat the process by selecting another swf file, and doing the playing/whatevering all over again.

    Is this the scenerio?

  10. #10

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    That is correct.

    See I originally had just one form with the shockwave component, but I didn't know how to reload the values or component, so I went to 2 forms.
    He who never made a mistake never made a discovery?

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    Ok. With this being the case, you don't need anything the form load unless you want to hardcode a swf file name. That would mean the same file played EVERY time you loaded your form, and that would get old very quick.

    It looks like all of the code to do what you want is in the click event of File1.

    I would take that code out of that and put it in a Sub. Call it something like PlaySWF. I would add a parameter to the sub for the file name. I would also take what was selected from File1_Click and display it in a textbox. That would give the user the opportunity to verify that they selected the file they wanted, and didn't select something by mistake.

    I would add a command button called cmdPlay, and call the sub from the click event of the command button. A quick example:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub PlaySWF(pstrFileName As String)
    4. 'code here to play the passed file name
    5. End Sub
    6.  
    7. Private Sub File1_Click()
    8. txtSWF.Text = File1.FileName
    9. End Sub
    10.  
    11. Private Sub cmdPlay_Click()
    12. PlaySWF txtSWF.Text
    13. End Sub
    Make sense?

    Now, you can play whatever you want just but selecting it, and clicking the command button, and you can do it over and over and over again. Plus, you only need one form.

  12. #12

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    Ok, let me try this and I'll get back to you with how I make out.
    Thanks.
    He who never made a mistake never made a discovery?

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    Quote Originally Posted by Navarone
    Ok, let me try this and I'll get back to you with how I make out.
    Thanks.
    It should work like a champ. I've no idea how to play an .swf file, but if you can handle that part, then I'm pretty sure I will be able to answer any other questions regarding the process and/or program flow for you.

  14. #14

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    ok, here is what I have. Everything is on one form.

    When I click the File1_Click, it writes a XML document called flv.xml. Also, when I click the File1_Click the Shockwave component inturn loads the swf - XML_FLV_player.swf. This swf reads the XML file and knows which flv file to play.

    So, when I click File1_Click the first time the correct flv plays, but if I click again, it will not play. The XML document is getting updated but the shockwave component isn't reloading.



    VB Code:
    1. Option Explicit
    2.  
    3. Private Function CreateDOM()
    4.     Dim dom
    5.     Set dom = New DOMDocument30
    6.     dom.async = False
    7.     dom.validateOnParse = False
    8.     dom.resolveExternals = False
    9.     dom.preserveWhiteSpace = True
    10.     Set CreateDOM = dom
    11. End Function
    12.  
    13. Private Sub File1_Click()
    14.  
    15.     Dim dom, node, frag, cd, attr
    16.     Dim sReplaceChar As String
    17.     sReplaceChar = ""
    18.            
    19.     'On Error GoTo ErrorHandler
    20.     Set dom = CreateDOM
    21.    
    22.     ' Create a processing instruction targeted for xml.
    23.     Set node = dom.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
    24.     dom.appendChild node
    25.     Set node = Nothing
    26.    
    27.     ' Create a comment for the document.
    28.     Set node = dom.createComment("sample xml file created using XML DOM object.")
    29.     dom.appendChild node
    30.     Set node = Nothing
    31.    
    32.     ' Create the root element.
    33.     Dim root
    34.     Set root = dom.createElement("videos")
    35.    
    36.     ' Add the root element to the DOM instance.
    37.     dom.appendChild root
    38.     ' Insert a newline + tab.
    39.     root.appendChild dom.createTextNode(vbNewLine + vbTab)
    40.     ' Create and add more nodes to the root element just created.
    41.     ' Create a text element.
    42.     Set node = dom.createElement("video")
    43.    
    44.     'find and replace \ with / for flash
    45.      sReplaceChar = (File1.Path & "\" & File1.FileName)
    46.      sReplaceChar = Replace(sReplaceChar, "\", "/")
    47.     'node.Text = "some character data"
    48.     'node.Text = File1.Path & "/" & File1.FileName
    49.     node.Text = sReplaceChar
    50.     'MsgBox (node.Text)
    51.    
    52.     ' Add text node to the root element.
    53.     root.appendChild node
    54.     Set node = Nothing
    55.       ' Add a newline plus tab.
    56.     root.appendChild dom.createTextNode(vbNewLine + vbTab)
    57.    
    58.     ' Save the XML document to a file.
    59.     dom.save App.Path + "\flv.xml"
    60.     Set root = Nothing
    61.     Set dom = Nothing
    62.    
    63.     Shape1.Visible = False
    64.    
    65.     ShockwaveFlash1.Movie = App.Path & "\XML_FLV_player.swf"
    66.    
    67.     'frmshockwave.Caption = frmhome.File1.FileName
    68.     'load shockwave form
    69.     'Unload frmshockwave
    70.     'Load frmshockwave
    71.     'frmshockwave.Show
    72.    
    73.     frmhome.txtInfo.Text = ""
    74.  
    75.     Exit Sub
    76.        
    77.    
    78. ErrorHandler:
    79.     MsgBox Err.Description
    80. End Sub
    81.  
    82. 'search for flv file
    83. Private Sub Drive1_Change()
    84.     Dir1.Path = Drive1.Drive
    85. End Sub
    86.  
    87. Private Sub Dir1_Change()
    88.     File1.Path = Dir1.Path
    89.     File1.Pattern = "*.flv"
    90. End Sub
    91.  
    92.  
    93. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    94.     If UnloadMode = 0 Then
    95.             Dim Msg   ' Declare variable.
    96.             'Set the message text.
    97.             Msg = "Do you really want to exit?"
    98.             'If user clicks the No button, stop QueryUnload.
    99.             If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbYes Then
    100.                 Call closeAllForms
    101.                 'Unload frmIntro
    102.                 Cancel = False
    103.             Else
    104.                 Cancel = True
    105.             End If
    106.         End If
    107.        
    108. End Sub
    109.  
    110. Private Sub ShockwaveFlash1_FSCommand(ByVal command As String, ByVal args As String)
    111.  
    112.     If (command = "info") Then
    113.         'frmhome.txtInfo.Text = (args)
    114.         frmhome.txtInfo.Text = frmhome.txtInfo.Text & args & vbNewLine
    115.     Else
    116.        MsgBox (args)
    117.     End If
    118.    
    119. End Sub
    120.  
    121.  
    122. Private Sub PlaySWF(pstrFileName As String)
    123.     'code here to play the passed file name
    124.     ShockwaveFlash1.Movie = App.Path & "\XML_FLV_player.swf"
    125. End Sub
    He who never made a mistake never made a discovery?

  15. #15
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: reload shockwave component issue.

    Does anything happen on the second click?

    Have you stepped through the code to see what is actually going on?

  16. #16

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: reload shockwave component issue.

    I have stepped thru the application and on the second click nothing happens in the shockwave control. However, i did verify that the correct path to the flv is saved to the XML file on the second click, so there is no problem with the file name being the same or not getting updated.

    I added the following to the File1_click event and the shockwave control works correctly on the second click and any subsequent clicks.

    VB Code:
    1. Unload frmhome
    2.     Load frmhome
    3.     frmhome.Show
    He who never made a mistake never made a discovery?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width