1 Reply Latest reply on Sep 20, 2006 3:57 PM by c5mike

    EventListener working 95% of the time in IE but only 2% in Firefox?

    c5mike
      I have no clue how to even begin to debug this. The problem is much more common in Firefox than in IE, but it does happen in both.

      The critical problem is that my EventListener function startChatClickHandler is not triggered 98% of the time in Firefox and about 5% of the time in IE. Even the Alert box doesn't trigger. I can click on it all day in Firefox and it just sits there though once ever while it works but never more than once. But if I right click on it, then select Rewind, it will work 100% - at least till I try it again. That must be a clue but I have no idea what it means. Also, it used to work just fine but one of my changes must have had a unintented effect but I can't seem to fix it. Also, I've had the same results on more than one PC.

      Another possible clue is that if I hit the enter key instead, that works 100% of the time in both Firefox and IE, even though all it does is pass it on to the EventListener function startChatClickHandler. It's like it's just not "hearing" the mouse clicks most of the time.

      The instance of the button is called startChatButton and userNameInput is a instance of a TextInput. The code for this section is below.

      I've struggled with this for 12 hours straight and I am at my wits end. Anyone who can help with this will have my undying gratitude.

      import mx.controls.Alert;
      var mainpicpath:String;
      var loadit_lv:LoadVars = new LoadVars();
      var userdata_so:SharedObject = SharedObject.getLocal("user_data");
      var tempName:String;
      //var buttonlistenerObject:Object = new Object();

      profileText.text = "Still loading...";
      userNameInput.text = chatName;
      tempName = userdata_so.data.chatname;
      if (tempName.length > 0)
      {
      userNameInput.text = tempName;
      }

      profileText.text = "Profile text failed to load.";

      function startChatClickHandler (evt:Object):Void // <----- HERES THE PART THAT ONLY SOMETIMES GETS TRIGGERED, MUCH WORST IN FIREFOX
      {
      Alert.show("function click triggered","Info");
      _global.userName = userNameInput.text;
      if (_global.userName.length > 0)
      {
      userdata_so.data.chatname = userNameInput.text;
      userdata_so.flush();
      }
      else
      {
      _global.userName = "Guest";
      }
      nc.connect("rtmp://my flash media server);
      }
      startChatButton.addEventListener("click", startChatClickHandler);

      function enter(ev)
      {
      Alert.show("function enter triggered","Info");
      startChatClickHandler(ev);
      }
      userNameInput.addEventListener("enter", this); //<---- THIS ALWAYS WORKS

      function onConnect(ev)
      {
      //Alert.show("You are connected to: " + nc.uri, "Information");
      gotoAndPlay("Main");
      }

      mainpicpath = " http://www.mywebsite.com/site_images/profiles/mainpic-" + channel + ".jpg";
      loadMovie(mainpicpath, "loginpic");

      loadit_lv.onData = function(src:String)
      {
      if (src != undefined)
      {
      profileText.text = src;
      }
      else
      {
      profileText.text = "Error loading profile text.";
      }
      }

      loadit_lv.load(" http://www.mywebsite.com/profiletext/" + channel + ".txt");

      And this is how the flash movie is called from Perl:

      print qq{<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="720" height="500" id="customer_v16b" align="middle">};
      print qq{<param name="allowScriptAccess" value="sameDomain" />};
      print qq{<param name="movie" value=" http://www.mywebsite.com/flash/customer_v16b.swf?dummyVar=$dummy" />};
      print qq{<param name="FlashVars" value="channel=$host_page&hostName=$profile_info{' name'}&chatName=$chat_name">};
      print qq{<param name="quality" value="high" />};
      print qq{<param name="bgcolor" value="#FFFFFF" />};
      print qq{<embed src=" http://www.mywebsite.com/flash/customer_v16b.swf?dummyVar=$dummy" FlashVars="channel=$host_page&hostName=$profile_in fo{'name'}&chatName=$chat_name" quality="high" bgcolor="#FFFFFF" width="720" height="500" name="customer_v16b" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage=" http://www.macromedia.com/go/getflashplayer" />};
      print qq{</object>};
        • 1. Re: EventListener working 95% of the time in IE but only 2% in Firefox?
          c5mike Level 1
          I stripped almost all the code out and verified I could click on the button and that it was working correctly.

          Then I started adding things back in till it broke again.

          Heres as much of the original code that I could put back without breaking it:

          import mx.controls.Alert;
          var mainpicpath:String;
          var loadit_lv:LoadVars = new LoadVars();
          var userdata_so:SharedObject = SharedObject.getLocal("user_data");
          var tempName:String;
          //var buttonlistenerObject:Object = new Object();

          profileText.text = "Still loading...";
          userNameInput.text = chatName;
          tempName = userdata_so.data.chatname;
          if (tempName.length > 0)
          {
          userNameInput.text = tempName;
          }

          profileText.text = "Profile text failed to load.";

          function startChatClickHandler (evt:Object):Void
          {
          Alert.show("function click triggered","Info");
          _global.userName = userNameInput.text;
          if (_global.userName.length > 0)
          {
          userdata_so.data.chatname = userNameInput.text;
          userdata_so.flush();
          }
          else
          {
          _global.userName = "Guest";
          }
          //nc.connect('rtmp:/GPL_chat_alpha/chat', _global.userName,"customer",hostName);
          nc.connect("rtmp://myflashmediaserver", _global.userName,"customer",hostName,channel);
          }
          startChatButton.addEventListener("click", startChatClickHandler);

          function onConnect(ev)
          {
          //Alert.show("You are connected to: " + nc.uri, "Information");
          gotoAndPlay("Main");
          }

          The following sections of code will break it (in that clicking on the button no longer does anything), either together or one at a time:

          function enter(ev)
          {
          Alert.show("function enter triggered","Info");
          startChatClickHandler(ev);
          }
          userNameInput.addEventListener("enter", this);

          ------------------------------------------------------------

          mainpicpath = " http://www.girlsplaylive.com/site_images/profiles/mainpic-" + channel + ".jpg";
          loadMovie(mainpicpath, "loginpic");

          ------------------------------------------------------------

          loadit_lv.onData = function(src:String)
          {
          if (src != undefined)
          {
          profileText.text = src;
          }
          else
          {
          profileText.text = "Error loading profile text.";
          }
          }

          loadit_lv.load(" http://www.girlsplaylive.com/profiletext/" + channel + ".txt");


          So the question is why does this happen and whats the best way to fix it?