ActionScript 3.0 :: GetChildByName() With Loop?

Oct 28, 2008

I'm trying to use XML to load in 4 images to a movieclip within a movieclip that is already created on the stage. I'm trying to do this in a loop since there are 4 movie clips I'm trying to access. I can get it working without the loop, but it's figuring out the syntax that's causing the problem. Currently I have the following code:

function ParsePics(picsInput:XML):void {
var picsList:XMLList = picsInput.pic.image;
for (var i:int = 0; i < picsList.length(); i++) {[code]..............

View 4 Replies


Similar Posts:


Actionscript 3.0 :: Access Multiple Movie Clips With Loop And GetChildByName?

Nov 3, 2010

All i really want to do is be able to affect multiple movieclips at once with event listeners and greensock tweens.

The first snag I hit was that I couldn't create references to movie clips using the old [] Associative array referencing method. Maybe I still can with AS3, but I couldn't get it to work...

So I found another technique using getChildByName that returns a reference to a movie clips and allows me to store that reference in a variable.

However, the movie clip I'm trying to affect with an event listener resides inside of another movie clips, so to build the address (aka, root.mc1.m2.mc3) to the mc I want to get to is proving to be difficult. (I'm very new to AS3...)

I thought the trace(target1_mc.target2_mc.name); at the bottom of the following code would output the name of target2_mc but it doesn't.[code]...

View 2 Replies

ActionScript 3.0 :: Accessing Multiple Movie Clips With Loop And GetChildByName

Nov 3, 2010

All i really want to do is be able to affect multiple movieclips at once with event listeners and greensock tweens.The first snag I hit was that I couldn't create references to movie clips using the old [] Associative array referencing method. Maybe I still can with AS3, but I couldn't get it to work..So I found another technique using getChildByName that returns a reference to a movie clips and allows me to store that reference in a variable.However, the movie clip I'm trying to affect with an event listener resides inside of another movie clips, so to build the address (aka, root.mc1.m2.mc3) to the mc I want to get to is proving to be difficult. (I'm very new to AS3...)I thought the trace(target1_mc.target2_mc.name); at the bottom of the following code would output the name of target2_mc but it doesn't...[code]

View 2 Replies

ActionScript 3.0 :: Flash For Loop + Getchildbyname - Trace What Button Is Clicked

May 20, 2011

I have made 30 movieclips for my level selection screen. Then I create a movieclip with the same name using a for loop. With that code I make roll_over function showing a Tooltip. I then want to trace what button is being clicked. My whole code is here: [URL] I want to trace what button is clicked, so I can show it on my tooltip textbox.

View 4 Replies

ActionScript 3.0 :: GetChildByName Mc Inside Mc

Feb 28, 2009

I'm trying to declare a movieclip variable in a class by finding the instance name of the movieclip.

On my stage I have a 'Container' (linkage class name) MC, inside that is a 'PlayerInfo' (linkage class name) MC inside that is a 'healthBar_mc' (instance name) MC. healthBar_mc is what I'm trying to access.

the class where I'm trying to run this function is linked to a MC inside 'Container'

So I tried the following code:

[Code]....

View 11 Replies

ActionScript 3.0 :: Cannot Set Property After Using GetChildByName?

May 2, 2009

I am adding a MovieClip to the container with the following code

ldr = new MovieClip();
ldr.graphics.beginFill(0xf0f0f0);  l
dr.graphics.drawRect(xPos,yPos,IMAGE_WIDTH,0);
 
[code]......

View 5 Replies

Flash :: Getting Instances Besides GetChildByName()?

Jul 7, 2010

I have many MovieClips and each has a name like "mcDummyClosed" and then and instance name "slideDummyClosed". Another MovieClip has a link to e.g. slideDummyClosed which I then call DummyClosed. I add a MouseEvent.CLICK event to DummyClosed.

Now without adding slideDummyClosed to the stage nor any other MovieClip can I with a string containing it's name get that instance? I've tried using getChildByName() but that only seems to work if I've already added the MC to be found and added before. My code looks something like this:

[Code]...

View 2 Replies

ActionScript 3.0 :: GetChildByName Functionality For XML?

