ActionScript 3.0 :: Dynamically Naming/referring To Movieclips?

Feb 15, 2010

I am going to have a button that when you click on it it creates a movieclip and adds a certain child to it (In this case, its linkage is set as "Rifle"). Each time you click on the button I need to give the new movieclip a different instance name then the last, such as "Riflemen1", "RifleMen2" etc.. I will need to be able to refer to each movieclip seperatly in my code, such as for example:

You spawn three Riflemen.. You click on one of them, which selects it, you then click on an "Attack" button which makes only him start firing (in my case gotoAndStop(2)), you then decide you want the third one to attack and so forth..

View 1 Replies


Similar Posts:


AS3 :: IDE - Dynamically Naming Movieclips?

Sep 23, 2009

Ok, I've been climbing the walls trying to figure this out, looked everywhere for an answer, learned a few bits and pieces along the way, but still can't do it.I've made my Class which is a little movieclip called 'block', it's fine and does what I tell it to do ie. I can reposition itstretch itotate it and stuff.The problem is.. I want to make more of them and reference them individualy so I can change the properties of them individualy ie, the x and y values etc.

for (var i=0; i<2; i++){
var newBlock:blocks = new blocks();
this.addChild(newBlock);

[code].....

View 6 Replies

Flash :: Naming Instances Of MovieClips Loaded Dynamically?

Aug 18, 2010

I'm trying to name the instances of MovieClips that I dynamically load.

I tried doing this:

comp = new Comp();
// and also tried doing this--> var comp:MovieClip = new Comp();
comp.name = "comp"; // comp is the name I want the instance to be

[Code]....

View 3 Replies

ActionScript 3.0 :: Referring To On-stage Movieclips From An Array?

Jan 14, 2009

I have a movieclip on the stage in which I have some 90 movieclips also on the stage.

I created an array to hold the movieclips. But when I try to add eventlisteners to these movieclips by cycling through the array, I get a 1009 error ("Could not parse the XML. Error #1009: Cannot access a property or method of a null object reference.") Oddly, however, the application seems to work correctly, handling my listener events.

On the other hand, if I add eventlisteners for each movieclip individually, all works fine--no errors are thrown.

View 4 Replies

ActionScript 3.0 :: Naming Multiple Movieclips Using .name?

Mar 13, 2011

I am working on a little project where I have this:

Code:
for (var py:int = 0; py < 6; py++)
{

[code]....

View 2 Replies

ActionScript 2.0 :: Hittest - Avoid Naming All Of The Movieclips

May 3, 2010

Code:
if(_root.selmovie.hitTest(this._parent)){
_root.hit.text="it worked";
}

Why doesnt this work? I want to avoid naming all of the movieclips that this hittest is to apply to but this._parent isnt working...

View 4 Replies

ActionScript 3.0 :: Naming And Accessing Dynamic MovieClips

Sep 26, 2009

I'm trying to dynamicly create movieclips that I can drag and drop. Here's what I'm trying to reproduce dynamically: (I placed 2 movieclips on my stage and named them mandible_mc and vertibral_mc)

mandible_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);mandible_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);vertibral_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);vertibral_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void {
[Code] .....

Here's what's happening:
Unless I have actually placed two movieclips on the stage and named them mandible_mc and vertibral_mc, I get an error. If I DO have those to movieclips on the stage, I get no error and I get my instances of "name_box". But, I can't drag them. I CAN drag and drop instances of mandible_mc and vertibral_mc so I know the addEventListener and buttonMode "thingys" are being created.

View 7 Replies

ActionScript 2.0 :: [CS3] Naming Dynamic MovieClips Individually?

Jun 6, 2008

Code:
for(var i=0;i<10;i++){
var skeet:MovieClip = attachMovie("skeet", "skeet" + i, i);

[code].....

View 5 Replies

ActionScript 2.0 :: Referring To Variable LoadVar Dynamically?

Mar 31, 2004

I am reading a file with certain user defined variables like &x=30&y=50&z=100

Lets the variable is caught in a function as argument myVar

now depending on the variable the user passes I need to fetch the value. ie if the user passes x i need to read the value of x. how the user has named his/her variables.

What i need to do it get the value of that variable by using loadVar.

this.myVar; As such it gives me undefined. There is text present in 'this' myVar represents 'x' I have tried eval(this.myVar) as well as this.eval(myVar) but in vain

View 5 Replies

ActionScript 3.0 :: Using And Referring To Dynamically Created Instances?

May 26, 2010

I'm creating a DDR style game. The 'moving graphics' are being randomly and dynamically created with the default instance name (instance28, instance 30...) I want to be able to refer to these different elements according to another movie clip I press (in this case, they look like piano keys).

So, if a 'C' moving graphic is created, I want the C movie_clip with a listener attached to check the 'C' moving graphic.

[Code]...

View 2 Replies

Flash :: Create/naming Var Dynamically?

Jun 6, 2011

or some reasons i need to create var dynamicaly.

Exemple

I have first an Array wich i want to use to "compose" my vars names

myArray:Array = new Array("aa","bb","cc");

In my final project this Array is created from a xml.

I want to do something like this, but doesn't work...

var ["myvar" + myArray[0]]:Sound = new Sound();
var ["myvar" + myArray[1]]:Sound = new Sound();
var ["myvar" + myArray[2]]:Sound = new Sound();

[Code].....

View 1 Replies

ActionScript 3.0 :: Dynamically Naming Variables?

Aug 31, 2009

Is it possible to dynamically name a variable? Like set a certain string as a variable name wouldn't think so but just in case.

View 2 Replies

ActionScript 3.0 :: Dynamically Naming Functions?

Aug 31, 2009

Code:
public function btnU1Out_Handler (event:Event ):void {btnUOut_Handler(1);}
public function btnU2Out_Handler (event:Event ):void {btnUOut_Handler(2);}

[code]......

View 4 Replies

ActionScript 3.0 :: MovieClips - Dynamic Naming Links To Variable

Jul 26, 2009

I am doing the following
Code:
Select allvar a:MovieClip = new MovieClip();
addChild(a);
Now what I want to do is I want to create six more mc i.e., a2,a3,a4,a5,a6. I want to accomplish this using loop like this:
Code: Select allvar i:Number = 0;
while(i < 6){
var a:MovieClip = new MovieClip();
addChild(a);
}

So with above method how can I give different names link above to var a? Then I am using all of these var as following:
Code:
Select allvar cube:Cube = new Cube(new MaterialsList({
front:a , left:a2, right:a3, top:a4, bottom:a5, back:a6}),200, 200, 200,10, 10, 10);
scene.addChild(cube);
How can I use those dynamic name here?

View 1 Replies

ActionScript 3.0 :: Referring To Dynamically Created Movie Clips?

Jan 21, 2010

There are five dynamically created movie clips inside my flash movie. Is there any way that I could refer to these from action script code?

View 4 Replies

ActionScript 2.0 :: Dynamically Naming & Clearing Intervals?

Dec 19, 2006

I am trying to dynamicallly name intervals and clear them. Here's my code:

[AS]
_root.onMouseDown = function() {
setMyInterval();
};

[Code]....

View 1 Replies

ActionScript 3.0 :: Naming Dynamically Created Movie Clips?

Jan 14, 2010

i am using a loop function to generate an place instances of a movie clip on the stage. the movie clips are being used as buttons, they have text in them. here is the code

ActionScript Code:
// butAniMini is an external custom class animating the buttons
var _sideBarBut:butAniMini;
//variables to hold the first buttons x an y position

[code]...

the problem is that i dont no how to set the text in the buttons so u can change the text and add event listeners etc to them

View 3 Replies

Actionscript 3.0 :: Naming A Dynamically Loaded Movie Clip

Jul 1, 2009

I have a project that requires manipulation of a movie clip (swf file). This clip is called clip_mc.I have functions such as:[code]If I add to the stage the swf and call it clip_mc, then everything is fine and it all works - BUT I have a few of these files that need to be loaded when the button is clicked.I understand the loader() class and the addChild class but cant get my head around bringing them all together!so essentially I would like to know; How to dynamically load the swf and name it clip_mc so that the functions will work?!

View 2 Replies

ActionScript 3.0 :: Dynamically Naming Movie Clips In A Loop?

Oct 5, 2010

k say i wanted to create a bunch of movieclips in a for loop but wanted to name them something different each time, how would i dynamically name them?

View 1 Replies

Array's And MovieClips - Use The Naming Conventions Of An Array?

Nov 18, 2009

I received help on this site on this info-graphic im doing and the solution was to use an "array" which im not familiar with at all. the person that helped me added the following code that worked:

var city_arr:Array = new Array("louisville");//filll that array with all nedded cities//make all the boxes invisible at startfor (i=0;i<city_arr.length;i++){    var [code]...

since i dont know how to use arrays im stuck. i need to add at least 30 more cities to my info-graphic but don't know how to use the naming conventions of an array.Only one of the houses works (when you click on it a pop-up appears, is draggable and has an x to close the pop-up)

Attachments:
relocation_working.fla.zip (975.1 K)

View 1 Replies

ActionScript 3.0 :: Dynamically Referencing Movieclips?

Nov 28, 2011

I'd like to know how I can achieve this in AS3. The code would work fine in AS2, but as I am very new to AS3 I am not sure what the equivalent would be in AS3.

code:
humanNum = 1;
MC = ["Human"+humanNum];

[code].....

View 1 Replies

ActionScript 3.0 :: How To Dynamically Align MovieClips

Jan 29, 2010

I'm working on a project so as to hopefully learn AS3 a bit more, and for it what I have for it currently is that it looks at the time, and if its between 8 pm and 8 am it imports one mc, or if its between 8 am and 8 pm it imports another. My problem at the moment is that I can get it to import it and align it at the needed x coordinates, but not the needed y coordinates. I'm not sure what the exact y coordinates are, but as in the future they might change, I was trying to find a way to align it so that the very top side of the mc to the top side of the stage, but so far I have had no luck, as I can't think of what would be needed. I've seen references to a "StageAlign._______" before, but either I'm not using it right or it isn't the right thing to use.

Here is my code right now:
ActionScript Code:
import flash.events.*
import flash.display.StageAlign;
import flash.display.StageScaleMode;
var time:Date = new Date();
[Code] .....

View 1 Replies

ActionScript 2.0 :: Dynamically Add Several Of Same Movieclips To Stage

Sep 20, 2010

Im trying to dynamically add several of the same movieclips to the stage. This movie clip contains a textbox. I have tried the following:-[code]I have my movieclip exported fror actionscript with the identifier as (textbox). This code does add a textbox to the stage however it only adds the second one which says "goodbye" but not the first one which should say "hello"? I thought the loop should go round twice and add a 'newText1' and a 'newText2'??

View 3 Replies

ActionScript 3.0 :: Assign Dynamically Name To Movieclips

May 2, 2007

i wanted to create a bunch of movieclips in a for loop but wanted to name them something different each time, how would i dynamically name them? example of basically what i want to know how to do

[CODE]...

View 14 Replies

ActionScript 2.0 :: Use A Loop To Add Movieclips Dynamically

Oct 29, 2007

I have a little problem with a loop. I recieve som data from a database and gets it back as an array. I then use a loop to add movieclips dynamicly and this works fine to, but if i try to trace the id from an onRelease function i get an undefines, but when i dot it outside the onRelease it works fine. This is the code. Its in a class by the way.

[Code]...

View 1 Replies

ActionScript 2.0 :: Move MovieClips' X & Y Relatively/dynamically?

Aug 28, 2008

I have about 70 MovieClips and when you rollover one I want it to enlarge and the other MovieClips' x & y to shift so that nothing is overlapping. Does anyone know how to do this or has anyone seen an example? I have attached some screen shots of how I would like this to work.

View 1 Replies

ActionScript 3.0 :: Dynamically Creating MovieClips?

Sep 5, 2009

Is there any way to create dynamic animations? Say if I'm creating a game and there might be multiple sprite sheets for different NPC's, would I have to manually create the walking/whatever other animations manually?

View 5 Replies

ActionScript 3.0 :: Dynamically Created Vs Static Movieclips?

Feb 4, 2009

Movieclips created on the stage and instanced behave differently from dynamic movieclips in that they are destroyed when you go to the next frame (I have a stop on every frame). If I create that same movieclip dynamically then it will stay on the stage forever regardless if I go to the next frame or not. I understand that it needs to be removed from the display list but I can't find any event that is fired on a next frame basis. I could use onEnterFrame but at 30 fps, that's alot of overhead. The idea is to have all the code contained in my .as file.

View 6 Replies

ActionScript 3.0 :: Drag And Drop One Of Many Movieclips Dynamically

Mar 4, 2011

I'm looking to be able to pick up one of 36 movieclips on the stage, and drag it to a hotspot. If it lands on the hotspot, then it does something, otherwise it just gets dropped.

How do I dynamically change the "target_mc" to be whichever movieclip I select?

This code works fine, but that's because eventlistener is set-up explicitly for a given mc.

Code:
// sprites
import caurina.transitions.*;
var drag_mc:MovieClip = energy_sprites.play_wave;

[Code].....

View 3 Replies

ActionScript 3.0 :: Accessing Dynamically Created Movieclips

Nov 21, 2008

I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.

Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.

access a dynamically created movie clip.

View 1 Replies







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