CreITve
02-17-2009, 04:33 PM
Hi everyone, I recently started learning Flex/Air platform (like it much). Actually i'm new to AS3 too, so i've got a problem.
While learning how to use XMLSocket object i wrote this mxml code at Flex Builder 3 : (copy at pastebin for your corections (http://kefir.pastebin.com/m7605dc57))
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button x="171" y="136" label="Button" width="264" height="63" click="init()"/>
<mx:Script>
<![CDATA[
import flash.net.XMLSocket;
var mySock:XMLSocket = new XMLSocket();
private function init():void
{
mySock.addEventListener(Event.CONNECT, connected);
mySock.addEventListener(DataEvent.DATA, dataReceived);
mySock.connect("localhost",8989);
}
private function connected(event:Event):void
{import flash.net.XMLSocket;
mySock.send("Hi");
}
private function dataReceived(dataEvent:DataEvent):void
{
trace(dataEvent.data);
var xml:XML = new XML(dataEvent.data);
}
]]>
</mx:Script>
</mx:WindowedApplication>
And before the running i got these errors:
Severity and Description Path Resource Location Creation Time Id
1061: Call to a possibly undefined method connect through a reference with static type XMLSocket. XMLSocket/src XMLSocket.mxml line 16 1234888871500 258
1061: Call to a possibly undefined method send through a reference with static type XMLSocket. XMLSocket/src XMLSocket.mxml line 21 1234888871515 259
I know it must be an "another n00b's stupid mistake", but forum is for asking, isn't it?;)
While learning how to use XMLSocket object i wrote this mxml code at Flex Builder 3 : (copy at pastebin for your corections (http://kefir.pastebin.com/m7605dc57))
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button x="171" y="136" label="Button" width="264" height="63" click="init()"/>
<mx:Script>
<![CDATA[
import flash.net.XMLSocket;
var mySock:XMLSocket = new XMLSocket();
private function init():void
{
mySock.addEventListener(Event.CONNECT, connected);
mySock.addEventListener(DataEvent.DATA, dataReceived);
mySock.connect("localhost",8989);
}
private function connected(event:Event):void
{import flash.net.XMLSocket;
mySock.send("Hi");
}
private function dataReceived(dataEvent:DataEvent):void
{
trace(dataEvent.data);
var xml:XML = new XML(dataEvent.data);
}
]]>
</mx:Script>
</mx:WindowedApplication>
And before the running i got these errors:
Severity and Description Path Resource Location Creation Time Id
1061: Call to a possibly undefined method connect through a reference with static type XMLSocket. XMLSocket/src XMLSocket.mxml line 16 1234888871500 258
1061: Call to a possibly undefined method send through a reference with static type XMLSocket. XMLSocket/src XMLSocket.mxml line 21 1234888871515 259
I know it must be an "another n00b's stupid mistake", but forum is for asking, isn't it?;)