ActionScript 3.0 :: Get Incrementing Instance Name To Work With .addChild?

Jul 1, 2010

i have a set of images with incrementing names image1, image2, image3 etc and i have a series of empty movie clips on the stage also with incrementing names mc1, mc2, mc3, etc

i wanted to use this:

mc_empty.addChild(my_loader);

to display a series of images into the series of movieclips on stage my_loader is an incrementing variable, and that works fine with the .addChild however, when specifying what addChild is loading content into, it doesnt seem to favour variables as names, it only seems to like real instance names thought i could use

getChildByName("mc_empty"+num)
like this:
getChildByName("mc_empty"+num).addChild(my_loader) ;

but that doesnt seem to work with .addChild either

View 7 Replies


Similar Posts:


ActionScript 3.0 :: Incrementing X Propety By 0.01 Does Not Work

Oct 3, 2009

Just having problems with incrementing the x property of an object by 0.01 using a timer.It works with 0.1, but does not seem to work with the value 0.01 (commented code).[code]

View 3 Replies

ActionScript 3.0 :: AddChild By Instance Name?

Feb 9, 2010

I am trying to addChild to Movie Clip by its instance name but can't do it.

Here is what I get when I trace my loader.name

MC_0
MC_1
MC_2
MC_3

Now I want to add a child to MC_2 but can't do it.

I tried

this[MC_2].addChild(player)
MC_2.addChild(player)
InfoMcHolder_mc[MC_2].addChild(player)

[Code]....

View 6 Replies

ActionScript 3.0 :: AddChild To Stage Instance From Static Class?

Nov 4, 2011

I need to know when an element is added to the stage (using main document class). So i use :

Code:
public override function addChild(__child:DisplayObject):DisplayObject{
super.addChild(__child);
trace("child added");
return __child;
}

Which works fine. I also use a static class, to which i pass the stage using :

Code:
public static function setStage(__stage:Stage):void{
_stage = __stage;
}

But if i add to the stage (_stage) a MovieClip from the static class, my "real" stage doesn't seem to get that something was added. So i guess _stage !== stage.
So why is this happening, why is _stage not getting the methods of stage ?

View 1 Replies

Actionscript 3.0 :: AddChild Dont Work?

Feb 21, 2010

I'm trying to use addChild in a for loop to add lots of copies of one mc, but they are not appearing on the stage.

[Code]...

View 3 Replies

ActionScript 3.0 :: AddChild() Does Not Work Inside Package{}

Sep 24, 2009

