Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Stage onClick problem

Participant ,
Oct 28, 2013 Oct 28, 2013
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown)
I tried use this to close a drop down menu whenver user click anywhere besides the menu button.
But it seems to me the 'stage' area pretty much covers only area that has nothing on it, example: the little 'padding' area outside the main movie, that's practically useless I need the user be able to click on ANYWHERE except the button and the menu area, and then trigger function to close the menu.
I google around but can't find anything useful,  it seem to me in AS2 there is onreleaseoutside event? Why wouldn't they have same thing on AS3? and what's the best solution for this?  I think on Javascript this is pretty easy to accomplish?
Thank you.

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 28, 2013 Oct 28, 2013
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2013 Oct 28, 2013

Hi!

I just tried this method, I get error however,

1061: Call to a possibly undefined method contains through a reference with static type flash.display:SimpleButton.

strange thing is it say 'contains' is undefined but in Flash its text is blue so 'contains' has to be an AS term..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 28, 2013 Oct 28, 2013

Enable debugging in your Publishing options and show the Line of Code that produces the error

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2013 Oct 28, 2013

ok, I tried enable debugging, added back the contains code.

it's the line that has 'contains' produce the error, this is the line, I used a button on stage instead of 'circle'

if (event.target == shopBttn || shopBttn.contains(event.target)){

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 28, 2013 Oct 28, 2013

change the whole line

if (event.target == shopBttn || shopBttn.contains(event.target)

to

if(event.currentTarget == shopBttn){

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2013 Oct 28, 2013

Hi,

It runs now, however only clicking on shopBttn works, on stage or anywhere else doesn't work.

Does 'stage' defines just within the movie, or timeline/movieclip regardless, just everything seen in the browser?

I asked because I'm doing this inside a movieclip

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 28, 2013 Oct 28, 2013
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2013 Oct 28, 2013

It said these properties are not 'applicable'...  My site is pretty heavy on filters and mask, is that why it doesn't work?  But this list practically un-applicable everything, it can't be right?

  • alpha
  • blendMode
  • cacheAsBitmap
  • contextMenu
  • filters
  • focusRect
  • loaderInfo
  • mask
  • mouseEnabled
  • name
  • opaqueBackground
  • rotation
  • scale9Grid
  • scaleX
  • scaleY
  • scrollRect
  • tabEnabled
  • tabIndex
  • transform
  • visible
  • x
  • y
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 28, 2013 Oct 28, 2013
LATEST

var stageref:Stage = this.stage;

//it only means that the stageref-Object  that I created above

//can`t be accessed with the properties that are listed, its not a Sprite or a MovieClip

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2013 Oct 28, 2013

Hi, I tried again, on the site it says I dont need the contains check, so I just took it down. 

It runs, however the result it will trigger what's inside circle, outside circle function doesn't trigger..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines