Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




MouseEvents



Hi everyone,
AS3 mouse events seem to be a vast improvement on AS2.

Mouse events in AS2 seemed to register even if you didn't directly interact with the clip, yet in AS3 it happens only if the mouse is over the clip:

AS2
Results in the clip rotating ANY time you move the mouse (a bit crap, really)

ActionScript Code:
clip.onMouseMove = movefunction move():Void{    clip._rotation = _xmouse;}


AS3
Results in the clip rotating only when you move the mouse over the clip (great!)

ActionScript Code:
import flash.events.*clip.addEventListener(MouseEvent.MOUSE_MOVE, move);function move(evt:MouseEvent):void{    evt.target.rotation = mouseX;}

Is this as-designed behaviour in both AS2 and AS3? Or have I missed something in AS2?

Thanks,
Dave



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 09-09-2008, 02:46 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Mouseevents Wtf?
Solved (too many }, pity the compiler/debugger isn't smart enough to catch a simple error like that lol).

MouseEvents Conflicted
Hi
I have created a movieclip.
I have implamented zoom and drag functionality in it.
when i click movieclip it scales larger and next time i click it it scales smaller.
but when i click movieclip for draging at that time i want to disable zoom function.
so is there anyway....
Thanks.

MouseEvents Outside Of Browser?
The times when I've built a Flash scrollbar, whenever the user's mouse would go outside of the browser, the scrollbar would cease receiving mouse events. Several times I've seen flash scrollbars that continue receiving events, how so?

Here's an example: https://www.masterbeat.com/#genre/electronica

Accordion Mouseevents?
hi! i'm very new at flash.. and i have a question about the accordion component :

i want to catch the onRollOver and onRollOut mouseevents when i go over an Accordion header, and my code looks like this :


ActionScript Code:
trace(accord._header0.onRollOver) //output : "type function"
 
accord._header0.onRollOver = new function() { trace("rolled over!!"); }
 
trace(accord._header0.onRollOver) //output : "undefined" (?!??)
 


so what i am doing wrong? i want to overwrite the onRollOver handler with my custom function, but when i call trace again - the function is gone

pleas help me i'm working on this the whole day )

MouseEvents For External Swf
Hi. I'm loading an external swf with MovieClipLoader into an emtpy MovieClip. Then I'd like to add an onRelease behaviour.

With an external jpeg this is no problem, but with a swf it doesn't react, since the swf itself already has it's own mouse behaviours.

So it seems that the mouse behaviour of the external swf overrule the frehsly assigned onRelease behaviour.

Isn't there a way to make this onRelease work, i.e. to make the swf pass the mouse events on the the main movie?

Thanks! Michael

Problem With MouseEvents
I'm currently working on a small design in Flash CS4 that I will use as part of a website, and am having troubles with some of my AS3 code. Basically, what I am interested in having my buttons do is this:

When I MOUSE_OVER the button, I would like the page information to come up directly below it. When I MOUSE_OUT from the button, I would like the page information to disappear. This part I have completed, and works fine. The next thing I would like to do is when I CLICK on the button, I would like the page information to stay, and the MOUSE_OUT to be void, so I can navigate through what is there, and then when I MOUSE_OVER another button it disappears.

I have sort of completed this. When I CLICK the button, the information stays, and when I MOUSE_OVER another button it will disappear. When I MOUSE_OVER that same button, and MOUSE_OUT the first time, it will disappear, but when I CLICK that button a second time, after I MOUSE_OUT and MOUSE_OVER again the information just stays without a CLICK, even after I MOUSE_OUT. I would like the information to only stay when I CLICK the button, and disappear after a MOUSE_OVER on another button, then only show the information on MOUSE_OVER again until I CLICK. Basically, a preview of the page on MOUSE_OVER, the full page on CLICK, then when another button is activated that all becomes void until the button is CLICKed again.

Here is my code for my first button:

Code:

stop();
btn_1.addEventListener(MouseEvent.CLICK, click1);
btn_1.addEventListener(MouseEvent.MOUSE_OVER, over1);
btn_1.addEventListener(MouseEvent.MOUSE_OUT, out1);

