4 Replies Latest reply on Sep 30, 2010 11:35 PM by Flex Rock

    Flex Event isn't fired

    EliezerReis Level 1

      Hi,

       

      I have te following situation:

       

       

      Main:

      <fx:Script>
           <![CDATA[
                private function onClick(event:MouseEvent):void {
                     mp3Player.connect("rmtp://localhost/snews");
                }
           ]]>
      </fx:Script>
      
      <s:HGroup>
           <s:TextInput id="file" text="Storage01/The Only.mp3" width="150"/>
           <s:Button click="onClick(event)"/>
      </s:HGroup>
      <view:Mp3Player id="mp3Player"/>

       

       

      Mp3Player

      public class Mp3Player extends SkinnableContainer {

           public function Mp3Player() {
           _nc=new NetConnection();
           _nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
           _nc.connect("rmtp://localhost/snews");
           }

       

           public function netStatus(event:NetStatusEvent):void {
           //NEVER FIRED
           }

       

           public function connect(url:String):void {
           _nc.connect(url);
           }

      }

       

       

      On this peace of code you can see that my button call a method on my Mp3Player class to connect on my stream server. You can see that on my Mp3Player constructor I configure a listener to NestStatusEvent. So, When I call connect method the event should be called but it doesn't happen. But, if i use my netconnection outside of this class, direct in my main.mxml it works great.

       

      I don't know what happen but if a event call a method that should dispatch another event the second event will not be dispatched. Why? How can I fix it?