ActionScript 3.0 :: Finding The Target Of A MouseEvent?

Jul 2, 2010

I have an object (a Loader) that you can click on, resulting in a MouseEvent. Clicking on the Loader moves it, which I do by modifying e.currentTarget.x in the MouseEvent function, a la:
   
private function onClick(e:MouseEvent):void {
e.currentTarget.x = 0 - (e.currentTarget.width/2);
}

The problem is, I also want to change the ChildIndex of the target. I tried this:

private function onClick(e:MouseEvent):void {
e.currentTarget.x = 0 - (e.currentTarget.width/2);
canvas.setChildIndex(e.currentTarget, 10);
}
 
But that results in a compile error: "Error Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject. at line 85 in Rotation.as"
 
I've noticed that sometimes I need to refer to the target as e.currentTarget.loader, so I tried that (canvas.setChildIndex(e.currentTarget.loader, 10);), but I get an error when I run it: "ReferenceError: Error #1069: Property loader not found on flash.display.Loader and there is no default value. at Rotation/onClick()". What's the proper way for me to get the target so I can apply setChildIndex?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: MouseEvent Target MouseEvent RelatedObject?

Jul 24, 2009

I have the following:
 
rwBtn.addEventListener(MouseEvent.MOUSE_OVER, audioOver);
function audioOver(e:MouseEvent):void
{
var thisClip:MovieClip = e.relatedObject;
thisClip.alpha = 0;
}
 
I would like to change the alpha of the clip that is being rolled over. I don't know how to target the clip that is being rolled over. How do I do that?

View 3 Replies

ActionScript 3.0 :: Get InstanceName / Object From MouseEvent.target?

Jun 4, 2009

[Code].....

When Mouse is down on PlanetEarth_mc, only PlanetEarthOuter_mc starts moving, leaving PlanetEarthInner_mc and PlanetInner_txt in the same existing place. I want to call the parent of the target i.e. I want to move PlanetEarth_mc. also, EventReceived.target.parent.startDrag();//Gives Error. How can I achieve that from received MouseEvent Object I hope u understand this.

View 3 Replies

ActionScript 3.0 :: Detect If The Target Of A Mouseevent Is A Child Of A Movieclip?

May 29, 2010

I have a parent movieclip with a few other movieclips inside it. When I add a mouseclick eventlistener to the stage and click on one of the children, i want the target of the event to be the parent movieclip. I still need the children to be mouseEnabled.

how do you check if a movieclip is a child of another?

View 9 Replies

ActionScript 1/2 :: .hittest Not Finding Target

Apr 20, 2010

i have a game in which the character shoots bullets and kills enemies and whatnot. Now, i am trying to get the bullet to disappear when it collides with a wall.[code]when the bullet goes out of bounds, the bullet disappears, but when it hits the enemy or wall, it seems that the collision is not detected. I have checked each instance name and linkage, but have so far come up with nothing.

View 10 Replies

Flash :: Get The MouseEvent.localX And LocalY Of A Target But Not Its Child Objects?

Jul 24, 2009

I'm creating a simple drawing application that adds new Shape objects to a MovieClip "canvas" every time the user clicks and drags. The problem is, I'm noticing that even though the MouseEvent listeners are set to the MovieClip, the child Shape objects are being returned as targets as well. This disrupts the localX and localY as well, causing the drawing cursor to jump around as the coordinates change from being local to the entire MovieClip to local to the Shape the mouse is currently over.Is there any way to retrieve the most parental target from a MouseEvent?

View 1 Replies

ActionScript 3.0 :: Finding Out Index Number For Event.target Of An XMLList?

Dec 7, 2009

This is my first AS3 post, I have recently taken the step from AS2. I am displaying an image from an XMLList using event.target.name. I need to access it's index number in the list to set to a variable.Here is the code:

thumbLoader.addEventListener(MouseEvent.CLICK, showPicture);
function showPicture(event:MouseEvent):void
imageLoader.load(new URLRequest(event.target.name)); 

[code].......

View 3 Replies

Actionscript 3 :: Finding Target's Id When Its Parent Generates Event In Flex?

Aug 10, 2011

I'm trying to get the id of the target in showMe(). For example, when I click button or image panel's showMe() function executes first. Here I want to capture the button/image's id.

private function init():void
{
pnl.addEventListener(MouseEvent.MOUSE_DOWN,showMe);
}

[code]....

View 2 Replies

Flash :: AS3 MouseEvent.MOUSE_MOVE Event Stops Responding After MouseEvent.CLICK Call?

Nov 6, 2010

I have several stage event handlers to enable mouseovers over several dynamically generated moviecilps on the stage that then change their alpha to indicate the mouse is over that particular mc... fairly trivial (mcOver handler). Additionally, I also want to know what MC is clicked, so I update a public variable (public var activemc:Number) with the ID of the dynamic movieclip when the mouse is over it (using a hitTest to check, which is why the EventListener is added to stage and not to the MC), which is checked in the mcClicked handler:This is in the constructor:

//stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
//stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mcOver);[code]....

However, the mouseover behaviour (alpha 0 when over, alpha 1 when out) stops working as soon as I click on any movieclip on the stage, and the mcClicked ID checking (below) stops working completely. I don't know if this is to do with focus:

private function mcClicked(event:MouseEvent):void {
myTextField.text = String(activemc); // activemc is a public var:Number with the movieclip //ID
}

I then tried adding the event handler for the stage mouse_move again and this gets the mouseover working again but only for 1 more click, after which it stops again:

private function mcClicked(event:MouseEvent):void {
myTextField.text = String(activemc); // activemc is a public var:Number with the movieclip //ID
stage.addEventListener(MouseEvent.MOUSE_MOVE, mcOver);

View 1 Replies

ActionScript 3.0 :: Get MouseEvent.ROLL_OVER Or MouseEvent.MOUSE_OVER To Pass Through To MovieClip Underneath

Jul 9, 2009

I have a MovieClip (call it base_mc) which is under a bunch of other MovieClips (call them subclips). The MovieClips on top are all mouseEnabled with MOUSE_OVER, CLICK, etc, event handlers. I want to capture the event of MOUSE_OVER (or ROLL_OVER) on the base_mc as well. Any time I am over one of the subclips I am also over the base_mc clip. How can I capture this event?

View 2 Replies

ActionScript 3.0 :: Flex - Diffrence In MouseEvent.CLICK & MouseEvent.MOUSE_DOWN?

Oct 21, 2010

I'd like to know what is the difference between MouseEvent.CLICK & MouseEvent.MOUSE_DOWN. Because when i use MouseEvent.MOUSE_DOWN for a button to set full-screen view its doesn't work, instead of this MouseEvent.CLICK works. So what was the reason.

View 3 Replies

ActionScript 3.0 :: MouseEvent.MOUSEDOWN Works But MouseEvent.CLICK Doesn't

Nov 6, 2010

I'm making a button for the first time, and I wanted to use a full click to drive it. However, when I use addEventListener(MouseEvent.CLICK, onClickHandler); nothing happens when I click on it. When I use (with the rest of the code being identical) addEventListener(MouseEvent. MOUSE_ down, onClickHandler); it works like a charm.

View 6 Replies

ActionScript 3.0 :: Difference Between MouseEvent.MOUSE_UP And MouseEvent.CLICK?

Apr 7, 2009

What is the difference between MouseEvent.MOUSE_UP and MouseEvent.CLICK? Why should I use one of these over the other? 

Code:myButton_btn.addEventListener(MouseEvent.MOUSE_UP, fNavigate, false, 0, true);
myButton_btn.addEventListener(MouseEvent.CLICK, fNavigate, false, 0, true);

View 3 Replies

Actionscript 3 :: Cancelling MouseEvent.CLICK After MouseEvent.MOUSE-DOWN

Aug 11, 2011

I have a MOUSE_DOWN handler that creates a CLICK event listener on a child object. Naturally, as soon as you release the mouse button, if you happen to be over the child object, the CLICK event fires.I was disappointed to discover that event.stopImmediatePropagation doesn't interrupt the CLICK event from registering the MOUSE_DOWN as part of its detection cycle. It makes sense that it doesn't but still... disappointing.A MouseEvent.CLICK consists of detecting a MOUSE_DOWN on the object and then if it's followed by a MOUSE_UP without leaving the object, he event fires. I had hoped that by cancelling the MOUSE_DOWN event, it would clear that out of the CLICK buffer, but no such potatoes, alas.This could all be handled with a flag and a couple more MOUSE_UP and MOUSE_DOWN handlers, but dang, smacks of effort

View 2 Replies

ActionScript 2.0 :: Stop Further Items Being Dragged Onto A Target When The Target Box Is Full?

Sep 29, 2003

On the attached exercise, is it possible to stop further items being dragged onto a target when the target box is full?

View 1 Replies

Flex4 :: Difference Between Target And Current Target

Nov 28, 2011

What is the difference between target and currenttarget in flex?What is the difference between Target and Current Target in Flex especially in mouse events.

View 2 Replies

ActionScript 3.0 :: Difference Between "$event:MouseEvent" And "e:MouseEvent"?

Jul 28, 2011

What's difference between "$event:MouseEvent" and "e:MouseEvent". What do they do?

View 4 Replies

ActionScript 3.0 :: Target Movieclip With E.target?

Aug 30, 2010

qi have a movieclip which is added to the stage:

var profileholder:profileHolder=new profileHolder ;

inside of profileholder is another movieclip(infoBtn) that acts as a button.when the mouse is over profileholder i want to do something with infoBtn like:

//profOver is the over state of profileholder
function profOver(e:Event) {
e.target.infoBtn.alpha=1;
}

this doesn't work and brings up this error:ReferenceError: Error #1069: Property infoBtn not found on flash.display.Loader and there is no default value.
at main_fla::MainTimeline/profOver()

i also tried:
function profOver(e:Event) {
var item:profileHolder=e.target as profileHolder;
item.infoBtn.alpha=1;
}

and get this error:TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 1 Replies

ActionScript 2.0 :: Error - Target Not Found: Target="whoweare" Base="_level0.instance20.instance48.instance49"

Mar 14, 2005

i don't know why this isn't working.i got a button. and when it's pressed, i need it to go and play a frame in a movie clip. i'll test it and then when i click on it, i get this:

Target not found: Target="whoweare" Base="_level0.instance20.instance48.instance49"

this is the code that i am using:

on (press) {
tellTarget ("whoweare") {
gotoAndPlay (51);
}
}

View 14 Replies

ActionScript 3.0 :: Difference Between "$event:MouseEvent" And "event=MouseEvent"?

Jul 27, 2011

What does "$" means in actionscript 3? What's the difference between "$event:MouseEvent" and "event=MouseEvent"?

View 2 Replies

ActionScript 2.0 :: Target Not Found: Target="_root.icon01" Base="_level0"

Feb 16, 2005

so, i'm making an animated rollover, and i get an output error that says this:

Target not found: Target="_root.icon01" Base="_level0"

i have no idea what the base="_level0" means.

View 1 Replies

ActionScript 3.0 :: Use A MouseEvent Twice?

Aug 25, 2010

I linked a button to a .php file, but now i have the problen that if I try to do it again, I get an error : 1021 Duplicate function definition

ActionScript Code:
myButton.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:MouseEvent):void