function click1(event:MouseEvent):void
{
   btn_1.addEventListener(MouseEvent.MOUSE_OUT, roll1);
   function roll1(event:MouseEvent):void
   {
      gotoAndStop(5);
   }
}
function over1(event:MouseEvent):void
{
   gotoAndStop(2);
}
function out1(event:MouseEvent):void
{
   gotoAndStop(1);
}


I hope I explained that well enough for someone to understand? Any help would be greatly appreciated! It seems fairly simple, but for some reason I just can't get it.

Basic Question On Mouseevents
Hi,
thank you for reading this and for any answers.

Which mouseevents are allowed in buttons that are part of a movieclip? I have experienced that rollOut works but not any others.(Not even rollOver.) I use Flash 5 and Flash MX and are using framelables. I assume that there are no difference between MX and 5 in this matter?

That the event release donīt work may be cuz a MC are a dynamic minimovie and a button a static symbol??

regards
ikaros

___________________________________

I cannot live without dreaming, but maybe it is just a dream that I am living...

[F8] MouseEvents For _parent And Child
I have a _parent movieclip that receives mouse events and I want the clips inside the _parent clip (child clips) to receive mouse events also, but because of the _parent's mouse event handlers, the child clips are "interfered" with, or not received....

how do I make it so both the _parent and the child clips can receive mouse events?

DisplayObjects And MouseEvents Question
Is it possible to make a child of a DisplayObject not register MouseEvents?

Here's my problem...

I have 3 squares that overlap each other. I was using a DropShadowFilter on them but found that it rendered too slowly. So I replaced the DropShadowFilter with a .PNG containing a blurry black square to simulate a dropshadow.

It runs much more smoothly, but the shadow is now picking up the MouseEvent.ROLL_OVER Listener, which means the square underneath isn't triggering its ROLL_OVER event

So the goal is to trigger the ROLL_OVER event of the DisplayObject that's being overlapped by the dropshadow.png

Any ideas?

Mouse.hide And MouseEvents?
I have hidden my mouse and am using a custom cursor, but when I hide the mouse none of my "MouseEvent.ROLL_OVER/OUT", "MouseEvent.CLICK", and "MouseEvent.MOUSE_UP" events work anymore. Is there anyway to get these to work without capturing the mouse click's x/y coords and converting that to the movie?
Thanks,
maji

How To Transmit MouseEvents To Children?
Hi,

I am currently working on an improvement of a old program in AS2 for my office.

The program consists of an evolved viewer for interactive languages courses THAT ARE ALREADY MADE AND SHOULD NOT BE CHANGED.

Those courses consist of simple flash movies with simple controls (play, go back, go forward, etc...)

For this advanced viewer, I have to add new functions on the buttons dynamically when the movie is loaded. But the buttons must also keep their old effect, which will add with the new one.

I had no problems with "simple" buttons, since I just had to add a second listener for the same "on press" event to them, but...

The hard part is movieclips with buttons in it.
For some reason, adding listeners on the buttons don't work, but adding on the movieClips containing them work.

But if I do that, the event isn't transmitted to the button inside, so the "old" action doesn't take effect.

To make it short :
If I could make the click event go to the children of the movieclip, or simulate a click somehow, my problem would be solved.

Any suggestions about this?

Problem With Depths And MouseEvents
Hey all,

I was wondering if there was a way to stop all event propogation from affecting a MovieClip. Basically, I have a movieClip that is "hidden" underneath another one, but I need it to be able to be accessible. The MovieClip on top has no listeners added, and no functionality whatsoever, yet it seems to be stopping anything from getting to the MovieClip underneath it.

I've tried setting the "enabled" property to false, as well as the "MouseChildren" on the "holder" to false.

Here's the code I use to set up the MovieClips that are meant to "hide" the other movieClips.


ActionScript Code:
var bandHolder:MovieClip = new MovieClip();
addChild(bandHolder);

var bandHider:MovieClip = new MovieClip();
addChild(bandHider);

for (var i:Number=0;i<pinMax;i++) {
     createHidingPin(i);
}

