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


Similar Posts:


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 3.0 :: Only Target Certain Child Objects?

Jul 31, 2009

I want to set the scaleX and scaleY of certain child objects within a movieclip, but there are tons of other elements inside of it. Here's what I have so far:

for (var i:uint = 0; i < outer_mc.numChildren; i++) {
trace(' | ' +i+'. name:' + timeline_mc.getChildAt(i).name);
}

This returns 60 child objects. The 50 I want to scale down have "_mc" appended to their instance name. I figure I should make a new array or variable and set the scale of those to whatever I want.

View 4 Replies

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 :: 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

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

Flash :: Localy Execute Actionscript Bytecode

Nov 24, 2009

i want to execute a piece of bytecode so that it will run in a specific scope ? for example i want to be able to run this code

label.x = 100+label.width

and have it react to a label instance that is somewhere inside the compiled swf. i want the code have the 'this' keyword of my abc code to point to the parent of the label instance. as i understand the eval library at [URL] will convert AS3 code to abc, which has to be loaded in as if it were an external swf. so the this keyword would always point to "global"

in the examples at hurlant the only way to access anything in the loading swf is to create a top-level class without packages i also found this page [URL] actionscript to be usefull. it has a class that allows you to pass data from the scope of the evaluation.

that is something, but what i really wanted is to actually execute it 'directly at' the scope of evaluation anybody know if this is possible ? i just want to create a command line from where i can execute code and also trace properties of the running swf. for example i want trace(label.x) to work, and set properties by doing label.text = "bla" etc...

View 1 Replies

Flash ::capture Child's Event.target?

Dec 23, 2011

I want to get the value of e.target inside the visual parent of a movieclip( ChildClass). in the following code.

public class ParentClass extends MovieClip
{
public function ParentClass()

[Code]....

View 1 Replies

ActionScript 3.0 :: Add AddEventListener And MouseEvent  To Child MCs?

Feb 7, 2009

show a demo using Actionscript 3 where a child movieclip is added dynamically in a loop using addchild within a cotainer movieclip. Then the child movieclip has an addEventListener MouseEvent added to the child, not the container, in the code.

View 4 Replies

Flex :: Mouseevent - In OnMouseOut Is Trigerred On Child?

Jul 27, 2010

In flex, I am using the following code:

mx:HBox id="box1" mouseOver="onBox('box1')" mouseOut="outofBox('box1')"
// adding label
// closing HBox

[code].....

View 1 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 :: MouseEvent.CLICK Blocked By Child Bitmap?

Jul 4, 2010

If anyone has come across this problem or is educated enough so that you may come up with a working solution then please post here. Okay so at the moment I have 2 swfs. One swf is the main swf, which contains a class called Avatar. This class extends Sprite and has 1 child, which is a bitmap image.
 
What I do is load the child swf into the main swf, create an object of the Avatar class and pass the Avatar object down to the child swf. The child swf takes this object and adds it to a Sprite object as one of it's children. Then I add an event listener for MouseEvent.CLICK to the Sprite object (the one containing the Avatar sprite) that is in the child swf.
 
Now when I go to click the Avatar bitmap inside the Sprite inside the child swf. The mouse click event does not fire.

View 2 Replies

Flex :: SWFLoader - Child Apps Couldn't Access Certain Objects That Were Instantiated By Another Child App?

Aug 23, 2010

i have problem with swfLoader in flex, when i close following code in click method i can easly add many swf to main application

<mx:VBox id="content" width="100%" height="100%" ></mx:VBox>
public function doIT():void
{[code]....

when i close adding those swfs in loop i have the same error, it looks like child apps couldn't access certain objects that were instantiated by another child app, so what can i do?

View 1 Replies

ActionScript 3.0 :: MouseEvent - Click And Drag Objects

Feb 17, 2009

I have unit A: on a mouseEvent: MouseUp and MouseDown event. I'm going click and dragging objects.
Unit A when I pick it up says I have picked up Unit A. I drop it in a location and it stays. GOOD
I pick up Unit B and it says I picked up Unit B. I drop it on top of Unit A and it says I have dropped Unit A. NOT GOOD.

I only want to drop unit B, not A. So I looked at the events:
Target: The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.

So I use currentTarget instead:
currentTarget: The object that is actively processing the Event object with an event listener. Except they both return the same. Both will register Unit A, even though I am holding Unit A.

View 1 Replies

Actionscript 3 :: Dispatch MouseEvent.MOUSE_UP When Un-clicking Only Some Objects, Not All Of Them?

Sep 24, 2011

What if I want to dispatch MouseEvent.MOUSE_UP when un-clicking only some objects, not all of them? I mean, when I add eventListener that listens for MOUSE_UP, it's dispatched (thought with different targets) every time I un-click anywhere, if you understand what I mean. How can I "fix" it?

View 1 Replies

ActionScript 3.0 :: Get The LocalX Value Of A MouseMove Event?

Aug 15, 2009

I'm trying to get the localX value of a mouseMove event which is working but the value isn't linear. The width of the object registering the mouseMove is 435px so you would expect to see values returned from 0-435. This is not the case because that object has child objects and everytime the mouse moves over one of them it resets because it picks up that objects localX. how can I get the mouseMove to return values only on the object it is register to? (kind of like how a rollover or rollout is only concerned with it's targeted object)

ActionScript Code:
thumbViewer.addEventListener(MouseEvent.MOUSE_MOVE, scrollStart);
private function scrollStart(event:MouseEvent):void
{

[code]....

View 6 Replies

ActionScript 2.0 :: Saving Files Only Localy?

Mar 23, 2002

Is there really no way to save an txt file on line. I know how to do it with a generator, i really would like to know it, so i could save the highscores on any computer.

View 6 Replies

ActionScript 3.0 :: XML - How To Target Child

Feb 19, 2010

<?xml version="1.0" encoding="UTF-8"?>
<tt xml:lang="en" xmlns="http://www.w3.org/2006/04/ttaf1"  xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling">
<head>
<styling>

[code].....
 
I think this is a simple question, but can't quite figure it out. How would i read the <div> that is english "en"?
 
something like this - tho this does not work:

trace(_xml.div.(@lang=="en"));

View 3 Replies

ActionScript 3.0 :: Storing And Preserving Data Localy?

Jan 26, 2008

I am making app that works as stand alone, do some calculations and sting formating. Also it need to save data localy, and be able to reload it when needed.I have read that Shared Objects do that but also have limitation. For example the data can be deleted without user doing it. I need the data to somehow persistend and been able to delete only by the user of the app. As extra exporting data for other user will be usefull, but is not requared

View 2 Replies

ActionScript 3.0 :: Getting Error 1119: Access Of Possibly Undefined Property LocalX?

Aug 11, 2010

I am trying to execute this :

[code]...

When I execute this it shows the error :

1119: Access of possibly undefined property localX through a reference with static type flash.events:Event.I wanna execute these functions to a part of the stage. I mean the function ABC draws in a specific area and XYZ in an all together different area. How can I do that ?

View 7 Replies

Flash :: Possible To Have Different Line Scalemode Options For Parent And Child Display Objects?

Sep 1, 2011

Imagine situation when child component is scaled and parent component is scaled as well. I want line to be drawn without scaling in child component and to be scaled in parent. Is it possible to achieve this?

View 1 Replies

ActionScript 3.0 :: Removing Target Child?

Jan 8, 2012

I've run into a problem when trying to move one of my sprites from the stage when it dies.So far what I'm having to do is call the Death method from the main class, which then goes to the Enemy Class in order to play the animation, once the animation has reached the last frame an event is triggered which is situated in the main frame which then removes the now dead enemy from the stage. However it doesn't appear to be able to target the child which I want removed =/Main Class:

Code:
private function hitCheck(e:Event = null):void{
var samuraiPos:Number = SamuraiChar.samuraiPos();

[code].....

View 4 Replies

Actionscript 3 :: Set Up Collision Detect So That It Ignores A Child Of The Target?

Feb 23, 2010

So in my game, every 'enemy' movieclip creates a textfield that represents the name of the enemy. The problem is, I want my collision detect engine to detect a collision with the enemy itself, not the textfield. This is the code that I have currently have on my collision class for detecting a collision with the enemy:

for(var i = 0;i < _enemies.length; i++)
{
if(CollisionEngine.isColliding(_laser, _enemies[i]._enemyNameTextField, _animation))

[code]......

View 2 Replies

Actionscript 3.0 :: Target Child's Attribute Nested In Movie Clip?

Apr 2, 2009

I have a Movie Clip called panel that I have added three children to (points, answer, question). I need to know how to access the alpha property of each child so that on a ClickEvent I can change the alpha so that the appropriate one is showing.[code]

View 8 Replies

ActionScript 3.0 :: Can Subclass Target Other Objects?

Feb 23, 2009

I have my main.swf which has class of Main.as which control everything.Then in main.swf I have 3 movieclips that acts as a button and they share a class of Button.as which controsl all the button functions btn1, btn2,bt3 are all place on stage and in Main.as I control their positions.When you click on a btn, it moves to a new location at the same time the other 2 btns will move as well.I can get the target btn that's been click to move just fine, but I can't get the other 2 btns to move and they all share the same class. I know this probably has to do with a targetting issue... I think. Is there a way I can make the connection in same Button.as class file? Or do I use like some global event dispatch?

View 2 Replies

ActionScript 3.0 :: Target Certain Objects In An Array?

Apr 23, 2010

I have an array with 3 objects and added a click event to them, when clicked the 3 objects move 200 pixels down, but i would like to become that the objects that werent pushed get an alpha of 0.5

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 :: How To Target Externally Loaded Objects

Jun 15, 2009

i have creating an image gallery of sorts. I have loaded my thumbnails through an xml like so:

Code:

function loadThumbs(){
for (var i = 0; i < totalElements; i++){
var thumb_url = elements[i].@thumbSrc;
trace("totalElements: " + totalElements);

[code]....

now i want to have it so that when u click a thumb, it re-layers them. I am able to get the one u click to the front of the order, but how can i tell the others to layer as i want? I guess the problem is that I cannot use the name of the display object and i can't user image_loader to setChildIndex with.

Code:

function replaceElementAndMoveThumb(event:MouseEvent):void{
setChildIndex(event.currentTarget, numChildren - 1);
trace(event.currentTarget);
}

I am thinking that in AS2 I would use the movieclip instance name, but don't think this works in AS3.

View 2 Replies







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