Frame can't move in actionscript3.0 - actionscript-3

Hi i have three class Mainintro.as, Gameplay.as, Lastscene.as, here i used this code to call another class.. Frame moving continuously not stoping...
Mainintro.as
package
{
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
import com.greensock.*;
import com.greensock.easing.*;
import Globe;
public class MainIntro
{
public function MainIntro(Mc:MovieClip)
{
Globe.self.realstage = Mc;
Globe.self.realstage.intro_mc.stop();
Mc.intro_mc.play_mc.addEventListener(MouseEvent.CLICK, GameStart);
Mc.intro_mc.play_mc.buttonMode = true;
Mc.intro_mc.ins_btn.buttonMode = true;
var gameply:GamePlay = new GamePlay();
}
public function GameStart(e:MouseEvent):void
{
{
Globe.self.realstage.gotoAndPlay("game");
}
}
}
}
Here in this class file (Gameplay.as) the code occurs in the public function onClick caused by :
Globe.self.realstage.click_mc.addEventListener(MouseEvent.CLICK,onClick);
Which gives a null object reference error but I've given the correct name for
instance and then I tried to run ignore the errors then the frame moving not
stopping...
Gameplay.as
package
{
import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import Globe;
public class GamePlay
{
var currentEntry:int = -1;
var aList:Array =
[
{card:Globe.self.realstage.joker_mc, x:605.55, y:195.45},
{card:Globe.self.realstage.king_mc, x:323.80, y:298.45},
{card:Globe.self.realstage.queen_mc, x:45.85, y:213.95},
{card:Globe.self.realstage.a_mc, x:605.55, y:195.45},
{card:Globe.self.realstage.ten_mc, x:323.80, y:298.45},
{card:Globe.self.realstage.five_mc, x:45.85, y:213.95},
{card:Globe.self.realstage.two_mc, x:605.55, y:195.45},
{card:Globe.self.realstage.nine_mc, x:323.80, y:298.45},
{card:Globe.self.realstage.four_mc, x:45.85, y:213.95},
];
public function GamePlay()
{
Globe.self.realstage.stop();
var gameply:LastScene = new LastScene();
Globe.self.realstage.click_mc.addEventListener(MouseEvent.CLICK,
onClick);
Globe.self.realstage.exit_mc.addEventListener(MouseEvent.CLICK,
lastScene);
}
public function lastScene(e:MouseEvent):void
{
Globe.self.realstage.gotoAndPlay("Scene");
}
public function onClick(e:MouseEvent):void
{
// Unsubscribe to avoid the mess with second click.
Globe.self.realstage.click_mc.removeEventListener(MouseEvent.CLICK,
onClick);
// Start process.
moveNext();
}
public function moveNext():void
{
Globe.self.realstage.currentEntry++;
// Stop the process if all the cards have been moved.
if (Globe.self.realstage.currentEntry >=
Globe.self.realstage.aList.length) return;
// Get the entry.
var anEntry:Object =
Globe.self.realstage.aList[Globe.self.realstage.currentEntry];
// Move the card.
Globe.self.realstage.TweenLite.to(Globe.self.realstage.anEntry['card'],
.4,
{x:Globe.self.realstage.anEntry['x'],y:Globe.self.realstage.anEntry['y'],
onComplete:moveNext});
}
}
}

I have used stop in the frame it is stopped now it's working good.

Related

as3 StageWebView in a class not displaying