[code]......

View 1 Replies

ActionScript 3.0 :: Way To Extend MouseEvent?

Sep 28, 2009

I want to simplify some event handling of an flash app (if that is possible).. so i thought to extend MouseEvent in some way to do it.What i need is OVER, OUT and CLICK callbacks with an extra parameter (an object)... or something like that..I tried:

Code:
package com.ui{
import flash.events.MouseEvent;

[code].....

View 2 Replies

ActionScript 3.0 :: More Than 1 MouseEvent For 1 Button?

Apr 21, 2010

This is what I used to have in AS2

Code:
on (rollOver) {
gotoAndPlay(2);

[code].....

View 2 Replies

ActionScript 3.0 :: StartDrag With MouseEvent?

Sep 24, 2009

I've created a function called dragItem() that I call with the MOUSE_DOWN event. I've got it working....kind of. I can access the function when the mouse is clicked and I can even get the name of the instance when the mouse is down. I'm trying to use the same logic to get the single object to allow a drag. see my code below...
 
function dragItem(event:MouseEvent):void {            var instName:String = event.target.name;            trace(instName);            trace(event.target.width);                        event.target.startDrag();                        event.target.removeEventListener(MouseEvent.MOUSE_DOWN,dropItem);            event.target.addEventListener(MouseEvent.MOUSE_UP,dropItem);                    }
 
I get this error when I try to drag the item...ReferenceError: Error #1069: Property startDrag not found on flash.display.Loader and there is no default value.    at Main/::dragItem()

View 8 Replies

ActionScript 1/2 :: MouseEvent Not Being Recognized?

Jun 9, 2010

but1.addEventListener (MouseEvent.CLICK,play1) ;
function play1 (event:MouseEvent) :void{
gotoAndStop("Wales 1") ;
}
 
This is my code but the MouseEvent is not recognised

View 3 Replies

Actionscript 3 :: TouchEvent Vs MouseEvent?

Apr 10, 2012

I am develop on Air for iPad app, just wonder is TouchEvent more efficient or MouseEevent is doing fine. i am talking about performance wise, things like doing drag and drop and ect...

View 1 Replies

Flex :: MouseEvent Of Images?

Jan 2, 2012

I dynamically create images in a loop (flash builder 4.5) and when I set mouse click event, I'm using this:

image.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{fromThumbnail(e,i)});

to pass i. However, when I click on any image, the function thumbnail prints the last i.

Is there solution for this problem?

View 1 Replies

ActionScript 3.0 :: MouseEvent.MOUSE_WHEEL?

Aug 15, 2009

Why is working properly in Internet Explorer, but not in FireFox 3.0

View 0 Replies

ActionScript 3.0 :: MouseEvent.MOUSE_OVER?

Aug 25, 2009

I have two sprites A and B, both are irreuglar drawn shapes (both with a transparent fill) that overlap certain points. The current result is B on top (though which is on top is not really relevant, as the same problem will exist if A is on top). They are both children of the same UIComponent.

Both are listening for the MouseEvent.MOUSE_MOVE event. It is to occur when a corner on either shape is passed over by the mouse. Though, when the mouse moves over the corner of A and this corner is behind B the MouseEvent is never raised.From my investigation I've found when i turn the fill off on the sprites and just draw the outline of the shape the mouse event will raise, but this is not what is wanted. how can I get *both* the objects listening and responding even when the corners of one is overlapping the other?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved