OnLoadExternalResourceByFullPath Event
Syntax
C#
public delegate void OnLoadExternalResourceByFullPathEventHandler(
object sender,
string URL,
Stream Stream,
ref bool Handled
);
public event OnLoadExternalResourceByFullPathEventHandler OnLoadExternalResourceByFullPath;
Description
The OnLoadExternalResourceByFullPath
event is triggered when Flash attempts to load a resource specified by a full (not relative) URL.
For example, this event will fire when Flash tries to load http://tratata/1.swf
.
You can handle this event to provide the resource content directly from memory, embedded resources, or other sources.
Example (C#)
private void OnLoadExternalResourceByFullPath(
object sender,
string URL,
System.IO.Stream Stream,
ref bool Handled)
{
if (URL == "http://FLV/FlashVideo.flv")
{
System.IO.Stream FromStream = System.IO.File.OpenRead(Path);
FromStreamToStreamWriter writer =
new FromStreamToStreamWriter(
FromStream,
Stream
);
Handled = true;
}
}
Example (VB.NET)
Private Sub OnLoadExternalResourceByFullPath(
ByVal sender As Object,
ByVal URL As String,
ByVal Stream As System.IO.Stream,
ByRef Handled As Boolean)
If URL = "http://FLV/FlashVideo.flv" Then
Dim FLVStream As System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("Sample2_SWF_FLV_Embedding.flashvideo.flv")
' You can write all content here, but if FLVStream is large it will take time.
' The form will be inaccessible to the user during this operation.
' Consider writing the content in a separate thread.
' See Sample1_SWF_And_FLV_Player for an example.
Const nSize = 64 * 1024
Dim buffer(nSize) As Byte
Dim nReadBytes As Integer
While True
nReadBytes = FLVStream.Read(buffer, 0, nSize)
If nReadBytes = 0 Then Exit While
Try
Stream.Write(buffer, 0, nReadBytes)
Catch e As System.IO.IOException
' Loading is interrupted
Exit While
End Try
End While
Stream.Close()
Handled = True
End If
End Sub
This event is useful for dynamically serving Flash resources without saving them to disk, improving security and flexibility.