I am sure this is an easy one. I have one Main.as class calling a another class that is loading a StageWebView. If called by itself the StageWebView works fine, but when I call it from another class it will not display. What simple thing am I forgetting?
Perhaps it has something to do with the "stage" in the loaded class?
Main.as
public function addPopeNews()
{
thePopeNews = new popeNews();
addChild(thePopeNews);
}
PopeNews.as
package com
{
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.*;
import flash.net.URLRequest;
import flash.media.StageWebView;
import flash.geom.Rectangle;
public class popeNews extends MovieClip
{
public var backBar:popeNewsBar;
public var webView:StageWebView;
public function popeNews()
{
webView=new StageWebView();
webView.stage = this.stage;
webView.loadURL("www.myUrl.com");
trace("POPE NEWS!!!"); /// trace works!
backBar = new popeNewsBar();
backBar.width = Main._screenX;
backBar.scaleY = backBar.scaleX;
webView.addEventListener(Event.COMPLETE, webLoaded);
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING,onChanging);
}
public function webLoaded(e:Event)
{
trace("web loaded"); // trace works!!
if (webView.isHistoryBackEnabled)
{
addChild(backBar);
backBar.bb.addEventListener(MouseEvent.CLICK, goBack);
webView.viewPort = new Rectangle(0,backBar.height,Main._screenX,Main._screenY - backBar.height);
}
else
{
webView.viewPort = new Rectangle(0,0,Main._screenX,Main._screenY);
}
}
public function goBack(e:Event)
{
if (webView.isHistoryBackEnabled)
{
trace("Called GO BACK");
webView.historyBack();
removeChild(backBar);
backBar.bb.removeEventListener(MouseEvent.CLICK, goBack);
return;
}
if (webView.isHistoryForwardEnabled)
{
webView.historyForward();
return;
}
}
public function onError(e:ErrorEvent):void
{
//infoBox.text="Page is not available. Try reloading.";
}
public function onChanging(e:LocationChangeEvent):void
{
//webView.viewPort = null;
trace("Called CHANGING!!!");
}
///
}
}
You are right, the stage is null in the PopeNews constructor. You should put your initialization code into a new method, and listen for the ADDED_TO_STAGE event.
public function popeNews()
{
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
}
private function addedToStageHandler(ev:Event):void
{
webView=new StageWebView();
webView.stage = this.stage;
webView.loadURL("www.myUrl.com");
trace("POPE NEWS!!!"); /// trace works!
backBar = new popeNewsBar();
backBar.width = Main._screenX;
backBar.scaleY = backBar.scaleX;
webView.addEventListener(Event.COMPLETE, webLoaded);
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING,onChanging);
}
Also, by convention class names are capitalized.

how to bring movie clip on front in as3

I have two movieclips one over other. using mouse click event I want to bring one of them in the front. It works 1 or 2 times then it just stops responding to mouse clicks. I don't know what is happening. I tried hard but could not get it work.
Here is my code for document class :
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
public class THREE2DP extends MovieClip {
public var page11:page1;
public var page22:page2;
public var scene11:scene1;
public var scene22:scene2;
public function THREE2DP() {
// constructor code
stop();
createscene();
createpage2();
createpage1();
this.addEventListener(Event.ENTER_FRAME, enterframehandler);
}
public function enterframehandler(e:Event):void
{
if(scene11.front)
{
bringToFront(page11);
scene22.front = false;
}
if(scene22.front)
{
bringToFront(page22);
scene11.front = false;
}
}
private function bringToFront(mcl:MovieClip)
{
mcl.parent.setChildIndex(mcl,mcl.parent.numChildren - 1);
}
public function createpage1()
{
page11 = new page1();
addChild(page11);
page11.x = 0;
page11.y = 0;
}
public function createpage2()
{
page22 = new page2();
addChild(page22);
page22.x = 0;
page22.y = 0;
}
public function createscene()
{
scene11 = new scene1();
addChild(scene11);
scene11.x = 0;
scene11.y = 635;
scene22 = new scene2();
addChild(scene22);
scene22.x = 400;
scene22.y = 635;
}
}
}
here is code for scene11 movieclip custom class
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
public class scene1 extends MovieClip {
public var front:Boolean = false;
public function scene1() {
// constructor code
stop();
this.addEventListener(MouseEvent.CLICK, clickhandler, false, 0, true);
}
public function clickhandler(event:MouseEvent): void
{
front = true;
}
}
}
code for scene22 custom class is
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
public class scene2 extends MovieClip {
public var front:Boolean = false;
public function scene2() {
// constructor code
stop();
this.addEventListener(MouseEvent.CLICK, clickhandler, false, 0, true);
}
public function clickhandler(event:MouseEvent):void
{
front = true;
}
}
}
Upon click on movieclips scene11 and scene22, movieclip page11 and page22 should come on front of stage respectively but that happens only once for each page, after that nothing changes.
my earlier logic for custom classwas faulty. took me 2 day. added mouse_down event to make it work.
i some how managed to do this right by changing custom class code to this
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
public class scene1 extends MovieClip {
public var front:Boolean = false;
public function scene1() {
// constructor code
stop();
this.addEventListener(MouseEvent.MOUSE_DOWN, presshandler, false, 0, true);
this.addEventListener(MouseEvent.CLICK, clickhandler, false, 0, true);
}
public function presshandler(event:MouseEvent): void
{
front = true;
}
public function clickhandler(event:MouseEvent): void
{
front = false;
}
}
}
also modified document class code by calling pagechange() function from enterframehandler() function for sake of simplicity
public function pagechange()
{
if (scene11.front && scene22.front == false)
{
bringToFront(page11);
}
if (scene22.front && scene11.front == false)
{
bringToFront(page22);
}
}
private function bringToFront(mcl:MovieClip)
{
mcl.parent.setChildIndex(mcl,mcl.parent.numChildren - 1);
}
Instead of using that bringToFront method, you could just readd page11 and page22 on stage with addChild(). addChild always adds a child on front of everything else in the parent.
public function enterframehandler(e:Event):void
{
if(scene11.front)
{
addChild(page11);
scene22.front = false;
}
if(scene22.front)
{
addChild(page22);
scene11.front = false;
}
}

