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


Similar Posts:


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

Flash :: Get The Specific Array Index Based On Value Inside The Index's Object?

Jun 22, 2011

So, for sending to individual streams we have to reference the connected netStream we want to send to in some way like this:

sendStream.peerStreams[0].send("MyFunction",param1,param2);

and I have to determine which peer I'm sending to by their ID such as "peerID1234"

I know that you can check the peerID of the stream by doing:

sendStream.peerStreams[0]["farID"]

how can I make my send stream function know to use the array index where the peerID is?

so basically it could be like:

sendStream.peerStreams[where peerStreams[]["farID"] == peerID].send("MyFunction",param1,param2);

View 1 Replies

ActionScript 3.0 :: Loading SWFs And Setting Z-index?

Jun 18, 2011

know how to load them using one container. The problem I have is that when a new SWF loads, it covers the main navigation's drop menus from main container. The navigation bar on main container is a movie clip labeled nav_btns.Here is my code, which works when loading SWFs

import flash.display.MovieClip;import flash.display.Loader;import flash.net.URLRequest;import flash.events.Event;
var Xpos:Number=10;var Ypos:Number=115;var swf:MovieClip;var loader:Loader=new Loader();var

[code].....

View 1 Replies

ActionScript 3.0 :: Setting Tab Index On Button Loaded From Library?

Jan 26, 2009

Is there a way to set the tab index on a button loaded (addChild method) from the library? Granted, you can easily add the tab index to the same button if it's on the stage, but I see no way to add it to the button if it's just chilling in the library..

View 5 Replies

ActionScript 3.0 :: Setting Index Of MovieClip - Loading Images?

Mar 31, 2011

I am working on a simple action-script3 slideshow. The thing that I have modified is the movie loads the list in two separate sections. The problem is I want the movie clip to load one image on the right then one image on the left. When the one on the left loads, it loads over top of the right image. I want send the image on the right to be on top again when the left image loads.

Here is my code specific to the images loading:
ActionScript Code:
function nextImage():void{
if(my_times > 0){
var my_image1:Loader = Loader(my_loaders_array[my_playback_counter]);
my_image_slides.addChild(my_image1);
my_image1.x = 26.1
[Code] .....
The idea is, when my_image1 is loaded, I want to have the depth of my_image to be on top.

View 4 Replies

ActionScript 3.0 :: Array, Shuffle A Part Of An Array Using Start And End Index Is Not Working Properly?

Feb 15, 2011

I have used a method to shuffle a part of a Array, but i noticed that it does not work very well.When i run this method I sometimes get empty array values.So if you would try the example below and test it out some times you would get a right result but sometimes a wrong result.For example when i run this i get in my trace output:

a,b,c,d,g,,e,f (here after the g it goes wrong)
a,b,c,f,g,d,e (here it  goes right)
a,b,c,d,,g,f,e (here it goes wrong)[code]...

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

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

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

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.0 :: Setting The Timeline Of A Child

Jun 8, 2009

I made a MovieClip called Stone and I made a StoneBackground child in it. What I want to do is make a grid of the Stone image but everytime with another background I tried this:

stone:Stone = new Stone();
for(var i:int=0; i<2; i++) {
stone.child.gotoAndStop(i);
addChild(stone);
}

But this doesn't work. How can I stop the timeline of the background at different frames for each "stone" ?

View 1 Replies

ActionScript 3.0 :: Setting A Child To Null Perhaps?

Sep 30, 2009

I've having a problem when I am removing a child. There is an area where you can choose a button to click(there are multiple buttons here). Once you click a button it loads workss_mc and you can go back from there and workss_mc is being removed then work_mc is being added again. The problem is once it is added again and you click on any of the other buttons the frame label from the previous session when it was clicked is still at that location.

[Code]....

View 0 Replies

ActionScript 3.0 :: Setting Variable From Child?

Feb 8, 2010

I have loaded a movie clip from the library using the addChild Method. Now, from withing the main timeline of this loaded movie clip I'm trying to set the value of a curScore variable on the stage.

Code:
MovieClip(this.parent).curScore += 10;
Doesn't work...

View 0 Replies

ActionScript 2.0 :: Setting Array Values To Variables In Another Array

Dec 11, 2007

I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated. A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.[code]How would you do this so that var1, var2... are updated properly according to the values found in array2?And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?

View 6 Replies

Way To Get Array Index

Sep 25, 2009

Is there a way to get the index of an array?

For instance, if I have an array:

buttons = Array("abc","def","ghi");

If I wanted to get the index dynamically of the string "ghi", could I do that with a certain function or piece of code?

View 1 Replies

Flash :: Setting Width For Sprite's Child Image?

Aug 9, 2011

I've a slider class (SliderUI) and I'm passing slider and track images to that class as sprites.

What I'm trying to do is, passing one more image as sprite and changing its width for doing masking in slider. (It will expand or collapse as you move volume slider)

When I try to change width of sprite, it doesn't show up and I guess sprite is just container and resizing it makes it disappeared.

So how can I resize sprite with its child image (it's loaded by a Loader object by the way)?

View 1 Replies

AS3 :: Way To Array Index Naming

Mar 11, 2010

I thought that there was a way to be able to name array indexes. Like instead of myArray[0], it could be myArray["tileFour"]. I thought that instead of using index numbers one could use index words.

View 1 Replies

ActionScript 2.0 :: Get The Index Of An Array?

Sep 25, 2009

Is there a way to get the index of an array?

For instance, if I have an array:

buttons = Array("abc","def","ghi");

If I wanted to get the index dynamically of the string "ghi", could I do that with a certain function or piece of code?

View 0 Replies

ActionScript 3.0 :: Getting An Array's Index?

Jan 18, 2011

I have a game map made of tiles, each tile is stored in an array called _tiles.The very each tile has a "plantable" parameter, which determines whether or not something can be placed on it.Then i loop through the array and check the position of each its elements against the mosue cursor, so I know which tile am I hovering with my mouse.

And it works pretty good. The problem is that even though I know what is the position of the tile I'm having the cursor on, I still lack the knowledge of what index is that tile. I simply can't tell where exactly in the array is placed this tile. I just know its position. The reason why I want to know the index of it, is because it's the only way for me to set a proper flag, namely whether it's plantable or not. Here's the code:

ActionScript Code:
for(var j:int = 0; j < _tiles.length; j++)
{

[code]...

View 1 Replies

ActionScript 2.0 :: Way To Specify Index Of Array

May 18, 2005

Is there a way I could specify the index of a array using this short code:[code]How would I go about giving a custom index name instead of it being myArray[0]? I could do it the long way like posted below, but I was wondering the there was a way to shorten this:[code]

View 2 Replies

ActionScript 2.0 :: Go To The Next Index Of The Array?

Jan 18, 2007

i have an array of names that looks like this. var aNames:Array =new Array("jack","mike","Scott")

i have a text field called names which displays index 1 of the array.

and i have a button,when the button is pressed i want it to go to the next index of the array.

View 6 Replies







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