ActionScript 2.0 :: Dynamic Object Naming From Xml In Array?
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
Similar Posts:
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
Mar 11, 2010
I thought that there was a way to be able to name array indexes. Like instead of myArray[0], it could be myArray["tileFour"]. I thought that instead of using index numbers one could use index words.
View 1 Replies
Jan 4, 2011
I made a thread a couple days ago, but dont think i explained the problem well enough. What im trying to do is name each of the children.
Child 0 = A
Child 1 = B
Child 2 = C
all the way to Z. Then start at A again.
ActionScript Code:
function moveBubble(Event) { // This function handles the movement of the bubbles
if (!inPlay) return;
[code]....
View 7 Replies
May 9, 2010
I'm creating some mc's on the stage with the attachMovie function in a loop. I have no problem naming them like that:
foo.attachMovie("myClip", "myClip"+i, 200+i);
But I need to name them with part of an array like that:
foo.attachMovie("myClip", "myClip"+array[i]+"_mc", 200+i);
I thought that would work but I guess my synthax is wrong. How do you mix strings and arrays elements inside the () of the attachMovie?I need to get something like: myClipArrayElement1_mc for the name of the attached movies...
View 2 Replies
Nov 28, 2002
ok, that's some basic question but it's 4 am, I can't find the answer in the tutz and I'm starting to get a headache...I'm creating some mc's on the stage with the attachMovie function in a loop. I have no problem naming them like that:foo.attachMovie("myClip", "myClip"+i, 200+i);But I need to name them with part of an array like that:foo.attachMovie("myClip", "myClip"+array[i]+"_mc", 200+i);I thought that would work but I guess my synthax is wrong... How do you mix strings and arrays elements inside the () of the attachMovie?
View 6 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
May 11, 2010
In this code I created an array and am placing instances on the stage when I click on buttons relating each movie clip.
[Code]...
View 3 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
Nov 30, 2010
I've got about 50 buttons onstage with names like btn1a_mc, btn2B_mc, etc. Each one loads an external swf (called "Monosem1Aslideshow.swf", where the "1A" corresponds to the button name.) into a movieclip holder called slideHolder_mc. I'm trying to use an array instead of writing code for each button. I'm using the following:
Code:
buttonNumber = ["1A", "2B", "3C", "4D", "1E", "2F", "3G"];
for(i=0; i<buttonNumber.length; i++){
var btnName:String = "btn"+[i]+"_mc";
[Code].....
But I can't seem to get it to work.
View 7 Replies
Nov 30, 2010
I've got about 50 buttons onstage with names like btn1a_mc, btn2B_mc, etc. Each one loads an external swf (called "Monosem1Aslideshow.swf", where the "1A" corresponds to the button name.) into a movieclip holder called slideHolder_mc. I'm trying to use an array instead of writing code for each button. I'm using the following:
Code:
buttonNumber = ["1A", "2B", "3C", "4D", "1E", "2F", "3G"];
for(i=0; i<buttonNumber.length; i++){
var btnName:String = "btn"+[i]+"_mc";
[Code].....
But I can't seem to get it to work. I'm a little shaky on array syntax and can't find a tutorial that addresses my particular problem.
View 12 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
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
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
Jun 6, 2008
Code:
for(var i=0;i<10;i++){
var skeet:MovieClip = attachMovie("skeet", "skeet" + i, i);
[code].....
View 5 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
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
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
Sep 3, 2009
I'd like to make an object that has it's properties named by constants from another class but can't quite get it to work. I'd essentially like to do something like this:
var myObject:Object = {Event.OPEN:"value", Event.COMPLETE:"value2"};
This syntax causes compiler errors.
View 2 Replies
Oct 7, 2009
Still trying to get the hang of AS3 here. I basically have 4 MovieClips on my scene and a collection of MovieClips in the library. I want to be able to select 4 from the library at random, and display them on the stage. They will end up being clickable as its a kind of quiz where they click on the objects and the score is recorded. For now I need to get the hang of loading them at random. I also want to be able to make sure there are no duplicate buttons loaded to the stage. So far I have one movie exported to AS and displayed across the stage:
Code:
for(var i=0; i<4; i++)
{
[code].....
View 14 Replies
Jul 18, 2011
In AS3 I would like to set the key of a shared object with the contents of a string as opposed to specifically naming the key.
so.data.test = "andy" // this is the basic working system
I do not want to write test I want something like this
// this is a non working and incorrect solution but shows what I am trying to do.
String myKey = "test"
so.data.{myKey} = "andy"
View 1 Replies
Mar 20, 2006
i have a function that creates a movie clip and then procedurally creates 10 rectangles inside that clip.
[Code]...
View 6 Replies
Jan 30, 2012
I have an object
obj = { a: 1, b: { c: 1, g: x, h: { j: {k: z} } } };
if I have an array of dynamic length ["a", "b", [...], "g" ]
How can I now update a.b.c.g ? example:
function set($target, $new_value, $array){
//magic
}
set(obj, y, ['b', 'g']);
[code]....
View 1 Replies
Jan 25, 2012
I have a load of objects with arrays in them.
var tabData0: Object = new Object();
tabData0.tab1 = new Object();
tabData0.tab1.names = new Array();
[Code]....
I want to combine this output with a few more to refer to my object / array. The remoteHolder contains the value I need to know which object (tabData0, tabData1, etc) to retrieve the info from.
tabHolder['btn' + i].titleHolder.titleField.htmlText = all['tab' + tab].names[(i-1)];
But get this:
ReferenceError: Error #1069: Property tab1 not found on String and there is no default value.
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
Jun 28, 2009
Is it possible to, if you have an array of class names like ActionScript Code: var city01names:Array = ["pic_01", "pic_02", "pic_03" ...] make a new array which would read these names, instantiate them, and push them into a new array containing the instances of all these pictures, which I could then use for a slideshow?
[Code]...
View 7 Replies
Jul 13, 2010
I am curious if this is an okay implementation of the Array.filter() method.
[Code]...
I was not able to figure out an implementation of the callback function for the filter() method, where the callback was outside of the getGallery() function. I wonder if there is a way to get the isGallery function outside of the getGallery scope?
View 1 Replies
Jul 7, 2010
I have been trying for an hour to clone an array, It seems that nobody has a true reference on how to do it. Two arrays - movieClipArray 1 and movieClipArray2 I want to duplicate movieClipArray1 entirely so that when I addChild(movieClipArray2[0]), it doesn't take away from movieClipArray1 or reference it in any way.
[Code]...
View 3 Replies