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
Similar Posts:
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
Jun 6, 2008
Code:
for(var i=0;i<10;i++){
var skeet:MovieClip = attachMovie("skeet", "skeet" + i, i);
[code].....
View 5 Replies
Aug 1, 2010
I am wrtiting a code which later on will read from XML and display text with links. Below is my code.
[Code]....
my problem is with the mouse events. When I test the movie, only the last link change on mouseover and on mouseout event, not every movieclip.
View 0 Replies
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
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
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
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
Jan 21, 2011
I recently started learning Flash and Actionscript and now I'm trying to write an actionscript for the first time. Im doing this in Actionscript 2.0.I have a movieclip that consists of two images and one dynamic text field with a variable. The name of the images are "VS1_P1_RUN" and "VS1_P1_OFF" and the name of the dynamic text field is "pumptext". In the dynamic text field I have the variable "VS1_P1_Ind". VS1_P1_Ind is probably a boolean variable as it shows 1 or 0 in another program but in Flash it shows True or False (not sure if Flash thinks it's a text/word or a boolean).My script is supposed to display the image named VS1_P1_RUN if the variable of the dynamic text field pumptext shows the text True and it goes like this:[code]
So I'm completely stuck in what to do. The bottom code works as it should but I want the images to show depending on the value of the variable VS1_P1_Ind. I thought just changing the text field to dynamic and typing the variable name in the variable field would do it but no.If it could be a clue to the solution I'll also share that the value of the variable is not seen/shown in textfield while inside the movieclip. Creating a dynamic textfield outside of the movieclip shows the value of the variable just fine, True/False.
View 1 Replies
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
Dec 8, 2008
I have a mc (changeColorMc) and three movieclips. The three movieclips are created on the fly (so there could be more movieclips) and filled with a color from an Array. This works fine.
Now I want to add an eventlistener for each movieclip, so when someone push one of the movieclips the movieclip with the name "changeColorMc" gets that same color from the colorArray.
My question is: How can I pass the color value from the colorArray to the buttonPressed function? Is this possible?
I was also thinking that I had to create three buttonPressed functions ie. buttonPressed1, buttonPressed2 and buttonPressed3 and attach these to the created movieclips.. but how? Because I don't know up front how many movieclips there will be..
View 5 Replies
Aug 26, 2009
Code:var StringMine:String = "hello";And i want to use the value of that string, 'hello' to name a new variable, i thought like this,Code:var [StringMine]:String = "One";but not supprisingly, it doesnt work...
View 2 Replies
Aug 1, 2009
I am wanting to create an array. 10 values in it (couting from 0 index to 9). Each 'place holder' will have a corresponding value to it;s index i.e.
myArray[0]=0
myArray[1]=1 etc...
I can do that in a for loop. But then I want to attach each value to a single variable name. I then want to change that each variable to a string. I then want access to all the variables outside of the for loop.
var i:Number;
var aArray:Array = new Array();
for (i=0; i<10; i++) {
[code]....
The output error is 1084: expecting identifier before aArray.
View 1 Replies
Oct 3, 2007
I'm using loadVars in AS2 Flash 8 and PHP returns this string
success=false&error_message=xxx
The success variable traces fine but error_message is always undefined. Is it because the underscore is not allowed?
View 4 Replies
Jul 25, 2011
i have an array of coins that are layed out on a map for a character to come pick up.i have the coins displaying on screen but i cant get a simple hit test to work. it only seems to work on the last coin created, i presume because the 'i' value hasnt been appended to the name. i knew how to do this in as2 but dont know the syntax for as3. ive attached the file for you to have a look at.
code:
rectangle_mc.startDrag();
rectangle_mc.x = mouseX;
rectangle_mc.y = mouseY;
[code]...
View 4 Replies
Nov 7, 2009
I'm curious if there is dynamic naming for variables, arrays, functions and whatnot in AS3. Below are Perl examples of what I'm asking about. It should be pretty explanatory.
[Code]...
View 3 Replies
Aug 4, 2010
I'm producing an array of thumbnails onto the stage from xml, all works fine, but I need to give them a unique number, starting from 0 etc. I believe I'm doing this right but I'm trying to trace back the ID/number from a mouse event...and keep getting the highest number for all of my instances.[code]
View 6 Replies
Dec 22, 2008
I am just getting started with AS3 and have run into a problem. I had a way of attaching movieClips from the library to the stage in AS2 that used the old attachMovie() function where I would run a for loop and it would duplicate the moviclip to the stage and dynamically create new names for the new instances.I now am using this:
var myCube = new cube();
addChild(myCube);
Then, I can access the myCube instance's properties like this:
[code]....
View 9 Replies
Jun 5, 2009
I have 4 Mc's on the stage, and they have instance names 'mc1' - 'mc2' etc.The MC's have links in them (they are kind'a navigation items) and i need to change the functions of the 'rollOver, and mouseDown events', but keep the MC's the same.The MC's are referenced by instance name and given functions in the first few frames of he movie. for example
---------------
mc_1_0.onRollOver = function() {
if (_root.mc_1_0._currentFrame == 1) {
[code]...
Now, what i want achieve is to change the instance names of the MC's (mc_1_0 for example) so that when the user interacts with this MC on the stage, they are taken to locations of my choice (and the actions of another MC), by switching the instance names. IE, i want to change the instance name of 'mc_1_0' to 'mc_2_0' at runtime, BUT i want to do it with a variable from a .txt file.i would need to start with a script that looks for the MC with a certain instance name
-- look for instance mc_1_0, and then change the instance name to 'mc_2_0'
The effect would be that the user would instigate the same actions, regardless of which of the two MC's they rolled over.Maybe i could call the instances initially 'MC_1_Temp' and 'MC_2_Temp' etc: and then i would need a script to change them to 'mc_1_0' and 'mc_2_0' at runtime.SO in the text file i would need something like this
--------------------------
&MC_1_Temp_name=mc_1_0&
--------------------------
this way the behaviour of the MC on the stage wil take on the functions of another MC.should i be looking at something like this placed on the MC.....
onClipEvent(load){
//make this instance called - var = MC_1_Temp_name
}
View 3 Replies
Mar 8, 2004
I am generation a textField by_root.createTextField("some"+randomNumber,1);Now I want to assign some text to the textField, how do I refer to it???
I tried using a variable first like
var myText="some"+randomNumber;
_root.createTextField(myText,1);
[code].....
View 3 Replies
Jan 20, 2009
This is the object array target structure I am looking to create
myObject.myArray[0].data=value;
myObject.myArray[0].data2=value2;
myObject.myArray[1].data=value;
[Code]....
View 2 Replies
Mar 8, 2004
I am generation a textField by
_root.createTextField("some"+randomNumber,1);
Now I want to assign some text to the textField, how do I refer to it? I tried using a variable first like
var myText="some"+randomNumber;
_root.createTextField(myText,1);
myText.text="something";
it doesnt work it gives me an error
View 3 Replies
Sep 22, 2008
Probably a lack of knowledge on my part (no, definitely...), but how do I go about loading dynamic text fields from an array, using dynamic variable naming?
for(j=0; j<count; j++){
this["contacts_mc.nameText"+j+".text"] = inputArray[j][0];
}
"nameText0", "nameText1", etc are the instance names of dynamic text fields in the contacts_mc movie clip, which is on the root level of my timeline.I get no return at all when tracing the target dynamic text field as trace(contacts_mc.nameText1.text), for example. Dynamic naming examples I've come across don't seem to work here - perhaps a difference in how dynamic text fields are assigned?
View 2 Replies
Nov 3, 2009
on my main timeline there is a movieclip ("sampleMc") which contains a number of labeled frames containing movieclips of gallery images (for example "dyerBikiniMc"). in turn, each of THESE movieclips contain a number of frames of detail shots of the main image (for example "dyerBikini00Mc, dyerBikini01Mc, dyerBikini02Mc, etc.").on the main timeline i have a gallery navigation bar with thumbnail buttons determining which image will be displayed. there's also a right arrow shaped button "detailsBtn" that i'd like to allow the user to click frame-by-frame through the detail shots of the image. i also have a before/after toggle button on the main timeline that needs to control the movieclip one level below that, where the before/after images of that particular detail shot are stored!
View 9 Replies
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
Oct 19, 2006
i've got 48 small movieclips named "1clip", "2clip", etc. all the way up to "48clip." I want to do something with them all and use a loop to affect them all the same way.
[Code]...
but that doesn't seem to work. are variables and instance names interchangeable? my lClip var traces out of course, but the lClip.imagHolder.loadMovie never happens (clip inside the clip).
View 1 Replies
Oct 14, 2009
I have built a 3dcarousel off a tutorial from this great site [URL]...There are some things I just cant work out after many hours of Googling and scratching my head I thought I would ask some more experienced peeps.
Firstly I need to add some links to the dynamic text field. Secondly I need to add a simple preloader as the carousel takes a while to load especially when all the text is in Japanese which it all will be eventually.
I am actually looking for skilled flash programmers to be able to use on a freelance bases as I run a small website business.
View 2 Replies
Jul 23, 2009
How do I make my email address and URL linkable
This is the copy on my actions layer[code]...
View 3 Replies
Aug 18, 2009
Okay I'm trying to make a navbar which is dynamically created when the flash movie starts, and the number of buttons and their links are defined by XML.So far, I've got the navbar making itself correctly and taking button names and number from the XML page.What I cant seem to figure out is how to have actionscript 3.0 take the link address for a button from the XML and use it to make the appropriate button navigate there when clicked.My XML is layed out like this;
buttons spacing="2"
button label="MOTION" path="www.google.com"
path="www.google.com"[code].......
Using this returns this error message; ReferenceError: Error #1065: Variable navigateToURL is not defined.at app.gui::MenuButtonMain/golink()
View 1 Replies
Aug 25, 2009
Here is what I'm trying to do: recreate the news ticker from [url]...
HEre is the trick: The client wants to be able to change the news themselves via an external .txt file, the also want each piece of news to link and the link will change..
I've got the text loading into the .swf just fine, but I have no idea how I can make the news pieces hot to a dynamically changing link that will be changed by them
View 6 Replies