1009: Cannot access a property or method of a null object reference

I've been stuck with such an error for 2 days now, and however I search on solving this from the number of previous questions asked about this error, I still can't seem to get it to work, mainly because I don't understand it at all.
This my code :
package {
import flash.events.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import org.libspark.flartoolkit.support.pv3d.FLARBaseNode;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cone;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.materials.MovieAssetMaterial;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.objects.primitives.Cube;
[SWF(width=640, height=530, backgroundColor=0x808080, frameRate=30)]
public class Earth extends PV3DARApp {
private var _earth:DAE;
private var _teapot:DAE;
private var _bone:DAE;
protected var _baseNode:FLARBaseNode
public function Earth() {
addEventListener(Event.INIT, _onInit);
init('Data/camera_para.dat', 'Data/paris.pat');
}
private function _onInit(e:Event):void {
bulet.addEventListener(MouseEvent.CLICK, _tombolbulet);
teapot.addEventListener(MouseEvent.CLICK, _tombolteapot);
tulang.addEventListener(MouseEvent.CLICK, _tomboltulang);
addChild(bulet);
addChild(teapot);
addChild(tulang);
_earth = new DAE();
_earth.load('model/earth.dae');
_earth.scale = 10;
_earth.rotationX = 90;
//_markerNode.addChild(_earth);
_teapot = new DAE();
_teapot.load('model/teapot.DAE');
_teapot.scale = 10;
_teapot.rotationX = 90;
//_markerNode.addChild(_teapot);
_bone = new DAE();
_bone.load('model/bone.DAE');
_bone.scale = 10;
_bone.rotationX = 90;
//_markerNode.addChild(_bone);
function _tombolbulet (event:MouseEvent):void
{
remove_all();
_baseNode.addChild(_earth);
}
function _tombolteapot (event:MouseEvent):void
{
remove_all();
_baseNode.addChild(_teapot);
}
function _tomboltulang (event:MouseEvent):void
{
remove_all();
_baseNode.addChild(_bone);
}
function remove_all () : void
{
_baseNode.removeChild(_earth);
_baseNode.removeChild(_teapot);
_baseNode.removeChild(_bone);
}
//addEventListener(Event.ENTER_FRAME, _update);
}
/*private function _update(e:Event):void {
_earth.rotationZ += 0.5
_teapot.rotationZ += 0.5
_bone.rotationZ += 0.5
}*/
}
}
You should first call new DAE() on your children, then add them via addChild(), not vice versa. Also, there is no bulet declared, but there's a bone. Also, you remove all the children in remove_all(), while only one of them seems to be on screen at one single time. Also, you have a lot of misnamed variables, which mess the code.