function createHidingPin(pinNum:Number) {
     var tempPin:pin_mc = new pin_mc();
     bandHider.addChild(tempPin);
     tempPin.x = ((i%5)*117.5)+pinOffsetX;
     tempPin.y = (Math.floor(i/5)*117.5)+pinOffsetY;
     tempPin.num = pinNum;
     tempPin.name = "hidingPin"+pinNum;
     tempPin.mouseEnabled = false;
}

That's really it. The "pin_mc" is basically just a circle right now (will change later) that is just a single frame on the timeline of that MovieClip. There is no added functionality to it. The "class" is just the generic extension created when you click on the "export for actionscript" checkbox in the "properties" of the MovieClip. So it's basically just a graphic that I place in a grid, and it's there to hide the stuff in the "bandHolder" (which is attached elsewhere and is a clearly defined Class). The mouseEvents for that class work if I set the "visible" to false for the Pins or for the "bandHider", but otherwise, they don't....

Anyone know of a way to get around this? I'd prefer to keep the thing dynamic (as the number of pins may end up changing in the end)...

Any help would be appreciated!

Do Masks Interfere With MouseEvents?
I have a sprite, on a layer. If I set the layer above it as a mask, the sprite's MouseEvents aren't captured. If I remove the mask, they are.....

I have never encountered this before, and in fact I have several other movieclips on timeline layers, that are beneath a mask-layer, which aren't having any MouseEvent problems.....aargh!





























Edited: 09/19/2007 at 06:53:48 PM by cayennecode

MouseEvents On Main Sprite
This is probably a beginners question, but I have been puzzled for a few days.

This works as expected (imports ommited):
public class Test extends Sprite {
public function Test() {
var circle:Sprite = new Sprite();
circle.graphics.lineStyle(1);
circle.graphics.beginFill(0xFF8000);
circle.graphics.drawCircle(50, 50, 10);
circle.addEventListener(MouseEvent.MOUSE_DOWN, down);
addChild(circle);
}
private function down(evt:MouseEvent):void {
trace("down");
}
}

However if I remove the circle object and directly draw on the main sprite, it doesn't work:

public class Test extends Sprite {
public function Test() {
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(50, 50, 10);
addEventListener(MouseEvent.MOUSE_DOWN, down);
}
private function down(evt:MouseEvent):void {
trace("down");
}
}
No matter where I click, I can't get the event to be fired.
I know I can attach the listener to the stage, but I'm wondering why it doesn't work on the sprite directly.

I'm sure there is a perfectly reasonable explanation, I just can't figure it out.
Can any one help?

Thanks in advance,
Peter

Accessing Childten MCs With MouseEvents In AS3
Hi,

I now have working code that creates a mask of about 2,700 children on a 650 by 450 image using a container to hold all the children's MCs.

Can anyone provide any help as to how I can access these children at once with a MouseEvent so that I could for instance change the alpha value of a child shape when the user rolls over it with their mouse.

I have attahced the code to this post.

Thanks in advance for any of the help provided as I've been learning to use AS3 from AS2.

Best,

Justin







Attach Code

import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;



var pixelated_mc:MovieClip = new MovieClip();
addChild(pixelated_mc);
pixelated_mc.y = 0;
pixelated_mc.x = 0;

var commaHolder_mc:MovieClip = new MovieClip();
addChild(commaHolder_mc);
commaHolder_mc.y = 0;
commaHolder_mc.x = 0;
//var commaTile_mc:MovieClip = new commaTile;
//trace(commaTile_mc.width);


var pixelSize = 2;




function pixelate(){
var bitmapData:BitmapData = new BitmapData( original_mc.width/pixelSize, original_mc.height/pixelSize, false );
var bitmap:Bitmap = new Bitmap(bitmapData);
pixelated_mc.addChild(bitmap);
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(1/pixelSize, 1/pixelSize);
bitmapData.draw( original_mc, scaleMatrix );
bitmap.width = original_mc.width;
bitmap.height = original_mc.height;
}