My Question: AddChild() in Main class work as expected, but not in GoBall class. (Main class refers to GoBall: var go = new GoBall()

[Code]...

View 2 Replies

ActionScript 3.0 :: Dynamic AddChild With Loop Wont Work?

Jan 7, 2011

I cant get addChild to work withing a loop (while).

I have a range of movie clips in the frame hidden away. These are called item_1, item_2, item_3 etc.

It works FINE when Im adding say item_1, then item_2, but if the code tries to add "item_1" twice, it seems to just overwrite the first new "item_1"!?!

This is what I need to do, and it just wont work!

ActionScript Code:
while(i<10){
this["item_new_"+i] =new MovieClip();
this["item_1"].y = 0;//I put this in just to make sure they line up right

[Code].....

View 8 Replies

ActionScript 3.0 :: Flash AddChild Does Not Work Inside Package

May 13, 2011

I would like to create a class displaying a button:
Code:
package {
import flash.display.Sprite;
import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.text.TextField;
[Code] .....

But when I call this from my fla file:
Code:
import AutoHideButton;
var button:AutoHideButton = new AutoHideButton();
no errors are given but nothing is displayed (the same code pasted directly into the timeline works).

View 2 Replies

ActionScript 2.0 :: Multiple Instance Names Don't Work?

Nov 2, 2009

I am trying to make a game where I am going to have different "Tiles" for each type of terrain. in my code I am calling on "Tile_GOLD" like this for a hit test:

[Code]...

and so my problem is that Multiple instance names don't really work, so I tried exporting for actionscript and that didn't really help either. So is there a way that I can call the tile in the characters code or is there a way that I can determine the hittest in the tile? Not necessarily for all of them to go to the next frame but to maybe have them make the character not be able to move. Also if anyone could give me a hittest code for making a mc not be able to go through an object

View 0 Replies

Professional :: Instance Name Not Work - Create A Symbol Dynamically?

Mar 16, 2012

This is a very basic question.  I'm rather new.  Just wondering how one creates and manipulates dynamic objects, when they were designed in the library- not dynamically.
 
I want to make symbols in the library (linked to classes) and then dynamically create them and manipulate them in the actionscript code.  But when I create them in the code, any instance names of sub-symbols cannot be referenced...
 
The instance name is "instance244" and not "leaf_text" which I set under [properties>instance name]

View 5 Replies

ActionScript 2.0 :: Same Instance Name Makes Code Only Work For One Object?

Apr 17, 2010

I happen to have this real massive code for an object in my game.(please guys dont move this to the game section the problem has hardly anything to do with that) One of them is a propane tank, the other a box and the third is a barrel.(it doesnt really make much diff i just want you guys to get a better picture of whats going on)So inside of each movieclip i put in this MASSIVE code.

ActionScript Code:
onClipEvent(load) {
var right:Boolean = true;
}

[code]....

it works fine but when i put in an instance name the whole thing messes up.only one of them works and all the others follow commands from the same one. so lets say if presse is true for the working on, presse will be true for all the rest. The problem still happens if i use different combinations of objects like 3 crates or 1 propane tank and 2 crates. Can someone please help me find a solution without changing the instance name. By the way '_root.hater' is the character.

View 0 Replies

ActionScript 3.0 :: AddChild From A Class - Get The Error "1180 : Call To A Possibly Undefined Method AddChild?

Jun 15, 2011

I'm trying to have a class file which can add objects to the stage via addChild; however, when I call addChild from within the class file, I get the error "1180: Call to a possibly undefined method addChild." I've tried importing flash.display.* and that doesn't fix the problem. Does the class file have to extend Sprite or MovieClip to be able to add objects to the stage?

View 8 Replies

ActionScript 3.0 :: Box2d Addchild - 41061: Call To A Possibly Undefined Method AddChild Through A Reference With Static Type Class

Jan 16, 2012

I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:

[Code]...

Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.

View 9 Replies

Arrays :: Flash - Collision Detection Between An Instance In Motion And Array Does Not Work?

Mar 8, 2012

I am trying to test the collisions between a bullet and an array of enemies in Actionscript 2. However it is not sensing a collision.This is the code in the bullet.

onClipEvent(load)
{
facing = _root.player.facing;
speed = 1;

[code]....

View 1 Replies

ActionScript 3.0 :: Difference Between Mc.stage.addChild And Mc.addChild?

Jan 20, 2011

I have the followings:

_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1

Why won't the MC display a child without using his stage?

View 1 Replies

ActionScript 3.0 :: Difference Between AddChild And Parent.addChild?

Aug 11, 2009

I'm trying to resolve an issue that reared it's ugly head yesterday.Frame one of main timeline I have the following code:

Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;

[code]....

The newMC doesn't show up.If I add 'parent.' in front of the addChild then it appears.mc_LibItem has a base class of "flash.display.MovieClip" and is exporting for ActionScript and on frame one.For grins I created a new .fla and began messing around with the same addChild idea and it worked.

View 14 Replies

ActionScript 2.0 :: Objects - XML - Creating A New Instance Of An Object That Uses An Identical Name To An Older Instance Delete The Previous Instance?

Mar 20, 2009

Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?

View 1 Replies

Actionscript 3 :: Why Isn't Variable Incrementing

Feb 18, 2012

When the user presses the space bar, I'm trying to take one string from a series of strings labeled c1-c9, break it into an array, display that array, and then increment the linenumber variable at the end of the function so that the next time the space bar is pressed, the next string in the series is traced and so on and so forth. Here is the relevant section of script (the strings and the linenumber variable have been declared earlier)

[Code].....

Every time I press the space bar, though, I just get the traces of the initial string and linenumber value repeated without any incrementing. I think it may have something to do with the "this" before the bracket in this line var displayarray:Array = this["c" + linenumber].split(" "); which I found in a code sample on some website and do not understand at all, but I get compiler errors if I try to join the "c" and the line number without the "this" there.

View 1 Replies

ActionScript 3.0 :: Incrementing Integer On Each Two Hours

Mar 29, 2010

I try to increment each 2 hours but I don't know how to proceed.

View 2 Replies

ActionScript 3.0 :: Rotation And Incrementing Variable?

Sep 28, 2009

I'm working on a flash movie that involves the use of rotating 3 objects in a matter that the first one moves 18000 degrees cw according to the value in the 'num' variable. The 2nd object rotates -1800 degrees. The third one rotates 180 degrees.

What I actually want to do is create a movie of the older analogue electric meters that had the 5 dials that represented each digit so if the far right dial moved from 0 to 5 the 2nd would move the opposite way to be between 0 and 1 and the third a hair to the right of '0' and so on in increments of 1/10.

When I run the below code the dials ( I currently useing jetplanes until I draw or locate a pointer image file as well as the circle with 0-9 marked off in it) stay on 500 and should be moving a bit since I have another variable that increments num by 1. I tried using the Timer event and would get several errors. I also know that the way it runs now doesn't work since num is going to be assign the same value of 18000 since I have it setup to gotoAndPlay(1) in frame 2. How would I be able to have it so that so it would increment without getting undefined variables. I also tried a for loop to increment the num but the stage would instantly show the end result after the loop was done.

code
--------------
var num:Number = 18000;
var i:Number= 0;

[code]...

View 0 Replies

ActionScript 3.0 :: Incrementing A Number Randomly?

Nov 16, 2009

I'm trying to get a text field that behaves like a fake hit-counter. Adding random numbers and getting larger each time:

My code doesn't add up though, it just replaces the text each time!!

var incrementTimer:Timer = new Timer(1000,0);
var lastNumber:uint = 0;
incrementTimer.addEventListener(TimerEvent.TIMER, incrementNumber);
incrementTimer.start();

[Code]......

View 1 Replies

ActionScript 2.0 :: Incrementing A String Variable

Mar 15, 2012

I basically have a text file with a username variable that assigns usernames to username1, username2, and so on. I would like to create a loop that checks to see if that username was created and if it was a conditional statement will follow. The problem I have is I want to do a loop with a counter(var i) and increment that counter in the loop and concat that with loginName to input that into a dynamic textfield labeled loginName1. (Actionscript 2)[code]I am using loadvars to load 2 text files, one has username and ip(username1 = blahblah ipaddress1 = blahblah and so on), the second file has an array that has ipaddress and data usage passed in an array. i want to check how many usernames there are and check the ipaddress of that username against the other file containing ipaddresses and usage.) I have everything setup, but im running into issues when writing a loop to check for username1, username2, and so on.

View 2 Replies

Actionscript 3.0 :: Loop Not Incrementing Values

Apr 24, 2010

I've solved this problem in AS2 but I can't seem to sort it out in AS3.[code]...

View 1 Replies

ActionScript 2.0 :: Incrementing An Array Of Movies?

Jun 13, 2005

I'm trying to create a spinner for different ads for an advertising company website. Each ad has a name, such as "out" "pie" and "bigger". All of them are turned off except "pie" to start off with:

Code:
//initialize movie
var itemArray:Array = new Array();itemArray[0] = out;
itemArray[1] = pie;
itemArray[2] = bigger;

[code]....

The thing is, I can' figure out the button script to cycle through this array. I want to click a forward and back button, lets use forward for now, and do something like (don't mind the syntax):

Code:
on (release) {
i+1, remember the spot, and make everything else invisible.
When you click again, you increment to the
next ad/instance name and so on.
}

What is the actual syntax for this?

View 3 Replies

ActionScript 2.0 :: Incrementing Within Arrays Using XML Data

Jan 6, 2007

I'm working with a gallery grabbing images from data extracted from an external XML file, and I'm trying to make it work in a hierarchical or folder like structure in Flash 8.For instance, thumbnails are displayed on load, and when a thumbnail is clicked, more thumbnails specific to the image clicked are displayed.As sort of a beginner to Flash and ActionScript, I've been working with this project for a couple months.There is one obstacle I'm facing within the 'for' loops I'm using.First, an example of my XML file is like this:[code]This way displays the catalog look just as I'd like, but it is only good for the first piece of art since this 'for' loop only loops through the <products> node within the first <art> node. Now, if I change 'this.childNodes[0]'to 'this.childNodes[1]',I can display the <products> for the next <art> node.The part that I have not been able to figure out is how to increment that 'this.childNodes[x]' so that I can use it in an onRelease function.

View 4 Replies

ActionScript 3.0 :: Incrementing Values To A Variable

Jun 17, 2011

i'm trying to add values to a variable.[code]a simple drag and drop on a MC.i would like to store the X displacement when i drag. let say i have 30 in a variable wich store x position of myMC, if i drag the MC 200 units the variable should read 230 and so on.

View 2 Replies

ActionScript 2.0 :: Won't Stop Incrementing While Being Hit By An Object

Feb 3, 2012

I have a problem creating scores in my game. how can i stop it from incrementing +1? [cod]e...

View 2 Replies

ActionScript 2.0 :: Incrementing A Variable With Buttons?

May 20, 2005

I've followed several tutorials on how to do this, but my dynamic text box always returns a value of "Nan" when I try to increment it's value.I've been trying to use Code:_root.total = _root.total + 1;] in an on release function. Even if i managed to get this to work though, I still need to reuse the variable i'm incrementing within other calculations.

View 2 Replies

ActionScript 2.0 :: Looping / Incrementing OnRelease Function?

Mar 6, 2009

Just getting up to speed on looping and incrementing variables. A real time saver.I have a onRelease function that I would like to apply to several button objects:

phase1a.but1.onRelease = function() {
p=0;
thisImage();
}

I need the p variable as well as the target but1 to increment. This is my first attempt:

for (n=1; n<=23; n++) {
phase1a.but[n].onRelease = function() {
p=[n+1];[code].......

I get a good trace on n showing that the incrementing is successful but nothing on p when the button is clicked and no execution of the function thisImage(). Not getting any errors either. Can you not loop an onRelease statement?

View 13 Replies

ActionScript 3.0 :: Incrementing Through Instances Of Movieclips To Get Them Into An Array?

Jun 2, 2009

the user needs to select an answer from a dropdown list.  I am then creating  an array that will store the answer to each question when the user clicks the submit button.  Each of the drop down menus is named sequentially.  So what I am trying to do is write  a while loop that will increment through and read each of the values into the array so I can process the responses later.  The issue that I am having is writing the syntax to recognize the Instance name of the specific drop down I am trying to reference.
 
Here is the basic code I am using:
 
var Store:Array = new Array(2);
public var Increment:Number;
Increment = 1;

[code]....

So the DropDowns instance names are DropDown1, DropDown2 etc...  It works fine if I manually enter in each instance name (but there are 43 total and I don't want to do each one individually).  
 
I am assuming that I need to setup some sort of variable to temporarily add the increment number to the "DropDown" and then use that as the reference:
 
Increment = 1;
while (Increment <=2){
ItemNumber = "DropDown" + Increment;
Store[Increment] = MovieClip(Scroller2.Form_Scroller.content).ItemNumber.value;
trace(Store);
Increment++;
}
 
But when I do that, I get the following error message:
 
TypeError: Error #1010: A term is undefined and has no properties.
at combotest/submitted()
 
I assume this is because it is looking for an instance of ItemNumber instead of the instance of the value of ItemNumber. 

View 5 Replies







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