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


Similar Posts:


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 :: 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 :: 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 :: Flash Call Function In One Child Class From Another Child Class?

Dec 1, 2011

I'm trying to call a function in one child class (Circle.as) from another child class (Wedge.as). Circle.as is instantiated by the document class (Tree.as), and Wedge.as is instantiated by Circle.as. How do I do this? This is my code:

Tree.as
package com.treediagram
{
public class Tree extends MovieClip
{

[code]....

How to call a function in a Class from another Class?but it was a bit hard to follow as it relates to my problem. One of the solutions worked, but was commented as being bad form, and another did not work, so I want to make sure I structure my code properly.

View 3 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 :: Can't Swap Child For New Class Instance IF Child Is Exported For Action Script?

Aug 18, 2010

I have a movieClip with one frame on the timeline containing one child whose instance name is "myContent"I am using this function to swap "myContent" with any number of possible class instances.

Code:
function setContentAsClass(c:Class)
{

[code].....

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

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

ActionScript 3.0 :: Removing Child And Setting It To Null Completely Remove Object?

Jan 24, 2010

In document class action script file I add a movie clip to stage using

Code:
public var square:Square
square = new Square
addChild(square)

So it adds square to stage.Then after sometime I want it to be removed. I call a function "removeSquare" also located in document class. It executes the following code. And it removes the square from stage visualy.

Code:
trace("proff that it's executed")
removeChild(square)
square = null

Then of course I want to add a square to stage again, using code I written at top of the post. And remove it again, and so on..But game is lagging more and more and more. So I guess that the square is not properly removed. If you need more details about my code feel free to say, I just written that since I really doesn't know what else should be important.

View 9 Replies

Actionscript 3 :: Update Xml Document's Child Regardless Of It's "vertical Index" / Depth In It?

Dec 23, 2009

I'm in a situation where I have a xml document which is going to be updated in the following way: The deepest child within the document which surrounds a certain x,y position (depending on it's x, y, width and height attributes) is going to get a new child element. If multiple childs exist with the same depth, the bottom one is updated.

My first step was to find this deepest child, this already caused problems, but I managed to solve this with the following recursion[code]...

View 2 Replies

ActionScript 3.0 :: Change The Z-index From Document Class?

Feb 23, 2011

I have a symbol of text with instance name "test_" on the main timeline and some graphics that are loaded programmatically. When the graphics are loaded onto the stage, it covers up the "test_" so that only part of it is visible. How do I change the depth of the "test_" symbol so that it is on top of all the graphics on the stage?

I tried this setChildIndex(test_,numChildren-1); however numChildren is equal to one so apparently it is already on top of its container. I need "test_" to be above all graphics that were loaded onto the stage instead.

View 1 Replies

ActionScript 3.0 :: Get Index Of Object Which Is Instance Of A Class

May 24, 2011

I am trying to get the index of an object which is an instance of a class. I need to get the index from within the class.So I have an instance of a class. When its clicked I need to get the index. I dont really know how to write this. I tried a few things like:[code]

View 4 Replies

ActionScript 3.0 :: Moving A Child From A Class To A Holder Sprite Inside That Class?

Feb 12, 2009

i have a BasicMap.as that takes an Array and populates itself with the MC objects passed to it by a String reference.it inherits from Sprite, and so it just places the objects on its self.then i have a class that inherits from that class, and gives a little more functionality to it, but in order for it to do that, it needs to place the objects not on itself, but instead inside a holder Sprite, so here is my problem:

code:
package Mushroom{
import flash.display.Sprite;

[code]......

View 8 Replies

Actionscript 3 :: Dispatching Events From Parent Class To Child Class

Apr 30, 2010

I think this is a pretty simply problem but I do not seem to be able to pull it off. Basically I have a parent class A, and a child class B.Class A instantiates class B with addChild.There is a shared object which is being updated from a java server (red5) that has an event listener attached to it in class A.I have a function in class A which will pass certain, specific updates from this shared object to class B.The problem occurs is that when class B is instantiated, the event listener from class A doesn't work anymore. I have not removed the event listener from A.?

View 1 Replies

ActionScript 3.0 :: Call Parent Class Function From Child Class?

Nov 25, 2010

Lets say I have a Main Document Class called Main. I also have a child class called childClass that call a function from the Main class and is also imported in the Main class. How should I call the function? I tried this , but when calling the function, it's getting me error.

Main class :

Code:
package {
import flash.display.Sprite;
import com.childClass;

[Code].....

View 6 Replies

ActionScript 3.0 :: Class.CONSTANT As Index When Instantiating Array?

Aug 3, 2010

Is there a way to declare and instantiate an array using constants as indexes? I want to do something like:

public var arr:Array = new Array([ CONSTANT_A : "helloWorld", CONSTANT_B : "helloGoodbye" ]);

In php one could do:

$arr = array(CONSTANT_A => "foo", CONSTANT_B => "bar");

View 9 Replies







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