function tileBG() {
for(var i=0; (i/original_mc.height < .1); i++) {
for(var j=0; (j/original_mc.width < .1); j++) {
var commaTile_mc = new commaTile();
commaTile_mc.x = j * commaTile_mc.width;
commaTile_mc.y = i * commaTile_mc.height;
commaHolder_mc.addChild(commaTile_mc);

commaTile_mc.addEventListener(MouseEvent.ROLL_OVER, onRoll);
//trace(commaTile);
}
}
};

function onRoll(event:MouseEvent):void {
trace("ROLL OVER");
}

removeChild(original_mc);
pixelated_mc.mask = commaHolder_mc;
pixelate();
tileBG();
trace(commaHolder_mc.getChildAt(0));

Not All MouseEvents Supported In Flash 2?
from the actionscript language reference in mx2004:

on()

Availability
Flash 2. Not all events are supported in Flash 2.

Usage
on(mouseEvent) {
// your statements here
}

Flash 2. Not all events are supported in Flash 2. <---- !!! which ones aren't supported? i couldn't find this in the AS2 docs anywhere.

and would this mean the same thing for this usage?
target.onMouseEvent = function(){
}

MouseEvents With Bitmap Objects
I am trying to have a mouse event register when the cursor leaves an image, but the listener function never gets entered. In AS3, how does one get the MouseOver event to work for a bitmap like I have?

