ActionScript 3.0 :: How To Trace Child Index Number

Mar 5, 2012

I want to know the index number of the object when I clicked it..
trace(mc.getChildAt(0)) = display the object at the index 0 lets say the output is [object] button
Now I want to reverse it. When I click the object button
button.addEventListener(MouseEvent.CLICK, onClick)
function onClick(e:MouseEvent){
trace(e.currentTarget.????????)
//I want to trace what index number is that button, the output should be "0"
}

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Trace Child Index Number?

Mar 5, 2012

I want to know the index number of the object when I clicked it..

trace(mc.getChildAt(0)) = display the object at the index 0 lets say the output is [object] button

now I want to reverse it..

when i click the object button

button.addEventListener(MouseEvent.CLICK, onClick)
function onClick(e:MouseEvent)
{

[Code]....

View 1 Replies

ActionScript 3.0 :: Trace The Index Number Of The Array?

Jun 29, 2009

The Action script code below takes the strings in the array (pgtit) and creates a dynamic navigation bar I am trying to trace the index number of the array being click I just seem to get -1.

var pgtit:Array=["link1","link2","link3","link4"];
var xPos = 0;
var menuHolder:MovieClip = new MovieClip;
addChild(menuHolder);

[code]....

View 2 Replies

Actionscript 3 :: After Shuffling Array - Variable = Array[index] Gives 0, Trace(array[index]) Gives Correct Number

Aug 16, 2011

I think it would be simplest to explain it like this:

[Code]...

View 1 Replies

ActionScript 3.0 :: Can't Trace An Index Of Array

Mar 22, 2012

I copied some code over to a similar function, which traces out the array index number using indexof(e.target).For some reason I'm getting the usual undefined property errors, but it is tracing other properties in the array using e.target?[code]

View 9 Replies

ActionScript 3.0 :: Having One Image Below Another Using Child Index

Jan 26, 2010

I'm not too familiar with how I can use the getChildIndex() along with an if statement in a mouse_move event to make sure one image is always above the other or one is always on the bottom

View 4 Replies

ActionScript 3.0 :: Add A Child Of Index 2 Or Higher?

Mar 3, 2010

I'm working on a project conversion from AS2 to AS3.
 
In AS2, I used a mainMenu file and loaded a Navigation file at _level 999 (very top). Then I loaded and unloaded different modules on _level 5.I also loaded and unloaded an external Glossary file on _level 95.Now in AS3 I am using AddChildAt(1) for the Naviation file and AddChildAt(.1) and removeChildAt(.1) for the module files. The Glossary file only seems to work at Child Index 1, so I'm guessing it pushes the Navigation file to a higher index. Is there a reference that explains the Index properties of the Child and why sometimes I get an error when I try to add a Child of Index 2 or higher?

View 3 Replies

ActionScript 3.0 :: Won't Let Reset Child Index?

Jul 15, 2010

I've got multiple images being loaded from an xml document and when they're created they add it to the stage and call a setIndex function to set it to 0. But when I try to the same object later on when they're called I get this compiler error:
 
I marked in bold the lines that relate. Out of the last two lines I marked bold I get this compiler error when I use the first one: 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:Sprite.
 
and this output error when from the last bold line: TypeError: Error #2007: Parameter child must be non-null.

[Code]...

View 2 Replies

ActionScript 3.0 :: Access Child At Top Index?

Dec 13, 2011

I am adding movieclips (myBall) to the stage by the click of a button. There is a base class applied to myBall which allows it (and its children) to be dragged and dropped. Within the base class on mouse down, along with startDrag, the movieclip is being brought to the top index. I would like to be able to refer to this movieclip in my document class. The point of doing this would be to apply a function to the last clicked movieclip (finding what movieclip was last clicked would happen by applying the function to the movieclip (myBall) with the highest index).[code]...

View 7 Replies

Flash :: Can't Trace Child Of A Sprite

Apr 1, 2011

I don't understand about the qualities of a sprite, but why does this trace as undefined? item is a movie clip and businessCard is a sprite which contains a movie clip.[code]

View 3 Replies

ActionScript 3.0 :: Trace The X Value Of A Child Of Snap_container?

Jul 18, 2009

How would I trace the x value of a child of Snap_container. I don't understand why this doesn't work.

Code:

var Snap_container:Sprite = new Sprite();
this.addChild(Snap_container);
var Snap_point:Sprite;

[Code]....

I get : 1118: Implicit coercion of a value with static type flash.displayisplayObject to a possibly unrelated type flash.display:Sprite.

View 1 Replies

ActionScript 3.0 :: Setting Child Index In A Class?

Sep 26, 2009

Im trying to build a class that moves around some movieclips on the stage, but it would never be that easy would it!

Code:
package {
import flash.display.MovieClip;
public class Rotation extends MovieClip {

[Code]...

So I waddled it down to the "stage.addChildAt(mcContainer[i], i);" bit and I've tried everything that I could think of, but nothing seems to work.

With this version of the code, I would get "The supplied index is out of bounds." error, I can change it to addChildAt etc, but that just gives me a different error.

I had this working when it was in a flash file, its converting it into a usable class thats bugging me. All the MovieClips in the array are being exported for Actionscript.

View 2 Replies

ActionScript 3.0 :: Setting Child Index From Within Array?

Sep 14, 2010

Here's what I'm trying to accomplish: I have as3 script that successfully displays an array of MovieClips, the MCs have variable xy positions, and in some cases they overlap each other. I have a function within the array that I can't quite figure out. Here's what I'd like the function to do: When the cursor rolls over a particular MC displayed by the array,I'd like that MC to be brought to the front of the others. This is my script:
 
var myArray:Array = new Array(); for(var i:int=0; i<8; i++) { myArray[i]= new myImage();addChild(myArray[i]);myArray[i].x = 180*i;myArray[i].y = 330;myArray[i].addEventListener(MouseEvent.ROLL_OVER , overlap);
function overlap (event:MouseEvent):void
{trace('function triggered on image ' + i);

[Code]...

View 3 Replies

ActionScript 3.0 :: Trying To Swap Child Index On Click

Feb 20, 2009

I have 3 objects (mask_cat, mask_dog, mask_sea_monster)on the stage and I want the user to be able to move them independently with the ol' click and drag.[code]So far only the, sea_ monster moves. The odd thing is the sea_monster moves when I click on the dog or the cat also, but not if I click anywhere else.

View 0 Replies

ActionScript 3.0 :: Change Child Index And Alpha?

May 16, 2010

I have 10 movie clips on the stage all of them are on the same layer and the alpha property at 0.5.

I want a single movie clip to randomly move to the top of the other at timed intervals. This movie clip alpha property will change to 1 while the other movie clip will remain at 0.5

View 5 Replies

Flash :: Trace Color Value As Hex Number?

Dec 17, 2010

Actionscript: how to output color value in format like "#FF00FF00"

So I use such code to generate colors ond simply trace tham. How to trace tham in Hex format?[code]...

View 2 Replies

ActionScript 3.0 :: Tracing An Index Number From An Array?

Jun 27, 2009

I am trying to trace an index number from an array.

I know this must be about as simple as it gets, but I just cant figure it out.

I know the contents of the array are all asighned a number begining with 0.

I need to find out the index number of a thumbnail when you click on it.

Code:
function whenThumbsLoad(event:Event):void{
var thisThumbsLink:String = clipPathList[ c ];
var thisThumbsTitle:String = clipTitleList[ c ];

[Code].....

I know I can trace the thisThumbsLink and get that, but all I need is it's index number. Also I trace(c); and I get how many there are, but I just don't know what to trace to find the index number.

View 12 Replies

ActionScript 3.0 :: Get The Array Index Number Which Currently Accessing?

Nov 2, 2009

i used a for loop to addChild of a class object(movieclip) to the stage and at the end line of for loop after addChild i push it into an array and i add eventlistener to it , such as
 
for (var i:Number = 0; i < 9; i++) {
.....
clip = new CLIP;
......

[Code]....
 
and if i want to get the array number which currently accessing how can i do that ? for example, i drag one of the mc class from the array which has already added eventlistener above.
 
how can i get the number of the array which im accessing ? evt.target..... etc ?

View 4 Replies

ActionScript 3.0 :: Cannot Get The Index Number From A StartDrag Function?

Jun 13, 2011

//*//*//*//*//**//**/**//**//**//**//**//**//**//**//**//**//**//
var t:Array=new Array();t=[d1,d2,d3,d4,d5];
var d:Array=new Array();d=[t1,t2,t3,t4,t5];

[code].....

View 6 Replies

ActionScript 2.0 :: Get Index Of The Smallest Number In The Array?

Nov 1, 2003

I have a Array. I dont know how large the array is. How can I get index of the smallest number in the array? I know array contains only numbers.

View 5 Replies

ActionScript 3.0 :: Child - Parent - Index Level Setting?

Jul 2, 2009

I encountered and did not make heads or tails out of this whole new concept of child, parent and setting a index level. What is an index level and this 'child and parent' thing?

View 3 Replies

ActionScript 3.0 :: Change The Number Of Xml Elements Trace

Oct 27, 2011

Simple question i can trace all elements from xml but how to trace 5 or 15 or any number (that you enter to input text field) of random elements from xml file

View 2 Replies

ActionScript 2.0 :: Flash8 Retrieve Index-number Of A Value In An Array?

Apr 30, 2009

For instance:

PHP Code:

my_Array = new Array();
my_Array.push("one", "two", "three", "four")

Here's the catch: another variable (for instance) called "three" is loaded. I want to look up "three" in my_Array and retrieve the index-number (should be 2 of course). How can I accomplish that?

View 2 Replies

ActionScript 1/2 :: Set A ComboBox Instance To A Certain Value (without Knowing Index Number)?

May 17, 2010

I have a ComboBox, with it prepopulated with the States.When I have a variable that says it should be pre-selected to for example CA, how do I do that, without haveing to figure out the index number for every single state?

View 3 Replies

ActionScript 3.0 :: Array Elements Knowing Their Index Number ?

Jul 8, 2011

Say you have a class Parent, which has a property childArray:Array. In this array, we will register several instances of the class Child. Is there an easy way for a child to know which position in the array it currently has? I know I could just pass the index number into the child as I register them, but if a child were to be deleted from the array, all children past the deleted childs index would need to have their indexes updatedl. While this is of course not a huge task, I just have this feeling it should be a better and more dynamic solution.

View 6 Replies

ActionScript 2.0 :: Checking Index Number Of An Item In An Array?

Aug 2, 2007

I have this Array

Code:
var shoprubriken:Array = new Array();
shoprubriken[0] = "43";
shoprubriken[1] = "44";

[Code]....

Now I wanted to check on which Index Position maybe the 47 is

How can I archive this on a Button or Function?

View 5 Replies

Arrays :: Changing Child Index Of MovieClips Based On Their Y Position?

Mar 1, 2012

I'm writing a game with Flash CS5/AS 3.0 that tries to simulate depth of field by drawing all the relevant Movie Clips based on their Y position in ascending order, i.e. things lower on the stage overlap things higher on the stage. A MovieClip with a Y position of 10 would therefore need to have a lower index compared to a MovieClip with a Y position of 20, so the second one gets drawn on top of the first.

I wrote a quick and dirty function just to test this. During the trace, I've noticed that the truck's index hits 0 when I go near the top of the stage, but if I go too far up it will completely disappear from the stage. Trace then starts generating this error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at EICT::Game/ReorganizeDisplayIndexes()

[Code].....

View 2 Replies

ActionScript 3.0 :: Tween Child Display Object Index Getting Screwed Up?

May 1, 2009

I have a set of buttons which trigger menu panels to tween up from below the screen. I want these menu panels to be displayed behind the buttons (which are displayed on the button edge of the screen). So I add the menus to the parent container, then I add the buttons, so that the menus would be behind the buttons and getChildIndex(buttons) = 1 and getChildIndex(menus) = 0.

The menus are correctly displayed behind the buttons when I comment out the tween code. But when I implement the tweens and start the tween of the menus, they do their motion tween but are displayed in front of the buttons instead of behind; somehow their display object index order got screwed up.from the Menu class:

Code:
this.tweenIn = new Tween(this, "y", Regular.easeOut, stageHeight, stageHeight - this.height, 2, true);
this.tweenOut = new Tween(this, "y", Regular.easeOut, stageHeight - this.height, stageHeight, 2, true);[code].....

View 9 Replies

Actionscript 3 :: Trace Returns A Blank Function Rather Than A Number?

Aug 16, 2011

I have a simple code that seems to be giving strange results.

var startPoint:Point = new Point(x, y); // a point
var r:Number = path[i].row + (-Math.floor((length * 2 + 2) / 2)); // just some math
trace(r); // the math checks out and gives a 3
var tey = startPoint.y + r; //this gives a really strange return....

[Code].....

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







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