Wednesday, 7 November 2012

Error code .1120: Access of undefined property NetStatusEvent. in Action Script


Error code .1120: Access of undefined property         NetStatusEvent.

when repeating the flv file in action script.


                               
Recently we  developed a project in action script .In that project we are playing the flv file by using  NetStream object in action script. Here we face problem as mentioned above. We want to repeat the file(video) when it is reaches the end . For that we add an event to the NetStream object.

Below the snippet of code
                      
                  ns.addEventListener (NetStatusEvent.NET_STATUS, onStatus1)

                              //   "ns" means netStream object


We write the code in onStaus1() function.
                             

                               public function onStatus1(item:Object):void
                                {                             
                                       if (item.info.code == "NetStream.Unpause.Notify")
                                                {
                                                if (Math.floor(ns.bufferLength)>=Math.floor(lastPosition))
                                                                {             
                                                                                ns.seek(0);
                                                                                ns.resume();     
                                                                }
                                                }
                              }

           After compiling this code we got error like  Error code .1120: Access of undefined property NetStatusEvent. We felt everything is good but it shows error. After some search we found the solution. We need to import package as mentioned below.

Import flash.events.NetStatusEvent;
             
                  After adding this package we got out put what we expected. Happy coding.

No comments:

Post a Comment