Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-22-2007, 12:39 AM   #1
msodrew
Registered User
 
Join Date: Nov 2006
Posts: 27
Default onMouseDown fires at the worng time...

Please excuse the ridiculous misspelling of "wrong" in the title.... haha.

Hey people perhaps you could lend me some help.

I've got a container_mc that holds two things:
  1. a picture of a polaroid (as decoration)
  2. a dynamically loaded image offset into the polaroid to fit

I want different things to happen for clicking on the two different children mc's! I've got the two different definitions as like
ActionScript Code:
container_mc.pic.onMouseDown = function () { /* some action */ }; container_mc.polaroid.onMouseDown = function () { /* some action */ };

The problem is that when i click a part that is DEFINITELY the polaroid, it registers it as a click for the pic MC! Oh noes.

Can anyone help?

Some notes: the pic mc was made via createEmptyMovieClip then using a MovieClipLoader object to load the jpg into it. The polaroid mc is BELOW the pic as far as depth (which should be obvious or else you wouldn't see the pic).

Thanks.
msodrew is offline   Reply With Quote
Old 03-22-2007, 12:56 AM   #2
straydog
Hands Resist Him
 
straydog's Avatar
 
Join Date: Jun 2006
Posts: 180
Send a message via AIM to straydog Send a message via MSN to straydog
Default

sounds like when you dymnamically created the MC for the jpg the MC was made larger than the MC for the polaroid background. And becasue you have the jpg MC above the polaroid MC it registers a click on the jpg MC.

try making a third MC to house both jpg MC and polaroid MC so you can put both the jpg MC and the polaroid MC on the same level and or in the same frame.

hope that helps some.
straydog is offline   Reply With Quote
Old 03-22-2007, 01:13 AM   #3
msodrew
Registered User
 
Join Date: Nov 2006
Posts: 27
Default

Quote:
Originally Posted by straydog View Post
try making a third MC to house both jpg MC and polaroid MC so you can put both the jpg MC and the polaroid MC on the same level and or in the same frame.
I don't understand what this 3rd MC would accomplish... If the tree ends up being like
Code:
container_mc -> extra_mc ->  pic_mc (depth 1)
                     \-----> polaroid_mc (depth 0)
then whats the difference?
msodrew is offline   Reply With Quote
Old 03-22-2007, 01:50 AM   #4
jsonchiu
Registered User
 
Join Date: Aug 2006
Posts: 482
Default

replace onMouseDown() with onRelease() or onPress()!
ActionScript Code:
container_mc.pic.onRelease = function () { /* some action */ }; container_mc.polaroid.onRelease = function () { /* some action */ };
jsonchiu is offline   Reply With Quote
Old 03-22-2007, 02:04 AM   #5
msodrew
Registered User
 
Join Date: Nov 2006
Posts: 27
Question

Quote:
Originally Posted by jsonchiu View Post
replace onMouseDown() with onRelease() or onPress()!
how could that possibly make a difference?
msodrew is offline   Reply With Quote
Old 03-22-2007, 02:13 AM   #6
jsonchiu
Registered User
 
Join Date: Aug 2006
Posts: 482
Default

.............
As far as I know, onMouseDown is a global event, meaning that if you click anywhere, it fires. onRelease is a event that specifically target a movieclip or a button. I don't think onMouseDown would work with buttons.
jsonchiu is offline   Reply With Quote
Old 03-22-2007, 02:18 AM   #7
msodrew
Registered User
 
Join Date: Nov 2006
Posts: 27
Default

Quote:
Originally Posted by jsonchiu View Post
.............
As far as I know, onMouseDown is a global event, meaning that if you click anywhere, it fires. onRelease is a event that specifically target a movieclip or a button. I don't think onMouseDown would work with buttons.
I tried both onRelease and onPress and they simply never fire. Eh... im lost.
msodrew is offline   Reply With Quote
Old 03-22-2007, 04:51 AM   #8
reyco1
To AS2.0 or not to AS2.0
 
Join Date: Mar 2005
Location: New York
Posts: 208
Send a message via AIM to reyco1 Send a message via MSN to reyco1 Send a message via Yahoo to reyco1
Default

omPress or onRelease should have definitely worked... hmmm,,, could you post your fla or recreate it in a new fla and post that?
reyco1 is offline   Reply With Quote
Old 03-22-2007, 05:16 AM   #9
straydog
Hands Resist Him
 
straydog's Avatar
 
Join Date: Jun 2006
Posts: 180
Send a message via AIM to straydog Send a message via MSN to straydog
Default

Quote:
Originally Posted by msodrew View Post
I don't understand what this 3rd MC would accomplish... If the tree ends up being like
Code:
container_mc -> extra_mc ->  pic_mc (depth 1)
                     \-----> polaroid_mc (depth 0)
then whats the difference?

the 3rd MC acts as a container for both of the other 2 MCs allowing both polaroid MC and jpg MC to be at the same depth level
straydog is offline   Reply With Quote
Old 03-22-2007, 10:03 AM   #10
3pepe3
;)
 
3pepe3's Avatar
 
Join Date: Aug 2006
Location: In transit--- Still bored
Posts: 1,705
Default

Quote:
Originally Posted by jsonchiu View Post
.............
As far as I know, onMouseDown is a global event, meaning that if you click anywhere, it fires. onRelease is a event that specifically target a movieclip or a button. I don't think onMouseDown would work with buttons.
this is the best way and it must work... but it's not going to work if you have something like onRelease, onRollOver, etc in the container_mc

ActionScript Code:
container_mc.pic.onMouseDown = function () { if (this.hitTest(_root._xmouse,_root._ymouse,true)){ /* some action */ } }; container_mc.polaroid.onMouseDown = function () { if (this.hitTest(_root._xmouse,_root._ymouse,true)){ /* some action */ } }; ///or use this: /* this.onMouseDown = function () { if (container_mc.pic.hitTest(_xmouse,_ymouse,true)){ /* some action */ } if (container_mc.polaroid.hitTest(_xmouse,_ymouse,true)){ /* some action */ } }*/
or more easy... if you have some mouse handler on the container_mc change it to some global mouse behavior.
if you have something like
container_mc.onRollOver()=function(){/*///blablabla///*/}
change it for :
ActionScript Code:
container_mc.onMouseMove = function () { if (this.hitTest(_root._xmouse, _root._ymouse, true)) { inside = true; mover();        } if (!this.hitTest(_root._xmouse, _root._ymouse, true) && inside == true) { inside = false; moverOut();   } }; ///and then you are going to be more free to work inside this movieClip container_mc.pic.onRelease = function () { /* some action */ }; container_mc.polaroid.onRelease = function () { /* some action */ };
__________________
http://www.pepemagana.com

Last edited by 3pepe3; 03-22-2007 at 10:11 AM.. Reason: error
3pepe3 is offline   Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
time MontyCoder ActionScript 2.0 9 02-16-2007 05:10 AM
Countdown timer, timezone offset stuck in Eastern time ironchefmoto ActionScript 2.0 3 12-26-2006 10:00 PM
Displaying multiple time zones using flash jdeutsch ActionScript 2.0 1 11-18-2004 05:02 PM
Function problem: 1st time ok second time not work Astralp ActionScript 2.0 2 09-04-2004 04:07 PM
Daylight Saving Time Clock ?????? poab ActionScript 1.0 (and below) 0 08-30-2001 12:15 PM


All times are GMT. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.