public class MyClass extends MovieClip {
.
.
.
[Embed(source='orange.jpg')]
public var MyOrange:Class;
.
.
.

public function MyFunction() {
var graphix1:Bitmap = new MyOrange();
graphix1.x = 70;
graphix1.y = 124;
graphix1.addEventListener(MouseEvent.MOUSE_OVER, showOrange);
}

What Am I Doing Wrong? MC Targeting And MouseEvents
Hi,

I have been frustrating with this for a while now and was wondering if maybe someone here could help me out.

I have attached a Flash File (CS3) with a movieclip inside. Lets say this movieclip is acting as a button. What i am trying to do is this. When the user rolls over the movieclip (parent) it begins the animation. The animation plays, then stops and a certain frame. On this certain frame there is another movieclip (child) i also want to act like a button. I have gotten it to when the user rolls into the child button the parent won't play its roll out animation unless you actually roll out of it as oppose to rolling into the child clip (which is technically out of the parent). The problem i am having is A) targeting the child clip, and B) getting the child to play its animation when rolled in and of.

This is the code i have used so far.

Code:
testButton.stop ();
testButton.addEventListener (MouseEvent.MOUSE_OVER, buttonOver);
function buttonOver (e:MouseEvent):void {
testButton.play ();
testButton.removeEventListener (MouseEvent.MOUSE_OVER, buttonOver);
testButton.addEventListener (MouseEvent.MOUSE_OUT, buttonOut);
}
function buttonOut (e:MouseEvent):void {
if (e.relatedObject==null || (e.target.name!="insideButton" && e.target.name!="testButton")) {
testButton.gotoAndPlay (11);
testButton.removeEventListener (MouseEvent.MOUSE_OUT, buttonOut);
testButton.addEventListener (MouseEvent.MOUSE_OVER, buttonOver);
}

}
The parent clip is named testButton and the child clip is named insideButton. I have been told that this is possible with AS3, but seem to be stuck.

Can someone here help me finish this? It has been the bottleneck of a project and is starting to give me headaches. Any help is very much appreciated. And thank you in advance.

MouseEvents For Buttons With Textfields
Hi,

Below is the code im using for a menu that recognizes which button is already selected and prevents its mouse_over/out states while it is selected.

I have two dynamic textfields on top of each button. I need these textfields to be part of the button without the text being tweened in the same way the button is.

I have tried putting the textfields inside the movieclip but then the text tweens the same way the button does (because the functions use 'currentTarget') and if I keep the textfields on top of the buttons my mouse events don't work when the cursor is over the textfields, making half of my button not function.

I have read about using mouseChildren = false but so far I'm having no luck

Any help guys.....


Code:

import gs.TweenMax;
import gs.easing.*;

// create an array of all nav buttons in group
var menuData:Array = new Array();
menuData.push(tab1);
menuData.push(tab2);
menuData.push(tab3);
menuData.push(tab4);
menuData.push(tab5);
menuData.push(tab6);

// create a variable to track the currently selected button
var activebtn = new MovieClip;

// doRollOver: start the rollover action or process,
// unless the button is currently selected
function doRollOver(event:MouseEvent):void {
if (event.currentTarget != activebtn) {
TweenMax.to(event.target, 0.5, {tint:0x0033CC});
}
}
// unless the button is currently selected
function doRollOut(event:MouseEvent):void {
if (event.currentTarget != activebtn) {
TweenMax.to(event.target, 0.5, {tint:0x333333});
}
}
function doClick(event:MouseEvent):void {
tab1.mouseChildren = false;
TweenMax.to(activebtn, 0.5, {tint:0x333333});
activebtn = event.currentTarget;
TweenMax.to(activebtn, 0, {tint:0x0033CC});
}

// assign functions to each event for each button in the group
function init() {
var i=0;
var btn;
for (i=0; i<2; i++) {
btn = menuData[i];
btn.addEventListener(MouseEvent.MOUSE_OVER, doRollOver);
btn.addEventListener(MouseEvent.MOUSE_OUT, doRollOut);
btn.addEventListener(MouseEvent.CLICK, doClick);
}
}
init();

Adding Mouseevents To Objects.
I'm setting up a menu by creating 3 new objects (I drew a basic rectangle and saved it as a movieclip + linkage).

var rect1:Rect = new Rect();
var rect2:Rect = new Rect();
var rect3:Rect = new Rect();


Next I would like to add 15 pixels to the x-property on mouseover, and go back to original x-property on mouseout. How would you add this functionality in a smart and effective way?

Coming from other programming I would probably go and edit the Rect-class and add some behaviour, but in Flash all I can figure is to add listeners like this..

rect1.addEventListener(MouseEvent.MOUSE_OVER, makeMenu1Over);
rect2.addEventListener(MouseEvent.MOUSE_OVER, makeMenu2Over);
rect3.addEventListener(MouseEvent.MOUSE_OVER, makeMenu3Over);
rect1.addEventListener(MouseEvent.MOUSE_LEAVE, makeMenu1Out);
rect2.addEventListener(MouseEvent.MOUSE_LEAVE, makeMenu2Out);
rect3.addEventListener(MouseEvent.MOUSE_LEAVE, makeMenu3Out);

.. which seems like a very wrong direction to go. I want as little code as possible. Can I write custom code for an object (like Rect in this case) so that all the mouseevents would be inherited upon instantiation?

Thanks for all smart replies!

Not All MouseEvents Supported In Flash 2?
from the actionscript language reference in mx2004:

on()

Availability
Flash 2. Not all events are supported in Flash 2.

Usage
on(mouseEvent) {
// your statements here
}

Flash 2. Not all events are supported in Flash 2. <---- !!! which ones aren't supported? i couldn't find this in the AS2 docs anywhere.

and would this mean the same thing for this usage?
target.onMouseEvent = function(){
}

Urgent Help Needed : Mouseevents & Movieclips
hello everybody,

I'm relatively new to flash but I need to make a simple portfolio in flash, instead of working with fixed titles for buttons like "atelier" theory, contact, and so on i made a REAL simple movieclip to start playing when i have the mouseevent Mouse_OVER so that the title moves and a line gets drawn, no problems there, but when i do a Mouse_OUT i want this movieclip, the title, to be in it's initial position, without the line, so in fact to reset the playhead of this movieclip but i don't know which function to use... can anyone help me?

the code for this effect:


Quote:





atelier_mc.addEventListener(MouseEvent.MOUSE_OVER, playmovieClip);
atelier_mc.addEventListener(MouseEvent.MOUSE_OUT,s topmovieClip);

function playmovieClip(gebeurtenis: MouseEvent) {
atelier_mc.play();
}

function stopmovieClip(gebeurtenis: MouseEvent) {
atelier_mc. ???? (); //what do I put here?
}

TileList Custom Mouseevents For Objects
For the TileList component's objects how do you make custom mouseEvents (eg onRollOver) ?

Trouble With MouseEvents And Overlapping Movieclips
I am developping a website in flash. The navigation for this site should respond to the MouseOver event no matter what else is happening on the site, updating the graphics based on mouse coordinates.

The problem is this: I want to add scrollable/clickable/.. content on the site, but because the Navigation movieclip covers almost the entire stage, All MouseEvents are caught by the navigation movieclip, so no events are triggered for underlying clips.

I'm sure this can be solved but I have no idea how.. Can anyone help, or point me in the right direction? swapping depths doesn't seem like the way to go because the menu clip should always be catching events..

Blocking MouseEvents From TextField W/htmlText
Hi again. So, I've got a TextField with htmlText that contains links. I'm using a stylesheet object to give the links an underlined hoverstate. When I create a new sprite, place it above the TextField, add event listeners for MOUSE_OVER (and even ROLL_OVER just to be sure) to the sprite, it does not block the text below from getting its hoverstate style applied.

I've tried placing other display object containers over top of the TextField as well.

Any thoughts on why this might not be able to block the html hover?

Thanks,
David

No MouseEvents Dispatched After Moving A Sprite
Hi all,

i've written a class which extends flash.display.sprite. The objects are then
added to another sprite wich is a child of the Document Class.

When i add them they are initially placed on coord 0/0. On that position,
the mouse events are dispatched correctly.

For some reason though, there are no more events after moving the sprite
somewhere else using mySprite.x = someNewPosition.

The positioning works fine, simply there are no more events dispatched from these objects.

Anyone an idea what i'm doing wrong ?


thanks for your help !

Catching MouseEvents From Siblinged Sprites
i have the following scenario:

two Sprites A and B, whereas A contains a .png file with some transparent regions,for instance a black rectangle with a hole in the middle. B is a smaller Sprite with
some Graphics. B has a DisplayList index lower than A so that A covers B and B can only be seen when it is behind the hole in A.

I turn B into a button by adding an EventListener to it.

1) When B is set as a Child of A, B can catch my MouseEvents.
2) But when A and B are just siblings, B doesn't receive any MouseEvent.

So, is there a way to make B "clickable" in case 2)

Keith

Papervision Mouseevents Througth Scene
I have a number of planes divided in rows. When clicked on a button within the plane's material, a box appears displaying content. This box has a close button. This button closes the box. However, when the close button is not over the content in the scene the buttons recieves the mouseevent(green), when it's over it does not(red). The image below shows this.

I use papervision 1.7, if required i will post additional information.

Flash.events.MouseEvents Will Not Load...need Advice
Hello,

I have a simple bit of code where I am attempting to detect a roll over. I think my code is right, but an error keeps showing that says:

"The class or interface 'flash.events.MouseEvents' could not load"

I think I am calling it correctly. Do I have to make a class and use the linkage to set the class path? I thought I could just import the class at the top of my script.

The code looks like this:


Code:
import flash.events.MouseEvent;

mc_button.addEventListener(MouseEvent.MOUSE_OVER, mouseOverListener);
mc_button.addEventListener(MouseEvent.MOUSE_OUT, mouseOutListener);

function mouseOverListener(event:MouseEvent):void{
this.arm_relaxed.play;
}

function mouseOutListener(event:MouseEvent):void{
this.arm_relaxed.stop;
}
Any ideas? I feel like it should work. Any tips would be greatly appreciated.

- JonCloud

Dynamically Generated Clips Won't React To Mouseevents...
When dynamically generating movieclips, how can you add a

myMovieClip.onRelease = function () {
what needs to be done comes here ...
};

Here's my code

for(i=1;i<=_root.artcounter;i++){
content.duplicateMovieClip("content"+i,i*1000);
this["content"+i].id = i;
if(i == 1){
this["content"+i]._y = 22;
this["content"+i]._x = 0;
}
this["content"+i].loadMovie(i+".jpg");
this["content"+i]._height = 10;
this["content"+i]._y = this["content"+(i-1)]._y+this["content"+(i-1)]._height;

}

It generates movieclips by duplicating a clip, loads a jpg into every generated clip and then places them in an _y position. But now I need to press them like they are buttons, and that won't work...


Anyone ?

thanks

MovieClip SubClass: Getters, Setters And MouseEvents
Hi folks. I am plain stumped. I am working in F8/as2.0.

