problem with disposing of f_in_box__form

.NET Edition of the F-IN-BOX
ilovecables
Posts: 1
Joined: Thu Apr 03, 2008 3:11 pm

problem with disposing of f_in_box__form

Postby ilovecables » Thu Apr 03, 2008 3:38 pm

I have a wierd problem with the f_in_box__form and need help to solve. I have tried everything.

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?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Apr 03, 2008 6:21 pm

Thank you for your questions.

It's difficult to understand what's the problem, I don't see any obvious errors.

Could you please send me the code to support (at) f-in-box.com ?
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 14 guests

cron