Actionscript 3 problems with tBeta and Actionscript 2 :(
Posted: 03 March 2009 08:41 AM   [ Ignore ]
Rank
Joined  2009-02-10
Total Posts:  4
New Member

Hi I am hoping someone can help me.

Long story short, I am using a downloaded actionscript 3 file which receives data from tbeta.

My knowledge only goes as far as actionscript 2 and I am having trouble deleting, moving and editing script in this new as3 file. It seems actionscript layout has changed quite a lot but due to time, I have decided to send data from that file, into my as2 file externally.... sort of.

here is the file which I searched via tinternet: http://blog.circlecube.com/2008/03/12/local-connection-actionscript-communicate-between-seperate-flash-files-tutorial/

Although these scripts work really nicely, putting them into the cs3 has me in a pickle yet again. The only bit I need is the send script:

var sending_lc:LocalConnection = new LocalConnection();
sending_lc.send("fromRed", “recieveRedText”, tuioobj.x);

But as stated above, this as3 file is not letting me add data.

I wish I could make more sense of this but my question is, is there anything obvious I am missing to get these two lines to work inside a as3? The error I am getting is it does not understand the LocalConnection line. Here is the full function.

package app.demo.MyTouchApp{

    import flash
.events.TUIO// allows to connect to touchlib/tbeta
 
    
import flash.display.*;
    
import flash.events.*;
    
import flash.geom.*; // needed for curPt;
 
    
public class MyTouchApp extends Sprite {
        
    
var posx:Number;
    var 
posy:Number;
 
        public function 
MyTouchApp():void {
 
            
//--------connect to TUIO-----------------
            
TUIO.init(this,'localhost',3000,'',true);
            
trace("MyTouchApp Initialized");
            
//---------------------------------------- 
 
            
addEventListener(TouchEvent.MOUSE_DOWNdownEventfalse0true); // run when finger down
            
addEventListener(TouchEvent.MOUSE_UPupEventfalse0true); // run when finger up
            
addEventListener(Event.ENTER_FRAMEupdaterfalse0true); // keep running
        
}

        
function updater(e:Event):void {
            
for (var i:int 0blobs.lengthi++) 
                
var tuioobj:TUIOObject=TUIO.getObjectById(blobs[i].id);
 
                if (! 
tuioobj{
                    removeBlob
(blobs[i].id);
                
else if (parent != null{
 
                    lines[
"line"+blobs[i].id].graphics.lineTo(tuioobj.xtuioobj.y);

                                       
//trace("(" + String(tuioobj.x) + ", " + String(tuioobj.y) + ")"); //trace the x and y coordinates
                    
                    
posx tuioobj.x;
                    
posy tuioobj.y;
                    
                    
//Sending
                    
var sending_lc:LocalConnection = new LocalConnection();
                    
sending_lc.send("fromRed""recieveRedText"tuioobj.x);
                
}
            }
        }
    }
}

So the problem is not the files talking to each other (yet) but just getting snippets of code into this as3 script.

Profile
 
 
Posted: 03 March 2009 05:29 PM   [ Ignore ]   [ # 1 ]
Avatar
RankRank
Joined  2008-02-25
Total Posts:  119
Jr. Member

Hey Guy, you should post the exact error code you get.  It has helpful information from the compiler that can help us diagnose your problem (also this post should be in the AS3 forum).

The code doesn’t work because you didn’t import the LocalConnection class like you did with the flash.display.*, etc.  In AS3 you are required to manually import every class you use in your class.  Flex Builder does this automatically when you type in a class name, but Flash doesn’t for some reason.  You need to add “import flash.net.LocalConnection” before you try to instantiate that class.

Parker

Profile
 
 
Posted: 04 March 2009 06:32 AM   [ Ignore ]   [ # 2 ]
Rank
Joined  2009-02-10
Total Posts:  4
New Member

that worked a treat! Thank you very much smile

Profile