I have a class that extends the MovieClip class. I have a blank_mc in the library that is linked to the class. Here is the constructor:
ActionScript Code:
public function MyMC (target_mc:MovieClip){
var _mc:MovieClip = this;
_mc = target_mc.attachMovie (.....);
}



That works all fine and dandy. Where I am having issues is basically I have properties x, y that DON't overwrite the _mc's _x & _y props. Instead, the use getter & setters that take values and then calculate the needed number to set the actuall _mc._x, _y props. This doesn't seem to work at all and i don't know why. Here is the code:
ActionScript Code:
function set x (num):Void {
__x = num;
this._x = (do some calculations based on num);
}



Of course this is really generalized. But is __x a private property of the MovieClip class and I am interfering with it?

On to issue two...

So I got this to work by NOT extending the MC. Instead I have a variable ref to a _mc prop in the class. However I am unable to set event functions to it even if I make some ref to the _mc prop. Is there a good way of approaching this by say a decorator pattern?

Help With How To Link A Lack Of MouseEvents To Timer Resent
Hi-

Can someone help me?

Somehow I need Flash to detect if/when the mouse does NOT move over a course of time, so that it can begin a countdown to replay an intro movieclip I need to play before a graphical menu loads.

That is to say, if no one moves the mouse in order to access any of the menu items (say within a minute of the menu_mc loading), the script runs and the intro_mc plays over again. Every time the mouse moves, the script should reset (so that it doesnt go back and replay while the viewer is moving the mouse).

In the attached example, I've labeled the parts, where the light green ball represents the intro and the static dark green ball represents the menu. It stays on the menu page with the following script (which I am obviously unaware of how to modify to meet the above criteria).


Code:
stop();

function startOver() {
clearInterval(id);
gotoAndPlay("start");
}
var id = setInterval(startOver, 10000);
Thanks so much, I am totally lost

DO With Higher ChildIndex Consumes MouseEvents Of Underlying DOs
DO = Display Object

Hi there! I have simple issue i need help with.. googled for a while to no avail..

I have created an example movie with a button(type MovieClip), added CLICK event like this:

Code:
myButton.addEventListener( MouseEvent.CLICK, onButtonClick );
onButtonClick() triggers correctly, all good.

Next i added a TextField (or MovieClip, Sprite..) above the button.

Now when i publish the movie, and try to click the button (under the added DO), the MouseEvent.CLICK ( or MOUSE_DOWN, whatever.. ) doesnt trigger anymore, probably because the DO which is now above the button eats the MouseEvent.

So what i wanna do is dispatch the MouseEvent into each DO that is under my mouse cursor, not only the top-most DO in the hierarchy.

..was trying and fixed this like 2 years ago (bluntly remember i used something else than MOUSE_DOWN / CLICK), but left AS3.0 programming at that time and now trying to do the same second time [aaa :]

Thanks for your help!

AS3 - Nested Movie Clips Ruin MouseEvents?
Hi everyone,