Sep 7, 2011

I am not sure if this is even possible so this is why I am asking. So you know how we can access a nested movie clip by name with the following code:

mainMC.getChildByName("nameOfMC");

I was wondering if it is possible to do the same thing with XML data. So for exaple:

xmlData.house would be mainMC.getChildByName("house");

(obviously I know that getChildByName doesn't work for XML and am looking for an equivalent command)

View 2 Replies

ActionScript 3.0 :: Changing Text With GetChildByName?

Jul 1, 2009

ok so im trying to change a dynamic txt in each button but i started with this one and i keep getting this error.

1087: Syntax error: extra characters found after end of program.

what is added or needs to be added? ive gone over the code several times and cant figure it out.

ActionScript Code:
var btnNum:uint = 7;
var spacing:Number = 0;

[Code].....

View 5 Replies

ActionScript 3.0 :: Accessing Methods And Properties Via GetChildByName

Dec 2, 2007

I seem to be having a bit of a problem here. I'm generating a load of class instances using the following code:

maxpersons=25;
for (var i:Number=1;i<=maxpersons;i++)
{
var person:Person = new Person;

[Code].....

OK. I then need to run through each of them and check for a collision with an object from the main stage (called redDot), which I pass to a method (called doDamage) within the class. I'm using the following code:

for (i=1;i<=maxpersons;i++)
{
if (game.getChildByName("person"+i).hitTestObject(red Dot))
{
game.getChildByName("person"+i).doDamage(redDot);
}
}

I keep getting an error saying "1061: Call to a possibly undefined method doDamage through a reference with static type flash.displayisplayObject."!

It just won't work. I've tried altering the code to:

game["person"+i].doDamage(redDot);

but I get an unexpected trace output saying "TypeError: Error #1010: A term is undefined and has no properties."

View 6 Replies

ActionScript 3.0 :: Call Variable By Name Similar To GetChildByName?

Feb 23, 2011

I have a several functions that I can compact into 1 function via a for loop if only I can find a way to call the variable by name.

For example:This is what I want to accomplish: (However I do not have the slightest clue as to how to go about doing the below...)

ActionScript Code:
var test1:String = "testing 1";
var test2:String = "testing 2";

[code].....

I am able to do something similar to the above when using objects using methods such as: (I know not efficient, but its just an example to show what I am trying to accomplish.)

ActionScript Code:
var test1:String = "testing 1";
var test2:String = "testing 2";

[code].....

View 7 Replies

ActionScript 3.0 :: GotoAndStop Doesn't Work With The GetChildByName?

Jul 22, 2009

I have this line on my code:

nav_mc.getChildByName("go" + i + "_mc").alpha = 0; // this works fine

but then if I add this:

nav_mc.getChildByName("go" + i + "_mc").gotoAndStop(2); // Doesn't work
nav_mc.go1_mc.gotoAndStop(2); // Works

nav_mv is a MC on stage, it's child is another mc whit 2 frames in use.why the gotoAndStop doesn't work with the getChildByName?this is the error I'm getting: 1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display: DisplayObject.

View 2 Replies

ActionScript 3.0 :: Error #1006: GetChildByName Is Not A Function?

Mar 11, 2012

I'm trying to use the getChildByName function and for some reason it's not working. Here's the line that is causing the error of "TypeError: Error #1006: getChildByName is not a function."

PHP Code:

var contactBox:MovieClip = anyBox.getChildByName("earthBox" + i); 

It is in a for loop and is definitely calling to a movieclip of the correct name in the MC array anyBox. I've searched the internet and haven't found anything (On the first page of google...)

View 5 Replies

Referencing Symbol On Stage - GetChildByName Returning Null

Sep 8, 2010

I have just recently started playing around with AS3 and am pretty new to what is going on in Flash (though I do have a lot of programming experience.) I have an object that I am dragging around on the mouse. I want it to be destroyed if I drop it anywhere but in a target location. I have the part where it is destroyed working, but I am running into a problem trying to find the target. When I try the following...

PHP Code:
public function DropObject(){
if (! this.hitTestObject(stage.getChildByName("Target"))){
stage.removeChild(droppedObject);
stage.removeEventListener(MouseEvent.MOUSE_MOVE,droppedObject.MouseCursorMove);
}}

I get "TypeError: Error #2007: Parameter hitTestObject must be non-null." So, "getChildByName" is returning null, but I'm not sure why. I've verified that there is an Instance name of the Target on the stage. Why can't I find it?

View 4 Replies

ActionScript 3.0 :: Get UIComponent By Id Or Name, The GetChildByName Does Not Return Childrent Of Children

Sep 23, 2009

My application will load an xml file that has the name or id of a UIComponent. Later this will be used to set text or images.
 
This component could be on a panel or a panel in a panel, I am not familiar with flex but in javascript getElementByid would return the element wherever it is on the document (when called on the document). There is no get....Byid in fex and getChildByName does not look in children.For example

<mx:Text name="works" id="works"></mx:Text>    <mx:Panel>        <mx:Panel>            <mx:Text id="noWorkie" name="noWorkie" text="a test"></mx:Text>        </mx:Panel>    </mx:Panel>
this.getChildByName("works"); // worksstage.getChildByName("works"); // returns nullthis.getChildByName("noWorkie"); // returns null
  
Thinking of creating a getElementByid but has to be called from the top element, have no idea what the top element is.
For example this.root does not have a getChildren method to go through nor does stage. Guess I need to find the highest possible Container class starting with this.parent.There must be a "simple" way to do this but all examples I could find would not go from top level to lowest child as javascript would do in document.getElemetByid.

View 7 Replies

ActionScript 3 :: Calling Children Inside MC - GetChildByName / GetChild At?

Jul 20, 2010

I found out that I can't target a object inside the main MC if I use getChildAt / getChildByName. It will return me
Error #1119: Access of possibly undefined property someProperty through a reference with static type flash.display:DisplayObject.

I was trying to use something like
this.getChildAt(0).getChildByName("objectName")....

View 1 Replies

ActionScript 3.0 :: Converting GetChildByName() Acquired Object To Other Class?

Feb 17, 2009

I've been wondering if it is possible to convert an object acquiredby a getChildByName() function to another class?Let's say i have a library item designated as MovieClip and it is a part of some "sprite sheet". Now, when i need some sprites for my program i create a new sprite sheet instance and then i take sprites from it using the getChildByName():

Code:
sourceSheet = new UISpriteSheet();
someObject = sourceSheet.getChildByName("someObject");

[code]......

View 6 Replies

ActionScript 3.0 :: Setting Properties Of Objects Found Using GetChildByName

Mar 9, 2009

I am attempting to set the propreties of a navigation button (movie clip) that has been built dynamically. The button contains a text field that I want to format and a movie clip that I want to adjust the alpha. I find the object using getChildByName(), however do not seem to be able to set the properties using the code below.[code]

View 2 Replies

ActionScript 3.0 :: GetChildByName Return Null If Public Setting Is Flash 9

Jan 18, 2011

I am facing a weird problem. The following code returns null if targeted player is Flash player 9 but works fine for Flash Player 10.

[Code]...

It works fine if I give a delay using setTimeout. I am not sure what I may be doing wrong. I have attached the source files. (Flash CS5 format)

View 5 Replies

ActionScript 3.0 :: Accessing Property Of A Custom Component Through The GetChildByName Method

Jul 23, 2010

I have written a piece of code where I have created a custom class containing some of my custom properties.I have used multiple instances of this custom class in my main class and added it to a container.Now I need to access one of my custom property in the main class through container.getChildByName()."custom property", but I am not able to access my custom property using this.I get an error saying
Access of possibly undefined property orientation(this is my custom property) through a reference with static type ..name of my main class.

Is there no way that can i access custom property of components through the getchildbyname method of the parent container ??

View 0 Replies

ActionScript 3.0 :: GetChildByName() Not Working - Delete The Existing Load Different Heads And Bodies

Jan 5, 2010

I have a movie that loads a head and a body onto the stage. I want to send it a command to delete the existing load different heads and bodies. Heres what I have and in theory would like to do:

[Code]...

View 3 Replies

ActionScript 3.0 :: RemoveChild(getChildByName("whatEverName1"))?

Oct 8, 2008

Look over the following code, look for the 'thumb.name =

"thumb" + i; // here' line;

function xmlLoaded (e:Event):void {

xml = XML(e.target.data);
images = xml.image;
for(var i:uint=0; i<images.length();i++){[code].........

View 3 Replies

ActionScript 3.0 :: GetChildByName("picMc"+(nIndex-1))

Jun 10, 2009

How do you write this so that it works?... i think it is a problem becuase when you minus 1 from nIndex it thinks that it is a number and thereofre not part of a string /name..nIndex is set as datatype number but getChildByName("picMc"+nIndex) works fine it is only when i try and minus 1 from it that it doesnt work.. cheers to any responders J.

View 3 Replies

Actionscript 3 :: Adding Child With "getChildByName"?

Dec 3, 2010

I have a variable as following:

private var fotoSlide:FotoSlide;

and i am doing the following inside my code:

var data:Object = _dataProvider[0];
trace(data.type);//This gives back the string Foto
var slide:Sprite = new (getChildByName(data.type+"Slide"));
addChild(slide);

So if i'm declaring my variable with getChildByName the result should be FotoSlide.
But it doesnt seem to work. I think it has to do because getChildByName can only be used when a child is added to the stage?

View 3 Replies

ActionScript 3.0 :: RemoveChild(getChildByName("backButton"))?

Sep 14, 2010

Code:
var backButton:BtnSMenu = new BtnSMenu();
backButton.name = "backButton";

[code]....

View 5 Replies

ActionScript 3.0 :: Create A Loop So Icons In Menu Continually Loop Indefinitely

Apr 16, 2010

I would like to create a loop so the icons in the menu continually loop indefinitly.[code]

View 2 Replies

ActionScript 3.0 :: Use A Loop To Create Text Field With The Loop's Current Value

Dec 11, 2010

I am attempting to use a loop to create text field with the loop's current value. The code looks like this:

ActionScript Code:
for (var i = 1; i<=10; i++) {
var 'nameHolder'+[i]+'_txt':TLFTextField = new TLFTextField();
'nameHolder'+[i]+'_txt'.x = 40
'nameHolder'+[i]+'_txt'.y = 40
'nameHolder'+[i]+'_txt'.text = "Hello World"
}

So essentially what it should do is create 10 text fields at 40, 40 with the text: "Hello World".

View 7 Replies

ActionScript 2.0 :: Infinate Loop For M.clip.the Looping Part Does Not Want To Loop?

Jun 13, 2004

i'm trying to do an infinate loop for my m.clip.the looping part does not want to loop...it loops back to my firrst frame even though there are two same picture in the movie clip.....here's a sample of what i use for the infinate loop script..

[Code]...

View 2 Replies

ActionScript 3.0 :: Loop With Varying Values Depending On Where Are In The Loop?

Jul 20, 2009

I have need of loops / nested loops that pick different figures depending on where you are in the loop. The whole function needs to run through 'ml' times. 'ml' is a dynamic figure. Loop 1 = While the loop is within the first 12 iterations, 'exconemp' must equal 100. For iterations 13 - 24, 'exconemp' must equal 102.5, for 25 - 36 it will be 105.06, for 37 - 48 it will be 107.69. This needs to change every 12th iteration until it has reached 'ml'. The calculation takes the value of the previous 'exconemp' and then multiplies that by 0.025.

Loop 2 = While the loop is within the first 120 iterations, 'abc' must equal 0.015 and any further iterations must use 0.01. This must also work in a way to figure out whether 'ml' is higher or lower than 120 and work accordingly. My main issue is this - how do I get the loops to run through as this: While the iteration is < 12, do this, THEN take the final figure (12th iteration) and start on 13 - 24, do this THEN etc etc. How do I produce a THEN statement? I can get the code to pick up the final values, but not change along the way.

[Code]...

View 6 Replies

ActionScript 3.0 :: Accessing Loop Variables Outwith Loop

May 5, 2011

Say, I had a loop in a function...

[Code]....

How would I refer to a in another function

View 8 Replies







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