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


Similar Posts:


ActionScript 3.0 :: Add Event Listener On Parent For Event.target = Child?

Jul 30, 2009

I have these buttons in a movie clip and I would like to have only one event listener for the parent, using event.target to point to the children. I have also tried event.currentTarget, and it didn't work.here is the code that works:

test01.abtn.addEventListener(MouseEvent.ROLL_OVER, mouseHandler);
test01.bbtn.addEventListener(MouseEvent.ROLL_OVER, mouseHandler);
test01.cbtn.addEventListener(MouseEvent.ROLL_OVER, mouseHandler);[code]....

It is only targeting the movie clip, not the buttons inside the movie clip.

View 4 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

IDE :: Bind Method So Event Point At Parent / Class Rather Than Target?

Feb 16, 2009

I just recently been using a lot of prototype javascript stuff, and was wondering there was anything like the "bind" method, for use in AS3. It's proved quite useful to be able to look both at the event.target as well as the class object the handler function might be associated with.

View 5 Replies

ActionScript 3.0 :: Target The Parent Container Of Whichever Object Receives An Event?

Sep 28, 2010

how I can target the parent container of whichever object receives an event?

Code:
Parent1.btnA.addEventListener(MouseEvent.CLICK, doSomething);
Parent2.btnA.addEventListener(MouseEvent.CLICK, doSomething);
Parent3.btnA.addEventListener(MouseEvent.CLICK, doSomething);

[Code].....

View 1 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

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

Flex 3 :: Determine If An Event Target Is Descendant Of Component

Nov 19, 2010

I have a custom component with a couple of text input fields (among other things) that is used as the row components in a tree. I have had to write my own drag and drop handling, and have almost finished the start handler (which I did last), using mouseDown as the event to kick if off.It basically works, but when the tree is expanded enough so that a scroll bar shows, using the scroll bar drags a row of the tree at the same time ! Not the desired behaviour.Looking in the debugger, I can see that when a row of the tree is dragged the currentTarget is the tree itself, and the target is the textInput component. Looking at the parents of that component I can see my custom component (that contains the textInput) a couple of levels up.My question is, is there an easy way to determine if this target is descended from my component, so that I can initiate a drag only if that is the case ? event.target is doesn't work by the way.

View 2 Replies

Actionscript 3 :: Finding Parent Of A Component?

Aug 3, 2011

In my application, I took a panel and to that I added an image by giving some image path. To that image I added DrawingArea(custom) object and started drawing. After free hand drawing I'm adding that to its parent(by giving this.addChild(graph);). Here this indicates what? What can I give instead of this(especially in case of removing a particular child)?

