Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 19th, 2009, 10:11 AM
ford2008 ford2008 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 188 ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 15 h 14 m 26 sec
Reputation Power: 44
ActionScript 3 - Property CLICK not found, game problem

Hello,

I am getting the error message when I put the mouse over the "badBlob":

ReferenceError: Error #1069: Property CLICK not found on flash.events.MouseEvent and there is no default value.
at collisionChangeCursor_fla::MainTimeline/followCursor()[collisionChangeCursor_fla.MainTimeline::frame1:12]

Any thoughts?

My Code is:

Code:
var score:Number = 0;

Mouse.hide();

stage.addEventListener(MouseEvent.MOUSE_MOVE,followCursor);

function followCursor(MouseEvent):void
{
	
	if(blob.hitTestObject(badBlob))
	{
		blob.addEventListener(MouseEvent.CLICK,addToScore);
		function addToScore(MouseEvent):void
	   {
		
		trace("hit bad blob");
		score++;
		pointsScore.text = score.toString();
		
	   }
		
	}
	
	blob.x = mouseX;
	blob.y = mouseY;
	
}


Thankyou for your time,

Ford2008
__________________
http://www.advertiseadspace.com Buy & Sell Advertising space in an online marketplace

http://www.onepoundscripts.co.uk One pound scripts and up, for Cubecart 3

Last edited by ford2008 : October 19th, 2009 at 10:13 AM.

Reply With Quote
  #2  
Old October 19th, 2009, 11:51 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 5,671 Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)Tann San User rank is General 17th Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 19 h 32 m 45 sec
Reputation Power: 2082
Facebook MySpace
Hi, it's bugging out because you're trying to assign the mouse event hundreds of times. That's happening because you're assigning the event inside the MouseMove event which gets called very frequently.

Another problem you'll run into is that the click event will never get called since the cursor will almost always be outside the blob clip since you're giving it the same x & y as the mouse. It's a bit hard to explain but an easier way is just to see for yourself. If you comment out the mouse hiding code you'll see that the registration is lined up so the top left corner of the box is directly under the cursor. Because the update routine is always slower than you can move the mouse it means sometimes it will not be at the same position so when you click the mouse it will not actually hit the blob.

Here's a cleaned up version that handles both of those issues:
Code:
var score:Number = 0;
Mouse.hide();

stage.addEventListener(MouseEvent.MOUSE_MOVE, followCursor);
stage.addEventListener(MouseEvent.MOUSE_DOWN, addToScore);

function followCursor(event:MouseEvent):void
   {
      blob.x = mouseX;
      blob.y = mouseY;
   }

function addToScore(event:MouseEvent):void
   {
      if (blob.hitTestObject(badBlob))
         {
            trace("hit bad blob");
            score++;
            pointsScore.text = score.toString();
         }
   }

We move the click code so it's on the stage. This means that whenever they click the mouse, be it over the blob or not, the addToScore function will get called. We put the hitTest check in there. That has the added benefit of meaning that it doesn't get called every time you move the mouse giving you a slight performance boost.

I also fixed your function headers:

Bad: function followCursor(MouseEvent):void
Good: function followCursor(event:MouseEvent):void
Comments on this post
Brokenhope agrees: Sexy code .
ford2008 agrees: nice answer
__________________
Quis custodiet ipsos custodes?

Reply With Quote
  #3  
Old October 20th, 2009, 11:47 AM
ford2008 ford2008 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 188 ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level)ford2008 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 15 h 14 m 26 sec
Reputation Power: 44
Thanks, thats great

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Property CLICK not found, game problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek