need a little help

i need some help with AS3

Page 1 of 1

2 Replies - 580 Views - Last Post: 08 April 2009 - 08:16 AM

#1 jasjohn2008  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-April 09

need a little help

Post icon  Posted 08 April 2009 - 07:33 AM

hi all, i'm compleatly new to as3, i know some basic stuff, but am currently stuck on a project,

i'm trying to make a drag and drop game, i have done the background and the iteams to drop, but have no idea how to set where to drop them to.

my game is desinged thus ; you have to drag bats into a cave, trouble is the cave is the background image, i placed it in flash useing only code, can someone please help me understand how to set the cave as the target area for the bats and to get the bat to dissapear and add some points to the score. if anyone can help i would be very greatful.


my code so far is below:


var castle:castleBg = new castleBg();
addChild(castle);
castle.x=400;
castle.y=466;

addEventListener(Event.ENTER_FRAME,myFunction);  
function myFunction(event:Event) 
{  
	enterframelistener();
	enterframelistener1();
	
}   
 
	
function enterframelistener() // move left
{
	if (stage.mouseX >  800) 
	{
		const speed:int= -25;
		castle.x += speed;
		const CastleOFFSET:int= 5
	}
		
} 
		
function enterframelistener1() //move right
{
	if (stage.mouseX < 250)
	{
		const speed:int= 25;
		castle.x += speed;
		const CastleOFFSET:int=-5
		
		}
	
} 

var bat:vBat = new vBat();
castle.addChild(bat);
bat.x=-250;
bat.y=-300;

bat.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
bat.addEventListener(MouseEvent.MOUSE_UP, dropIt);


function pickUp(event:MouseEvent):void {
	event.target.startDrag(false);
	//trace("Drag Started!");
}

function dropIt(event:MouseEvent):void {
	event.target.stopDrag();
	
	
	bat.visible = false;
	//trace("Drag Stoped!");
	
}
bat.buttonMode = true;

var tMouth:mouth = new mouth(); // this is where the bat will hit and vanish
castle.addChild(tMouth);
tMouth.x= 200;
tMouth.y=350;	

// if(this.hitTestObject(tMouth)) {
	
	trace ("hit");
	}


Mod edit - Please :code:

Is This A Good Question/Topic? 0
  • +

Replies To: need a little help

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: need a little help

Posted 08 April 2009 - 08:04 AM

i believe that there are no programming questions allowed in this forum, you should have posted it in the correct forum and also you forgot to add the code tags
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,283
  • Joined: 17-March 01

Re: need a little help

Posted 08 April 2009 - 08:16 AM

Moving to Flash and ActionScript.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1