private function StartMarking(eve:MouseEvent):void
{
if (!eve.buttonDown)

[Code].....

View 1 Replies

ActionScript 3.0 :: Finding The Biggest Parent?

Feb 10, 2009

This is in AS3:

ActionScript Code:
itemPropertyX = event.target.parent.propertyX;

Simple enough code, works fine when the event.target.parent is the one that has .propertyX, but I'm using this as part of a function for use on various things, and not event.target is the same number of .parents from the .propertyX, so some of them need to be

ActionScript Code:
itemPropertyX = event.target.parent.parent.propertyX;

.. but I can't change the code or the ones that only need the one parent don't work, right?So.. how do I find the topmost parent? I tried using event.target.root but that comes out to be the stage every time.

View 0 Replies

Flex :: Drag Manager - Access The Target Of Dragging Event In DragDropHandler?

Mar 29, 2011

I'm making a Matching Game where I have some images on my left and I can drag them onto images on my right and if they are matching, they should both disappear from the stage.

[Code]....

findMatch() is a function that finds in my XML file the path of the file that matches the file that is being dragged. Having that path, I send it to dragEnterHandler where it compares it with the path of the dropTarget file and if they are the same, it accepts it. Then in dragDropHandler, I'm changing the source path of my second image to "", so that it disappears from the stage. How can I access the first file (the one that was being dragged), so that I can change its path to "", to get rid of it?

View 1 Replies

AS :: Flex - Handle Custom Event In Parent Component?

Feb 6, 2010

I defined a simple event class:

public class NewMoveEvent extends Event
{
public function NewMoveEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=true)

[code].....

View 1 Replies

ActionScript 3.0 :: Finding Parent Array Of Object?

Aug 21, 2009

There is most certainly as easy way of doing this, but for the life of me I can't find it.

How do I determine the array name of an object i.e. when I hover over a certain clip on stage, I want to identify which array it is from.

View 2 Replies

Flex :: 4 - Multiple Instances Of A Custom Component Listening The Same Event Of A Parent

Jan 28, 2011

In short: I need an event listener in a custom component so all its instances (without editing them) react at the same time, fired by a dispatched event in its parent container. In detail: I have a custom component with Tab navigator. (The tabs are intended to show different preferences for different Languages.) I have a button bar with buttons for all the languages. There are a lot of instances of the custom component.

I want to click in a button of the languages bar and get ALL the instances switched to the same tab (the custom component contains the logic to change the tab). I can do it by adding the event listener for EACH INSTANCE of the custom component, so it calls an internal function that changes the tab. But it seems to be very coupled, isn't it? I wonder if it can be done in the master CLASS of the component, so it listen for events in its parent container, whichever it is. In my mind this code shoud work, but it doesn't (obviously ill'use a custom event to pass the new language value): this.parent.addEventListener("lang_change", this.change_tab); This way I can just drop an instance of the component, and see it working for itself.

View 2 Replies

Flex :: Web Applications - When Export A Release Build, It Generates A Whole Bunch Of Files?

Jan 19, 2011

I made an application in Flex 4. When I export a release build, it generates a whole bunch of files. (including the skins used, etc, etc.)How do I make those plentiful files except the container HTML file, get compiled into a single SWF file?E.g.My folder should only contain:

my_app.swf
my_app.html

But my_app.swf should still run like a normal Flex 4 app, only this time, all the files, images, skins, etc are inside that one SWF file.

View 2 Replies

ActionScript 3.0 :: Get Parent Of E.target.name?

Jul 16, 2009

How would you get the name of the parent of a movieclip? below is only some of the options I tried to trace.
  
function getParentName(e:MouseEvent):void{
trace(e.target.parent.name);
trace(parent(e.target));

[Code]....

View 2 Replies

ActionScript 3.0 :: Access Event.target Outside Event Listener Method

May 13, 2010

how can i access event.target outside event listener method.say for example

my_mc.addEventListener(MouseEvent.CLICK, onC);
function onC(e:MouseEvent):void
{
var m:MovieClip = e.target as MovieClip;
}
trace(m.totalframes);/// not working

now what if i want to get totalframe property of m instance, in short for every movieClip clicked.

View 11 Replies

ActionScript 3.0 :: Target Parent Of A Class?

Oct 2, 2009

I am trying got get the parent of a class so I can set a variable. first I problem I have is I cant even trace parent. I have a simple class nothing in it except a trace(parent) I instantiate it on the main timeline of a fla and it returns null. I have tried to trace root and it returns null as well. the class extends movie clip or sprite

View 7 Replies

ActionScript 3.0 :: Difference Between Event.target & Event.currentTarget?

May 4, 2010

i'm new to AS3. Couldn't understand what some of the explanations out there are getting at, so i decided to post it here. In the code example below, what does event.target & event.currentTarget point to?

[Code]...

View 5 Replies

ActionScript 3.0 :: Can't Target Parent Movie Clip

Feb 17, 2010

I have a swf which contains a main menu bar along the top which has been added dynamically at run time. ALl the controls for this bar live inside btnHold One of these buttons loads in a new swf. There is a button within this second swf that I want to use to control the main menu bar in the top layer (I want to make it invisible for a time, or get its layer and then ensure that its not too high etc etc)However, I just can't work out how to target this btnHold from within the newly loaded swf.

View 2 Replies

Actionscript 3 :: Target Ignoring Parent MovieClip

Apr 4, 2012

I changed the question as its seems to be a problem with target not registering children mc/ or nested MovieClips.

var box:Box = new Box();
ground.push(box);
levelPlane.addEventListener(MouseEvent.MOUSE_DOWN, onOver);

[Code]....

How Do i target the movieclips(BOX) inside of the main MovieClip(levelPlane)?
imagine i have nested 10 boxes inside a MovieClip Called "levelPlane" i want to click on any of the boxes to add another Mc on the box i clicked x,y location.

View 2 Replies

ActionScript 2.0 :: Target Parent Movieclip From Within Itselelf

Mar 15, 2012

how do i go about and target a movieclip from within itself, without knowing it's name?

View 8 Replies

ActionScript 3.0 :: Event.target Or Event.currentTarget?

Jul 11, 2011

I have a Flex 4 List component which I have tied a click event to. In my event, my assignment of the source file paths works just fine --> my larger image displays just fine when a thumbnail click happens. My problem comes when trying to attach elements of the dataProvider to text inputs on another panel. Actionscript is throwing an error. Can someone point me in the right direction??

[Code]...

View 6 Replies

ActionScript 3.0 :: Mouse Event And Event Target

Nov 26, 2009

i have these 2 functions and both are the same:

as you can see disabledAction receives e.target as a paremeter from another function (click function actually).

is there a way to somehow call disabledAction from rollOverHandler ? (so that the code doesnt repeat)

Code:
function disabledAction(target:MovieClip):void {
var txt:TextField = Finder.findTextfield( target as MovieClip ) as TextField;
if (txt) {

[Code].....

View 1 Replies

ActionScript 3.0 :: Refer To Movie Clip In Parent That Includes Target.name?

Nov 18, 2009

I am writing code in a MovieClip and want to refer to another MovieClip that shares the same parent.it'll be MovieClip(parent).theOtherMovieClip.But I want to refer to the MovieClip using the current MovieClip's instance name + "txt." This was my guess at the code, but it doesn't work.

MovieClip(parent).MovieClip(this.target.name+"txt" )

This didn't work either

MovieClip(parent).this.target.name+"txt"

View 1 Replies

Flex :: Get Parent Form Textfield "enter" Event?

Nov 2, 2010

I'm not sure what the best practice is when attempting to "do something" with a form as a result of a user interaction - I'm certainly open to an alternative if it's the best practice.

There's an MXML event property called "enter" that applies to s:TextInput which calls an AS event handler when the user presses the Enter key within a TextInput field (imagine a Search field - you type in your search term and press Enter).

Now, within that event handler, I need to get at the parent Form object. Since we're talking best practices here, I'm not interested in referring to the Form by ID, in case my "enter" handler must be able to work with different forms.

My question is - what is the best way to get a handle on the event target's parent form in Flex? The parent-child hierarchy in Flex is absolutely ludicrous [code]...

The TextInput is initiating the event, and is the event.target. Following my MXML hierarchy, a logical chain might be event.target.parent.parent taking me from TextInput to FormItem to Form, but as you can see, the lovely skinnable Spark architecture puts all these other display objects and containers in-between.

View 2 Replies

ActionScript 3.0 :: Finding Mouse Position WITHOUT An Event?

May 3, 2009

I'm trying to get the position of the mouse while it is stationary. For example, if the SWF loads and the mouse is already on the SWF, how can I detect it's position WITHOUT waiting for the user to move the mouse.

how to grab the mouse position when the mouse moves, just not how to obtain that info when it has not moved yet.

View 1 Replies

ActionScript 2.0 :: Finding An Event That IU Can Assign A Function That Is Called When An Swf Closes?

Aug 11, 2004

Is there an event that IU can assign a function that is called when an swf closes?

View 5 Replies

Professional :: How To Use UnCaughtErrorEvent - Unhanded Event Error (ioErrorEvent For Not Finding The Xml File)

May 27, 2010

I am trying to use the new unCaughtErrorEvent, as explained here: [URL] When testing the event I run across two problems:

1 - when testing the movie from the flash IDE, the uncaught error is indeed caught and handled (as in the example) BUT the original

error still gets thrown! For example, when loading an XML file that does not exist: - first the uncaughterror event gets called. (good!) - then I get an unhandled event error (ioErrorEvent for not finding the xml file). Isn't the whole point of catching uncaught errors that you can catch ALL these errors? This way it seems rather useless to me.

2 - when testing the uncaughterror handler from a html page, the debugger gives an entirely new error: VerifyError: Error #1014: Class flash.events::UncaughtErrorEvent could not be found. So for now, I'm truly baffled as to what UncaughtErrorEvent is supposed to do and why it doesn't work

View 4 Replies

Actionscript 3 :: Get Name Value Of Event Target?

Apr 16, 2011

I'm implementing a text display area inside an app that displays selected text when the user mouses over one of four elements. Rather than creating a handler function for each element, I would like to get the name of the instance that is calling the handler in order to implement a switch statement. I've tried two ways, but both aren't working:

//install event handlers
initialText.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
timeText.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
withdrawalText.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);

[Code]....

Both of those return undefined for the variable name. However, in the debugger, I can trace the event values through currentTarget.name, and that shows the instance firing the handler function, whether it be withdrawalText, initialText or timeText. So how can I apply the name value to a variable in order to determine which text block to display?

View 1 Replies







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