ActionScript 3.0 :: Run A Function With CurrentTarget.name?
Oct 25, 2011
i'm wondering how i can run a function that has the same name as the current target. so when i click a button with the instance name "notes" this will run the "notes" function e.g
ActionScript Code:
evt.currentTarget.name();//run the function with the same name as the target
this doesn't work and returns a Error #1006: value is not a function.
I'm making a tile game in flash and I need to pass event.currentTarget (the current tile) into a new function which sends the tile back to it's start position.[code]I need to call this function from other places in my code..I've tried passing the object itself to another function as a variable but it loses it's start position information !
I have a movieClip in my library that I am loading into a scrollPane. When I click on the scrollPane I want to know the name of the target I am clicking on. I am trying event.currentTarget but all that I get in the output box is ObjectMovieClip. I want to use one function for all my buttons so when I click on them it loads another movieClip in my library. I realize I could make 3 separate functions, but I'ld like to use just one.
I am loading a series of thumnails through an XML file into a scrolling movieClip. I am able to get all of the images to load and scroll and even control their alpha value using event.currentTarget. What I am having a problem with is getting the corresponding XML attribute(@title) to load into a dynamic text field.Here is a snippet of my XML file:
The thumbnail alpha changes and the text field changes to the text that is defined by the first title attribute. What I need to figure out is how to use a variable instead of the "#". I'm assuming that I should be able to make use of event.currentTarget like I did to change the alpha of the thumbail movieClip.
If you have a series of sprites in a movie clip, can you get the currentTarget.currentTarget as it were? So if a sprite throws a mouse event, I can capture that?
Sorry if that's gobbledegook.
I have a movie clip called myMC. In that are a series of sprites sitting in a vertical row. On mouse up I want to know which sprite I was over. currentTarget gives me the parent movie clip, can I get the sprite underneath?
AS3 coding, and despite being able to find posts about most of my problems, this problem has stumped me, and I'm not certain what words to search for.I'm trying to make a list of MCs on my stage to link to external URLs.I figured the following would work, but it just pulls the 'event.currentTarget.name+"URL"'the instance names of the MCs are "idlink" and "findStore"Is there a way I can get the loadLink variable to pull the URL instead of the "idlinkURL" string, or is my logic for this completely backwards?
Code: var buyLinks:Array = [idlink, findStore]; // add listeners to the menu array
Have 8 mc's, and when I click one want something to happen to all except the one that I clicked.My question is how do I declare "all except currentTarget" for a MouseEvent?
I have create a few sprites consist of various music notes, when the cursor sprite move over to one of the notes, it would blink using intersect. I have no idea on how to make the cursor detect which note it overlap.
Possible Duplicate: Difference between e.target and e.currentTarget I don't really understand the difference between these two event.target and event.CurrentTarget and explanation.
I'm new to AS3 and was wondering how I can use something like: var mc:MovieClip = MovieClip(e.currentTarget); As part of another instance name. For example if the currentTarget was a move clip with an instance name of "oneNav" and then I wanted to control a movieclip with the name of "SuboneNav", how could I do it? All the variations of concatenation I'm familiar with weren't working. I even tied getting e.currentTarget.name instead but there always seems to be an issue.
I know I'm missing something rather basic here, but can't figure it out. I want to take a "currentlySelected" target of a hit test and attach it to a movieClip container. It traces as an object, but I can't figure out how to translate this to a movieClip. I'm sure I've done this before--- but I'm drawing a blank.
Code: trace(currentlySelected + " hit test box 1") currentlySelected.x=box1.x;
The event target. This property contains the target node. For example, if a user clicks an OK button, the target node is the display list node containing that button.
currentTargetproperty
The object that is actively processing the Event object with an event listener. For example, if a user clicks an OK button, the current target could be the node containing that button or one of its ancestors that has registered an event listener for that event.
is there something similar to currentTarget with dropTarget?Right now dropTarget will get me the "lowest" DisplayObject possible, but I'd like to get the top-most. I cannot use parent as my objects are of different nesting depths.
i'm trying to create a menu system where each item expands in height when clicked but is then collapsed back to the original state when other items are clicked.m is the height of the expanded state. n is the height of the collapsed state. i is the number tacked on the instance name.Also, I'm using Tweener for smoother transitions. I've done this already by copying out the code but it's 24 items so 24x24 lines of code when I'd like to be able to do it a little more elegantly. Here's roughly what I want to do, but don't know if it's possible:[code]So every box below the one that's been clicked on most recently gets the value of m added to the y value and every box above doesn't.Is it possible to retrieve the value of the variable i that corresponds to the currentTarget?
i have a set of 6 buttons and upon clicking one of the buttons i want to tween the others that were not clicked to fade out. how do i do this? i know how to do the tween part but i dont know how to get a hold of the buttons that are not currentTarget...
I have a number of MC's that I've assigned listeners to through a loop that references an xml table.
//create listeners for all biketrails mc's and designate functionsfunction createListenersbk():void{for(var i:uint=0;i<bktrlXml.row.length();i++){var mc:MovieClip =
[Code].....
I thought I'd be able to replicate the above code and somehow refernce the "idlink" children through the e.curentTarget.
I am designing a game in which the player can travel through doors when they are the same color.There are three doors on stage: "door1","door2" and "door3". Each door is an instance of the same symbol. The symbol contains six frames, 3 copies of the door in a different color and 3 copies of the door in different colors with an icon of the player.. The frames are labeled "color1", "color2" "color3" and also "player1","player2" and "player3".
I am attempting to write code that tells Flash to a)select a door at random and then select a random frame for the randomly selected door to set the game for play. For instance, at startup, Flash randomly selects "door2"and then randomly selects "player2". So, the player's starting position will be on "door2" and the door will be red. After this, Flash will select the other door colors randomly from the frames labelled "color1","color2" or "color3".I am attempting to do this with this code:
var min:Number =1; var max:Number =3; ("door"+String(Math.floor(Math.random()* (max - min) + min) ));
This randomly selects the door.I would like this to randomly select the color of the randomly selected door.
I want to use mutliple images in my flash script and instead of writing tons of code I want to get the 'currentTarget' and assign a variable name to it so I can tweenlite it . Instead of me naming all the instances i thought the following would work but it doesn't.
wedding.addEventListener(MouseEvent.ROLL_OVER, pan_over) ; function pan_over(e:MouseEvent):void{ var ct:string = Event.currentTarget.name ;
The code I am having trouble with is al the way at the bottom (Actions layer on the stage). Below the multi-line comment.Basically, I have a rotating image bar. One the first level of my file, on the stage, is a container movie clip called "imageScroll". The code that allows the images to rotate is applied to the container clip. Inside of "imageScroll", are a series of 36 images, each with their own unique instance name.On the main level, I have a block of code which first detects when the user mouses over imageScroll. Next my code attempts to dig down one level into imageScroll and find the instance name of the image the users mouse is hovering over.
I want to then store that instance name in a string "_destination", then take that string and store it in a MovieClip variable "currentClip". By doing this, I can then use the variable currentClip to effect the code at the bottom, which causes the images to scale up when the user mouses over, and scale back when the user mouses out.The way I currently have my file set up, the code always returns the instance name imageScroll. I am using event.currentTarget.name to try and pull the instance name of the image. I have tried using event.target.name, but that pulls the instance name of a movie clip two levels lower then I want to go.I basically need a way to modify my code so it finds out which movie clip inside of the container imageScroll the user is mousing over.For those who would prefer to have all the code here, see below:
I have a function which triggers a tween for the currentTarget in an array when target is clicked but how can I trigger a tween for everything else in the array??
I'm trying to tween six Movieclip (using TweenLite) in an Array to where they scale up when pressed. When another is pressed it scales up and the others will scale down. I'm having trouble getting them to do this consistently. This is probably a minor fix for most of you, but I have been tackling this for two days.[code]
I'm trying to tween six Movieclip (using TweenLite) in an Array to where they scale up when pressed. When another is pressed it scales up and the others will scale down.I'm having trouble getting them to do this consistently. This is probably a minor fix for most of you, but I have been tackling this for two days.
I've got a problem with an if/else statement within a function which checks to see which 'drop area' one of ten items should to snap to.. the problem is I can only set the start location of each item to work on the first hitTest, otherwise after clicking another item or positioning any item in one of the drop areas, the drop area becomes it's start location due to startDrag() and stopDrag() been called again to move the object..
What I've tried to do here is to create a variable (which does trace the correct (currentTargetHome) movieclip reference, but as a string) but it doesn't work when I try to access it's attributes using [currentTargetHome]. The item exists within the movieclip "gamePage" and the rest of the function works !