Nice new phpBB skin by the way. Anyways, I've been working on this simple flash navigation for my neighborhood website and figured it's a good time to learn ActionScript 3.0. I've only coded for the first button (Home) but it seems the problem is I have a container movie clip that has the event listener to watch for MouseEvent.MOUSE_OVER but when you mouse over one of the nested movie clips it ruins the button and i believe it goes back to frame 1 state of the movie clip. If you mouse over the home link without hitting the "Home" text or the House Icon the button functions properly. I think I need to make it so events from those nested movie clips are ignored somehow or if i needed to turn them into graphics instead of mc's. Link and code are below. ( the "content" target is because i was planning on having the flash in a frame on the left side and a <frame name="content"> on the right side.

Code:

import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.net.*

var homeURL:URLRequest = new URLRequest("http://www.adobe.com/");
home.addEventListener(MouseEvent.MOUSE_OVER, home_over);
home.addEventListener(MouseEvent.MOUSE_OUT, home_out);
home.addEventListener(MouseEvent.CLICK, home_click);

function home_over(event:MouseEvent):void {
   home.gotoAndPlay(1);
}
function home_out(event:MouseEvent):void {
   home.gotoAndPlay(7);
}
function home_click(event:MouseEvent):void {
   navigateToURL(homeURL, "content");
}

FLA: http://www.mdmazzola.com/projects/arboroaks/AO_buttons.fla
SWF: http://www.mdmazzola.com/projects/arboroaks/AO_buttons.swf

I also would like to know if it's possible to create a package / class that could handle the code for all of the buttons using "this.gotoAndPlay(1)" so i don't have so much redundant code. I know Lee made a tutorial on it in AS2 but i couldn't figure it out. For now i'm more focused on getting the buttons working smoothly. Any help is much appreciated. Thanks guys. Keep the gotoAndLearn community going.

Problem With MouseEvents Of Items Inside Sprite/MovieClip
Hi,

i try to build a simple navigation bar using a sprite with buttons (sprites with textfields) inside. The menu is initially hidden and should slide
down if it recieves a MOUSE_OVER event. No Problem so far, i add an EventListener for MOUSE_OVER and MOUSE_OUT so it slides up if mouse
leaves the menu.

I want the buttons to change color if the mouse hovers so i add them a MOUSE_OVER and MOUSE_OUT.

But now, if the mouse is over the button the menu receivs a MOUSE_OUT because the mouse is now over the button and no longer over the menu.
How can i provent sending an MOUSE_OUT event from the menu if the mouse enters the button? If i set mouseChildren = true for the menu the
buttons don't receive any events so that would'nt help.

Anyone got an idea how this could be done?



Create a new Flash CS3 AS3 File, insert the code in frame 1. Watch the trace output if you move over the button on top to see what i mean.

Code:

// create menu bar
var menu:Sprite = new Sprite();

menu.graphics.beginFill(0xcccccc);
menu.graphics.drawRect(0, 0, stage.stageWidth, 100);
menu.graphics.endFill();

// create clickable link inside that menu bar
var spText:Sprite = new Sprite();
var tfText:TextField = new TextField();
tfText.autoSize = TextFieldAutoSize.LEFT;
tfText.textColor = 0x000000;
tfText.text = 'click me';

var bounds:Rectangle = tfText.getBounds(this);

// position everything
spText.x = 10;
spText.y = 70;
menu.y = -90;

spText.addChild(tfText);
menu.addChild(spText);

spText.buttonMode = true;
spText.mouseChildren = false;

addChild(menu);

// add event listener
menu.addEventListener(MouseEvent.MOUSE_OVER, expandMenuBar);
menu.addEventListener(MouseEvent.MOUSE_OUT, collapseMenuBar);

function expandMenuBar(e:MouseEvent):void {
   trace('exand menu bar');
   menu.y = 0;
}

function collapseMenuBar(e:MouseEvent):void {
   trace('collapse menu bar');
   menu.y = -90;
}

spText.addEventListener(MouseEvent.MOUSE_OVER, highlightLink);
spText.addEventListener(MouseEvent.MOUSE_OUT, unHighlightLink);

function highlightLink(e:MouseEvent):void {
   tfText.textColor = 0xff0000;
}

function unHighlightLink(e:MouseEvent):void {
   tfText.textColor = 0x000000;
}

Major Issue: MovieClip Inside Movieclip Will Not Have MouseEvents?
Hey guys, I got this empty MovieClip i add to the stage called 'container'. In container, I also dymaically add warrior(), warrior2(), and warrior3(). Now Im trying to add my rollover state for warrior, however, it never works?

When I place the warrors inside of a container in design time and then attach the code and place it on the stage, it works? Any Ideas?

public function addHitState(container:MovieClip, linkage_name:String, id_name:String):void{
var class_definition:Class = getDefinitionByName(linkage_name) as Class;
var added_clipisplayObject = new class_definition();
added_clip.name = id_name;
container.addChild(added_clip);
added_clip.x = 1151.2;
added_clip.y = 407.8;

added_clip.buttonMode = true;
added_clip.addEventListener(MouseEvent.ROLL_OVER, rollOverFunction);
};

private function rollOverFunction(event:MouseEvent):void{
trace("@");
};

Copyright Đ 2005-08 www.BigResource.com, All rights reserved