AS3 browse client files from SWF in a server

newbie on AS3 here! :)
basically I'm trying to write an application that let the user choose an image file and display it (then I will manipulate pixels, so i don't want the application to store the image in a new file, just managing the ByteArray).
So far I wrote in Flash Develop some working code that show a window to choose the image and then display it. but when I upload to a server the generated files (myapplication.swf, expressinstall.swf, index.html, and the js folder) the window shows no more.
I'm using FileReference.browse() method.
What's wrong?
(edit: as pointed out from The_asMan here we miss some code, here it is - improved with the suggestion of The_asMan)
my package:
package searchfiles
{
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.FileReference;
import flash.net.FileReferenceList;
import flash.net.FileFilter;
import flash.events.*;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.display.DisplayObject;
/**
* ...
* #author ddd
*/
public class searchForFiles extends EventDispatcher
{
public var newfile:FileReference;
public var loader:Loader
public var bitmapimg:BitmapData;
public function searchForFiles() {
newfile = new FileReference();
newfile.addEventListener(Event.SELECT, onFileSelected);
newfile.addEventListener(Event.CANCEL, onCancel);
newfile.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
newfile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
trace("abbiamo instanziato un searchForFiles");
var textTypeFilter:FileFilter = new FileFilter("Image files (*.png, *.jpg, *tif)",
"*.png; *.jpg; *tif");
newfile.browse([textTypeFilter]);
}
public function onFileSelected(evt:Event):void
{
newfile.addEventListener(ProgressEvent.PROGRESS, onProgress);
newfile.addEventListener(Event.COMPLETE, onComplete);
newfile.load();
}
public function onProgress(evt:ProgressEvent):void
{
trace("Loaded " + evt.bytesLoaded + " of " + evt.bytesTotal + " bytes.");
}
public function onComplete(evt:Event):void
{
trace("File was successfully loaded.");
loader = new Loader();
loader.loadBytes(newfile.data);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
}
private function erroremanip(evt:IOErrorEvent):void {
trace("errore " + evt);
}
private var bitmapData:BitmapData
public function getBitmapData(e:Event):void {
var content:* = loader.content;
bitmapData = new BitmapData(content.width,content.height,true,0x00000000);
trace("loader.width = " +loader.width);
dispatchEvent( new Event(Event.COMPLETE));
//trace("get bitmap data called");
}
public function onCancel(evt:Event):void
{
trace("The browse request was canceled by the user.");
}
public function onIOError(evt:IOErrorEvent):void
{
trace("There was an IO Error.");
}
public function onSecurityError(evt:Event):void
{
trace("There was a security error.");
}
}
}
and here's the main()
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.errors.IOError;
import flash.events.*;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import searchfiles.searchForFiles;
/**
* ...
* #author ddd
*/
[SWF(width = "550", height = "600")]
public class Main extends MovieClip
{
public var file:searchForFiles;
public var mybtn:Loader = new Loader();
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
mybtn.addEventListener(MouseEvent.CLICK, mouseclicked);
mybtn.addEventListener(IOErrorEvent.IO_ERROR, erroremanip);
var urlqst:URLRequest = new URLRequest("preview_true.png");
mybtn.load(urlqst);
addChild(mybtn);
}
public function mouseclicked(e:MouseEvent):void {
trace("clicked");
file = new searchForFiles();
file.addEventListener(Event.COMPLETE, puttheimage);
}
private function erroremanip(e:IOError):void {
trace("ciao erroreio");
}
private function puttheimage(e:Event) :void {
addChild(file.loader);
}
}
}
FileReference.browse()
When outside local sandbox needs to be triggered via user interaction IE: mouseclick.
Basically, the click event needs to be in the stack somewhere.
You can verify this with.
file = new FileReference();
file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
However, you posted no code and it is very hard to determine exactly what you did wrong.
[EDIT]
package searchfiles
{
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.FileReference;
import flash.net.FileReferenceList;
import flash.net.FileFilter;
import flash.events.*;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.display.DisplayObject;
/**
* ...
* #author ddd
*/
public class searchForFiles extends EventDispatcher
{
public var newfile:FileReference;
public var loader:Loader
public var bitmapimg:BitmapData;
public function searchForFiles() {
newfile = new FileReference();
newfile.addEventListener(Event.SELECT, onFileSelected);
newfile.addEventListener(Event.CANCEL, onCancel);
newfile.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
newfile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
}
// new function
public function browse(event:Event):void{
var textTypeFilter:FileFilter = new FileFilter("Image files (*.png, *.jpg, *tif)", "*.png; *.jpg; *tif");
newfile.browse([textTypeFilter]);
}
public function onFileSelected(evt:Event):void
{
newfile.addEventListener(ProgressEvent.PROGRESS, onProgress);
newfile.addEventListener(Event.COMPLETE, onComplete);
newfile.load();
}
public function onProgress(evt:ProgressEvent):void
{
trace("Loaded " + evt.bytesLoaded + " of " + evt.bytesTotal + " bytes.");
}
public function onComplete(evt:Event):void
{
trace("File was successfully loaded.");
loader = new Loader();
loader.loadBytes(newfile.data);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
}
private function erroremanip(evt:IOErrorEvent):void {
trace("errore " + evt);
}
private var bitmapData:BitmapData
public function getBitmapData(e:Event):void {
var content:* = loader.content;
bitmapData = new BitmapData(content.width,content.height,true,0x00000000);
trace("loader.width = " +loader.width);
dispatchEvent( new Event(Event.COMPLETE));
//trace("get bitmap data called");
}
public function onCancel(evt:Event):void
{
trace("The browse request was canceled by the user.");
}
public function onIOError(evt:IOErrorEvent):void
{
trace("There was an IO Error.");
}
public function onSecurityError(evt:Event):void
{
trace("There was a security error.");
}
}
}
and here's the main()
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.errors.IOError;
import flash.events.*;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import searchfiles.searchForFiles;
/**
* ...
* #author ddd
*/
[SWF(width = "550", height = "600")]
public class Main extends MovieClip
{
public var file:searchForFiles;
public var mybtn:Loader = new Loader();
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
// moved to init
file = new searchForFiles();
file.addEventListener(Event.COMPLETE, puttheimage);
mybtn.addEventListener(MouseEvent.CLICK, mouseclicked);
mybtn.addEventListener(IOErrorEvent.IO_ERROR, erroremanip);
var urlqst:URLRequest = new URLRequest("preview_true.png");
mybtn.load(urlqst);
addChild(mybtn);
}
public function mouseclicked(e:MouseEvent):void {
trace("clicked");
// events need to be set before any active code is run in the object
// that is why we moved listeners or else you risk the listener
// not getting triggered
file.browse()
}
private function erroremanip(e:IOError):void {
trace("ciao erroreio");
}
private function puttheimage(e:Event) :void {
addChild(file.loader);
}
}
}
FileReference is for accessing files on the user's local machine. It sounds like you want to load a file from the same server that is hosting the SWF files.
You can't 'browse' the server from Actionscript - unlesss you write code on your server to enable that - but you can load files by name using URLLoader.

