1 of 3
1
Simple Flash Client? 
Posted: 23 July 2008 11:46 AM   [ Ignore ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

Hello,

I’m working on a surface table that is going well. But i’ve got a problem with the software, i downloaded some source files but I can’t find the option I need. I see coloured dots while touching de surface. But how do I link a movieclip from my library to the dots. So where the dot is I want to have my movieclip.

The examples I downloaded where not based on movieclips so I can’t find the sulotion.

I hope someone can help with the Action script code for this.

Thanks a lot.

Ivo

Profile
 
 
Posted: 24 July 2008 12:35 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  474
Joined  2006-11-09

Hey Ivo,

Try checking out the AS3 folder on http://touchlib.googecode.com/

I am not sure what source you are discussing… where did you download from?

Good luck smile

 Signature 

~

Profile
 
 
Posted: 24 July 2008 02:27 AM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

Yes that’s the one I downloaded. I was working with Ripples.fla. I removed the water effect and I only see the dots. But now I want to make a movieclip in flash that appears on the dots. Do you know how to do that.

This is what I got:

package 
{
    import flash
.display.Bitmap;
    
import flash.display.BitmapData;
    
    
import flash.display.*;        
    
import flash.events.*;
    
import flash.net.*;
    
import whitenoise.*;    
    
import flash.geom.*;            
    
    
import flash.text.*;
    
    
    
import flash.filters.*;


    
public class RippleSurface extends MovieClip
    {
//        [Embed(source="brush.swf", symbol="Brush")]
//        public var Brush:Class;


        
        
private var blobs:Array;        // blobs we are currently interacting with        
        
        
internal var sourceBmp:BitmapData;        
        
internal var paintBmpData:BitmapData;
        
internal var paintBmpData2:BitmapData;        
        
private var buffer:BitmapData;        
        
private var paintBmp:Bitmap;
        
private var output:Bitmap;
        
private var brush:MovieClip;
        
private var logo:MovieClip;
        
private var filter:BitmapFilter;
        
private var filter2:BitmapFilter;        
        
private var symbol 1:Button;

        
private var dispFilt:BitmapFilter;                
        
        
private var outputBmpData:BitmapData;                
        
private var surface:BitmapData;                        
        
        
internal var pt = new Point(0,0);
        
internal var matrix1 = new Matrix();        
        
                
        function 
addBlob(id:NumberorigX:NumberorigY:Number)
        
{
            
for(var i=0i<blobs.lengthi++)
            
{
                
if(blobs[i].id == id)
                    return;
            
}
            
            blobs
.push{ididorigXorigXorigYorigYmyOrigXxmyOrigY:y} );
        
}
        
        
function removeBlob(id:Number)
        
{
            
for(var i=0i<blobs.lengthi++)
            
{
                
if(blobs[i].id == id
                
{
                    blobs
.splice(i1);        
                    return;
                
}
            }
        }
        
        
function update(e:Event)
        
{

            
for(var i:int 0i<blobs.lengthi++)
            
{
                
var tuioobj:TUIOObject TUIO.getObjectById(blobs[i].id);
                
                
// if not found, then it must have died..
                
if(!tuioobj)
                
{
                    removeBlob
(blobs[i].id);
                
else {
                    
var localPt:Point parent.globalToLocal(new Point(tuioobj.x*0.125tuioobj.y*0.125));                                        
                    var 
m:Matrix = new Matrix();
                    
m.translate(localPt.xlocalPt.y);
                    
sourceBmp.draw(brushmnull'overlay');
                
}
                
            }
            
            
            paintBmpData
.applyFilter(sourceBmppaintBmpData.rectptfilter);
            
//            paintBmpData2.applyFilter(paintBmpData2, paintBmpData.rect, pt, filter2);            

            
outputBmpData.applyFilter(surfaceoutputBmpData.rectptdisp);
            
            
buffer sourceBmp;
            
sourceBmp paintBmpData.clone();
//            buffer.copyPixels(sourceBmp, sourceBmp.rect, pt);
//            sourceBmp.copyPixels(paintBmpData, paintBmpData.rect, pt);

        
}
        
        
        public 
function downEvent(e:TUIOEvent)
        
{        
            
if(e.stageX == && e.stageY == 0)
                return;            
            
            var 
curPt:Point parent.globalToLocal(new Point(e.stageXe.stageY));                                    
            
symbol 1._x 0;
symbol 1._y 0;
            
addBlob(e.IDcurPt.xcurPt.y);
            

                
            
e.stopPropagation();
        
}
        
        
        
        public 
function upEvent(e:TUIOEvent)
        
{        
                
            
//removeBlob(e.ID);            
                
            
e.stopPropagation();                
                
        
}        

        public 
function moveHandler(e:TUIOEvent)
        
{
        }
        
        public 
function rollOverHandler(e:TUIOEvent)
        
{
        }
        
        public 
function rollOutHandler(e:TUIOEvent)
        
{
        
        }        
        
    }
}

And is is also possible to put in buttons in my project so when I touch an object it will press the button.

Thanks for your help.

Profile
 
 
Posted: 24 July 2008 03:25 AM   [ Ignore ]   [ # 3 ]
Elite
Avatar
RankRankRankRank
Total Posts:  460
Joined  2008-02-12

Ivo something like this was done before you can find more information here http://nuigroup.com/wiki/Building_Your_First_Application/ and here http://nuigroup.com/forums/viewthread/2451/

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 24 July 2008 03:56 AM   [ Ignore ]   [ # 4 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

i tried this code:

package app.demo.MyTouchApp{

    import flash
.display.*;
    
import flash.events.*;
    
import app.core.action.RotatableScalable;

    
public class MyTouchApp extends RotatableScalable {

        public 
function MyTouchApp() {

            
//--------connect to TUIO-----------------
            
TUIO.init(this,'localhost',3000,'',true);
            
trace("MyTouchApp Initialized");
            
//----------------------------------------        

            
addEventListener(MouseEvent.MOUSE_DOWNonMouseDown); // adds an event listener looking for a mouse click - runs "onMouseDown"
        
}
        
        
        private 
function onMouseDown(event:MouseEvent):void { //creats a circle when the mouse is clicked

            
var circle:Sprite = new Sprite();
            
            
circle.graphics.lineStyle(100xff0000); //set line width to 10px and red
            
circle.graphics.drawCircle(0,0,40); // draw a 40px circle
            
circle.mouseX//put it where the mouse clicked
            
circle.mouseY;

            
addChild(circle); //add the circle to the plane
        
}
    }
}

But i get no result in my project only see the coloured blobs where I click is there an sample available with only this simple source in a FLA file.

Profile
 
 
Posted: 24 July 2008 08:41 AM   [ Ignore ]   [ # 5 ]
Sr. Member
RankRankRank
Total Posts:  69
Joined  2008-05-31

Sadly not right now. But I will help you through it.

Do you have that sample code working currently? (it just adds red circles where you click the mouse, NOT TOUCH, and allows you to move/ scale around)

do you need the movie clips to move or be scaleable?

But, it sounds like you you have it working… right? Im actually a little confused as to what you are looking for.

if not…
Do you know how to link this as file to an fla?
And do you know any AS3?

Asking mainly so I can tell you what you need to know to get it working.

Profile
 
 
Posted: 24 July 2008 08:51 AM   [ Ignore ]   [ # 6 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

I know a little bit about as3, just starting using it. I only want to make a movie clip to move.

I’ve got a AS file linked to flash. It’s the as file from a ripple surface sample. But I want to include in that file a code to move a movie clip. The movie clip will appear on the positions of the touch.

Profile
 
 
Posted: 24 July 2008 09:24 AM   [ Ignore ]   [ # 7 ]
Sr. Member
RankRankRank
Total Posts:  69
Joined  2008-05-31

Only one movie clip? or every time you touch, a new one?

also, is the movieclip a photo, an swf, or...?

You need to create a new fla fie and a new .as file.

in the properties of the fla click settings (next to “publish:")
next to the drop down for actionscript version, click on settings
at the bottom for classpath hit plus sign and enter
../int
and the same again for:
../ext

save the fla file in (the touchlib folder) AS3/src (name it what you want)
save the .as file in AS3/int/app/demo (name it MyTouchApp.as )

in the fla file in properties window, for the Document class enter
app/demo/MyTouchApp.as

it should have no error… click the pencil button next to it, and it should take you to your .as file if it worked properly.

They are now linked.

In the as file use this code.

package app.demo.MyTouchApp{ //adds a circle where you touch (no resize)

    
import flash.display.*;        
    
import flash.events.*;
    
import flash.net.*;
    
import flash.geom.*;  
    
import app.core.action.RotatableScalable;      

    
public class MyTouchApp extends RotatableScalable {

        public 
function MyTouchApp() {

            
//--------connect to TUIO-----------------
            
TUIO.init(this,'localhost',3000,'',true);
            
trace("MyTouchApp Initialized");
            
//----------------------------------------        

            
addEventListener(TouchEvent.MOUSE_DOWNtouchDown); //run touchdown, when touched
        
}
        
        public 
function touchDown(e:TouchEvent):void{        
                        
            
var curPt:Point parent.globalToLocal(new Point(e.stageXe.stageY)); //convert touch points to x,y                
            
            
var circle:Sprite = new Sprite(); //create a new sprite
            
            
circle.graphics.lineStyle(100xff0000); //set line width to 10px and red
            
circle.graphics.drawCircle(0,0,40); // draw a 40px circle
            
circle.curPt.x//put it where touch is (x cord)
            
circle.curPt.y//put it where touch is (y cord)

            
addChild(circle); //add the circle where touch happened
            
        
}
    }
}

I have not figured out how to make a file move after touching it, but I think this code is closer to what you want to do. It adds a circle where ever you touch every time though.

you could make it a movie clip im sure, and probably also imit it to one if you wanted?

Im really new to this.

Profile
 
 
Posted: 24 July 2008 09:58 AM   [ Ignore ]   [ # 8 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

i get an error while doing this:

in the fla file in properties window, for the Document class enter
app/demo/MyTouchApp.as

About alphanumeric

Profile
 
 
Posted: 24 July 2008 10:07 AM   [ Ignore ]   [ # 9 ]
Sr. Member
RankRankRank
Total Posts:  69
Joined  2008-05-31

What doe the error say exactly?

Ivo - 24 July 2008 09:58 AM

i get an error while doing this:

in the fla file in properties window, for the Document class enter
app/demo/MyTouchApp.as

About alphanumeric

Profile
 
 
Posted: 24 July 2008 10:12 AM   [ Ignore ]   [ # 10 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

Class names must be valid indentifiers. Please enter a class name that contains only alphanumeric characters or supported symbols.

Profile
 
 
Posted: 24 July 2008 10:23 AM   [ Ignore ]   [ # 11 ]
Sr. Member
RankRankRank
Total Posts:  69
Joined  2008-05-31

I bet something is not copying correctly.
Did you try hand typing it in?

An you are using an AS3 fla file correct?

Profile
 
 
Posted: 24 July 2008 10:26 AM   [ Ignore ]   [ # 12 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

Yes I try again

When I use ‘\’ or ‘/’ it gives that error.
When I only fill in MyTouchApp.as it works but says could not find file

Profile
 
 
Posted: 24 July 2008 11:19 AM   [ Ignore ]   [ # 13 ]
Sr. Member
RankRankRank
Total Posts:  69
Joined  2008-05-31

Ahhh… sorry

use . not /

Sorry… im still a php boy.

Profile
 
 
Posted: 24 July 2008 11:30 AM   [ Ignore ]   [ # 14 ]
New Member
Rank
Total Posts:  23
Joined  2008-07-23

Ok that works, file is found but when I compile I get the following error:
1017: The definition of base class RotatableScalable was not found.
5000: The class ‘app.demo.MyTouchApp’ must subclass ‘flash.display.MovieClip’ since it is linked to a library symbol of that type.

Profile
 
 
Posted: 24 July 2008 11:36 AM   [ Ignore ]   [ # 15 ]
Sr. Member
RankRankRank
Total Posts:  69
Joined  2008-05-31

Try

You probably need to change “extends Sprite” to extends MovieClip…

but im not sure

package app.demo.MyTouchApp{ //adds a circle where you touch (no resize)

    
import flash.display.*;        
    
import flash.events.*;
    
import flash.net.*;
    
import flash.geom.*;  

    
public class MyTouchApp extends Sprite {

        public 
function MyTouchApp() {

            
//--------connect to TUIO-----------------
            
TUIO.init(this,'localhost',3000,'',true);
            
trace("MyTouchApp Initialized");
            
//----------------------------------------        

            
addEventListener(TouchEvent.MOUSE_DOWNtouchDown); //run touchdown, when touched
        
}
        
        public 
function touchDown(e:TouchEvent):void{        
                        
            
var curPt:Point parent.globalToLocal(new Point(e.stageXe.stageY)); //convert touch points to x,y                
            
            
var circle:Sprite = new Sprite(); //create a new sprite
            
            
circle.graphics