Skip navigation
Currently Being Moderated

Problem with code

Mar 30, 2012 12:50 PM

Im new to Flex, and I got some problem with this code.

 

The problem is the "NewValue" I want to be updated thru UDP, any help?

 

 

 

 

<fx:Script>

              <![CDATA[           

                                 

              import be.aboutme.nativeExtensions.udp.UDPSocket;            

              import flash.events.TimerEvent;

              import flash.utils.Timer;        

              import mx.collections.ArrayCollection;

              import mx.events.FlexEvent;      

              private var udpSocket:UDPSocket;

                    

             

                     protected function applicationCompleteHandler(event:FlexEvent):void

                     {

                           udpSocket = new UDPSocket();

                           udpSocket.addEventListener(DatagramSocketDataEvent.DATA, udpDataHandler);

                           udpSocket.bind(1000);

                           udpSocket.receive();

                     }

                    

                     protected function udpDataHandler(event:DatagramSocketDataEvent):void

                     {

                           try

                           {

                                  var o:Object = event.data.readObject();

                                  switch(o.command)

                                        var NewValue = new o:Object;   <---------- HERE!  

                           }

                     }

                    

             

              [Bindable]

              public var myArray:ArrayCollection = new ArrayCollection();

              public function initTimer():void

              {

                     var myTimer:Timer = new Timer(100, 0);

                     myTimer.addEventListener("timer", timerHandler);

                     myTimer.start();

              }

             

              public function timerHandler(event:TimerEvent):void

              {

                     var obj:Object = new Object();

                     var NewValue;

                     obj.time = getTimer();

                     obj.Value = NewValue;   <---------- HERE!

                     myArray.addItem(obj);

                    

              }

              ]]>

       </fx:Script>

 

 
Replies
  • Currently Being Moderated
    Apr 2, 2012 8:13 AM   in reply to fsoender

    Your syntax looks funny to me.

    I am not familiar with that approach.

    Following are some suggestions.

     

    try something like

    var o:Object = event.data.readObject();

    var NewValue = o;

     

    or if you are trying to typecast then

    var NewValue = o as Object;

    or

    var NewValue = Object(o);

     

    also it looks like you are missing the 'catch' part of the 'try / catch' structure.

     

    try

    {

         ... some code here

    }

    catch (err:Error)

    {

         ... handle error here if it happens

    }

     

    I hope this helps you a bit.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points