AS3 to get children in Gestureworks TouchSprite working

Recently just trying around with the Gestureworks multitouch.
Here I have some problem about button inside a TouchSprite, below is my code:
package
{
import com.gestureworks.core.GestureWorks;
import com.gestureworks.core.TouchSprite;
import com.gestureworks.events.GWGestureEvent;
import com.gestureworks.events.GWTouchEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Stage;
import flash.events.Event;
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
public class Main extends GestureWorks
{
private var myDisplay:TouchSprite;
public function Main():void
{
super();
key = "xxx";
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
}
override protected function gestureworksInit():void
{
myDisplay = new TouchSprite();
myDisplay.gestureReleaseInertia = true;
myDisplay.gestureEvents = true;
myDisplay.disableNativeTransform = false;
myDisplay.disableAffineTransform = false;
myDisplay.mouseChildren = true;
myDisplay.gestureList = {"n-drag":true,"n-scale":true};
myDisplay.addChild(boliviaMap);
myDisplay.addChild(mapPink);
addChild(myDisplay);
myDisplay.addEventListener(GWGestureEvent.DRAG, gestureDragHandler);
myDisplay.addEventListener(GWGestureEvent.SWIPE, gestureSwipeHandler);
mapPink.addEventListener(TouchEvent.TOUCH_TAP, tapPink);
}
private function tapPink(e:TouchEvent):void
{
trace("PINK");
indicatorTxt.text = "PINK";
}
private function gestureDragHandler(event:GWGestureEvent):void
{
trace("g drag: ", event.value.dx, event.value.dy);
event.target.$x += event.value.dx;
event.target.$y += event.value.dy;
indicatorTxt.text = "g drag: " + event.value.dx + " " + event.value.dy;
}
}
}
apparently the myDisplay.mouseChildren = true; will make myDisplay not able to drag or scale anymore.
Before adding your bigMap button set the mouseChildren property of myDisplay to true:
myDisplay.mouseChildren = true;
This should pass mouseEvents to objects inside.
Also, depending on the effect you want (I'm assuming this is for a multi-touch screen of somesort), I'd suggest you should probably use a TouchEvent.TOUCH_TAP on bigMap instead of MouseEvent.CLICK(MouseEvents arent multi-touch and won't be responsive if there is some kind of touch on another part of the screen at the same time).
Edit:
Assuming boliviaMap and mapPink aren't TouchMovieClips or TouchSprites then do something like this:
myDisplay.graphics.beginFill(0x555555, 1);
myDisplay.graphics.drawRect(0,0,500,500);
myDisplay.graphics.endFill();
Then add your child assuming boliviaMap and mapPink are less than 500x500px:
myDisplay.addChild(boliviaMap);
myDisplay.addChild(mapPink);
Edit 2- A working example(for me anyways) combining TouchEvents with GWEvents:
package {
import flash.display.MovieClip;
import com.gestureworks.core.GestureWorks;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import com.gestureworks.core.TouchSprite;
import flash.display.Sprite;
import flash.events.TouchEvent;
public class Main extends GestureWorks {
public function Main() {
super();
key = "INSERT YOUR GW KEY HERE";
Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT;
}
override protected function gestureworksInit():void
{
trace("GestureWorks has initialized");
var myTouchSprite:TouchSprite = new TouchSprite();
myTouchSprite.graphics.beginFill(0x555555,1);
myTouchSprite.graphics.drawRect(0,0,100,100);
myTouchSprite.graphics.endFill();
myTouchSprite.gestureReleaseInertia = false;
myTouchSprite.gestureEvents = true;
myTouchSprite.disableNativeTransform = false;
myTouchSprite.disableAffineTransform = false;
myTouchSprite.gestureList = {"n-drag":true, "n-rotate":true};
myTouchSprite.mouseChildren = true;
var myTappableSprite:Sprite = new Sprite();
myTappableSprite.graphics.beginFill(0xAD3059,1);
myTappableSprite.graphics.drawRect(30,30,40,40);
myTappableSprite.graphics.endFill();
myTappableSprite.addEventListener(TouchEvent.TOUCH_TAP, tappedThis);
//myTouchSprite.addChild(myTappableSprite);
myTouchSprite.addChild(myTappableSprite);
addChild(myTouchSprite);
}
public function tappedThis(event:TouchEvent){
trace("You tapped this");
}
}
}
I should also add that this will only work on a screen/device that triggers TouchEvents(if you're clicking myTappableSprite with a mouse it won't trigger the event).