I have an embedded flash movie in the transparent form.
The transparent form calls the flash to load an image from a URL then the flash calls the form again that it is loaded.
Another class then can loop through a bunch of URLs calling the transparent form to send the url to the flash. This works fine as long as I create only one transparent form - it will loop through several images.
What I need to do is to is dispose of the form between batches of images. But if I do a batch and then close the form, when I create a new form the flsah gets stuck. It never calls the MovieClipLoader.onLoadStart. I tried a AS3 version with Loader() instead and got the same result. It is very bizare! Can someone please help me out.
Here is the simplified code for the embedded swf:
Code: Select all
import flash.external.*;
ExternalInterface.addCallback("init",this, init);
function init(url:String){
ExternalInterface.call("flashAlert","init("+url+")");
var loadimage:MovieClipLoader = new MovieClipLoader();
var loadlistener:Object = new Object();
loadlistener.onLoadStart = function (target){
ExternalInterface.call("flashAlert", "onLoadStar()t");
}
loadlistener.onLoadError = function (target, errorCode){
ExternalInterface.call("flashAlert", "onLoadError(): "+errorCode);
}
loadlistener.onLoadInit = function (){
ExternalInterface.call("flashAlert", "onLoadInit()");
ExternalInterface.call("flashCompleted", "done");
}
loadimage.addListener(loadlistener);
if (_root.holder != null) _root.holder.removeMovieClip();
_root.createEmptyMovieClip("holder", 10);
loadimage.loadClip(url, _root.holder);
}
and here is the code for the form:
Code: Select all
public class MyTranslucencyForm : f_in_box__lib.f_in_box__form
{
//EVENTS
public delegate void CompleteHandler();
//declaring the event
public event CompleteHandler Complete;
public MyTranslucencyForm()
{
Console.WriteLine("MyTranslucencyForm()");
this.Context = "xxxxx";
this.Width = 500;
this.Height = 300;
this.Left = 100;
this.Top = 100;
InitializeComponent();
}
private void InitializeComponent()
{
Console.WriteLine("MyTranslucencyForm InitializeComponent()");
this.OnFlashCall += new f_in_box__lib.f_in_box__form.OnFlashCallEventHandler(this.MyTranslucencyForm_OnFlashCall);
// Loading movie from stream
System.IO.Stream MovieStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("PDVD.Embedded_Movies.CreatePNG.swf");
this.PutMovieFromStream(MovieStream);
}
private void MyTranslucencyForm_OnFlashCall(object sender, String request)
{
XmlDocument document = new XmlDocument();
document.LoadXml(request);
XPathNavigator navigator = document.CreateNavigator();
XmlNode invoke = document.GetElementsByTagName("invoke")[0];
XmlNode arguments = document.GetElementsByTagName("arguments")[0];
if (invoke.Attributes.GetNamedItem("name").Value == "flashAlert")
{
Console.WriteLine("Flash Alert called: " + arguments.ChildNodes[0].InnerText);
return;
}
if (invoke.Attributes.GetNamedItem("name").Value == "flashCompleted")
{
Complete();
}
}
public void callFlashMethod(string url)
{
string callString = "<invoke name=\"init\"returntype=\"xml\"><arguments>";
callString += "<string>" + url + "</string>";
callString += "</arguments></invoke>";
Console.WriteLine("MyTranucencyForm callFlashMethod(" + callString + ")");
this.FlashMethod_CallFunction(callString);
}
public void closeTranslucencyForm()
{
Console.WriteLine("MyTranucencyForm closeTranslucencyForm()");
this.Dispose();
this.Close();
}
}
then in the main class this works:
Code: Select all
translucentForm = new MyTranslucencyForm();
translucentForm.Complete += new MyTranslucencyForm.CompleteHandler(doloop1);
doloop1();
but this doesn't:
Code: Select all
translucentForm = new MyTranslucencyForm();
translucentForm.Complete += new MyTranslucencyForm.CompleteHandler(doloop1);
doloop1();
//close the old form
translucentForm.closeTranslucencyForm()
translucentForm = null;
//create a new form
translucentForm = new MyTranslucencyForm();
translucentForm.Complete += new MyTranslucencyForm.CompleteHandler(doloop2);
doloop2();
in both the case the doloop calls:
Code: Select all
translucentForm.callFlashMethod(imageUrl);
for a number of images
Is it something to do with disposing of the embedded flash. Can this resource be released?