A quit button in flash
Posted: 17 July 2008 11:11 PM   [ Ignore ]
New Member
Avatar
Rank
Total Posts:  57
Joined  2008-06-29

I want to join a quit button in flash(*.swf).What I should write the code?Where to insert ?
For example ripples.swf and photo.swf,Have already existed.
please help me,thank you!

 Signature 

New Technology -_- New Life
http://www.chinamultitouch.com From China中国北京

Profile
 
 
Posted: 18 July 2008 12:21 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  537
Joined  2006-11-09

What do you mean? You want to close the SWF window? Try this smile

First you’ll have to import fscommand:

import flash.system.fscommand;

Then you can use the follwing function for the button click handler:

button.addEventListener(MouseEvent.CLICKclickHandler);

private function 
clickHandler(event:MouseEvent):void {
fscommand
("quit");
}

 Signature 

~

Profile
 
 
Posted: 18 July 2008 01:53 AM   [ Ignore ]   [ # 2 ]
New Member
Avatar
Rank
Total Posts:  57
Joined  2008-06-29

I want to close the flash window through the multitouch, but not click with the mouse.
Thank you ,I try

 Signature 

New Technology -_- New Life
http://www.chinamultitouch.com From China中国北京

Profile
 
 
Posted: 18 July 2008 03:08 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  596
Joined  2008-02-12

using the tuio classes in specific the touchEvent Class you can do the same

first you import all dependencies

import flash.system.fscommand
import flash.events.TouchEvent;
import flash.events.*;

Then you can use the following function for the button click and touch handlers:

button.addEventListener(MouseEvent.CLICKclickHandler);
button.addEventListener(TouchEvent.MOUSE_DOWNtouchHandler);

private function 
clickHandler(e:Event):void {
fscommand
("quit");

private function touchHandler (e:Event):void{
fscommand
("quit");
}

this way your button will react to both mouse clicks and touch events wink

or if you wanted to you could use a touchlib wrapper its in the elements folder…

then it would be as simple as

WrapperObject.addEventListener(MouseEvent.CLICKclickHandler);

this pretty much does the same thing…

Taha

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 20 July 2008 09:47 PM   [ Ignore ]   [ # 4 ]
New Member
Avatar
Rank
Total Posts:  57
Joined  2008-06-29

I define the button, after writing into the following code, the mistake appears to brief on,

import flash.system.fscommand;
import flash.events.TouchEvent;
import flash.events.*;
button.addEventListener(MouseEvent.CLICK, clickHandler);
button.addEventListener(TouchEvent.MOUSE_DOWN, touchHandler);
private function clickHandler(e:Event):void {
fscommand("quit");
}
private function touchHandler (e:Event):void{
fscommand("quit");
}
WrapperObject.addEventListener(MouseEvent.CLICK, clickHandler);

Scene 1, layers’ Dummy Layer ‘, frame 1,7 lines
1013: private attribute can only be used in class attributes definition.
private function clickHandler (e: Event): void (

Scene 1, layers’ Dummy Layer ‘, frame 1,10 lines
1013: private attribute can only be used in class attributes definition.
private function touchHandler(e:Event):void{

 Signature 

New Technology -_- New Life
http://www.chinamultitouch.com From China中国北京

Profile
 
 
Posted: 20 July 2008 10:30 PM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  596
Joined  2008-02-12

First of all these AS3 code is designed to be used in an AS3 Classes file not within frames, change it from private to just function… Also another thing i see is that you arent importing the wrapper object, nor are you defining your button or wrapper object.

you need this to import the wrapper object

import app.core.element.Wrapper

then you need to define your wrapperobject something like

var WrapperObject:Wrapper = new Wrapper('button instance  name');

also i suggest you looking to Using Flash Develop thats a lot better program for making flash based MT apps it has a better compiler. Take a look at this link http://nuigroup.com/forums/viewthread/1689/

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 23 July 2008 03:55 AM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  596
Joined  2008-02-12

enjoylife here is the the project with all the necessary files, in the src folder you will find both a FD project and a FlashCS3 fla

if you have any questions just ask

and btw i used the wrapper class here, but this could have most easily have been done with using touchevent

File Attachments
closeApp.zip  (File Size: 34KB - Downloads: 59)
 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 26 July 2008 08:03 PM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  596
Joined  2008-02-12

Hey enjoylife im not sure if this is what you wanted… but i created the closed button code into an object so you can added to any main to allow you quit…

File Attachments
closeApp_objectClass.zip  (File Size: 36KB - Downloads: 51)
 Signature 

My MultiTouch Blog

Profile