Actionscript 3.0 :: Dynamic Building Arrays With MovieClip Names?

Apr 30, 2009

In the AS2 days you could create an array and add a bunch of Mc names to it like so

Code: Select allarray("clipA","clipB","clipC", etc..)

Then you could use this array to reference clips dynamicly or on stage to do stuff.I was trying to do the same with AS3 but came across a problem I've not found an answer to yet. I created the following code:

Code: Select allvar letterArray:Array=new Array("A","B");
var buttonArray:Array = new Array();
//

[code]....

Now with the line:

Code: Select allvar currentButton:MovieClip = buttonArray[i];

I get: Type Coercion failed: cannot convert []@369e8581 to flash.display.MovieClip.but if I remove that line, it works. My problem is that I need to make it a "var" of type movieclip before I can assign a listener to it. Why can't I build an array of movieclip names using:

Code: Select allbuttonArray.push(["button"+letterArray[i]]);

I have seen arrays in the past that contain:

Code: Select allarray(mc1,mc2,cm3, etc...)

but notice that it's just using the name of the clip and not array("mc1","mc2","mc3", etc..)

View 6 Replies


Similar Posts:


ActionScript 3.0 :: Arrays - Dynamic Field Names?

Mar 3, 2010

I need to create dynamic arrays with field names loaded from a database. So, the names for the fields will be always different.Then, suppose I have the names "product" and "color" to create the following array structure dynamically:var myarray:Array = new Array;myarray[0] = ({product:undefined,color:undefined});But in other ocasion, the names may be say "brand" and "model", so the array will be:myarray[0] = ({brand:undefined,model:undefined});

View 1 Replies

ActionScript 3.0 :: Call A Button Inside A MovieClip, With Names Stored In Arrays

Mar 10, 2012

I have an Arrays that contains the names of MovieClips:

Code:
var MyMCs:Array = ["A","B","C","D","E"];

The actual MovieClips names are "MC_A", "MC_B", etc..., I use this method so I reuse the same Array for multiple tasks, I simply add what ever it's needed to the name to match the task at hand. On this case I add "MC_".

Then I have multiple Arrays, with the same names of the values of MyMCs. The values of each these Arrays are the names of buttons that are inside the movieclips of MyMCs:

Code:
var A:Array = ["RR","TT"];
var B:Array = ["YY","UU"];
etc...

I could add a listener to a button this way:

Code:
MC_A.YY.addEventListener(MouseEvent.CLICK, DoSomething)

My problem is that i want it to be done dynamically, using the Arrays values in a loop to add Listeners to the all buttons. The loop system is not a problem for me... my real problem is in the dynamic attribution itself.
Here is what I have:

Code:
//'i' and 'j' have previously been created
for(i=0; i<MyMCs.length; i++){
for(j=0; j<this[MyMCs[i]].length; j++){

[Code]....

I know that this is correct since I tried them separately and I can trace the proper values.

I know that my problem is in the "this" since I get an error message stating:
1084: Syntax error: expecting identifier before this.

I suppose it should state something else... I tryed with "root", "parent", "child", "MovieClip"... with no luck...

View 2 Replies

ActionScript 1/2 :: Dynamic MovieClip Names?

May 18, 2009

I have an array that houses the names of six movieclips. I randomly select three of them. I am trying to get my randomly chosen movieClips to do what I want them to do. I have tried the following code to get the first to fade in:

[Code]...

But it does not work. The trace comes back with the full movie clip name ex: mcTom, but even though that value comes up in the trace, the AS doesn't see it as a movie clip. Any thoughts on how I can correct this?

View 4 Replies

ActionScript 2.0 :: Dynamic Movieclip Names?

Aug 1, 2005

I've got this code but apparently the reference to the button doesn't work since i get an AS error upon execution.

PHP Code: [code].....

I've already tried without the brackets but that yields the same result.

View 3 Replies

ActionScript 3.0 :: Dynamic MovieClip (Loader) Names?

Jul 8, 2009

I have an array of data that I'm using to create thumbnails and labels  I'm using "Loader" to load the thumbnails (sample code below) but what I'm wondering is how I can make the name of the loader dynamic so that each child gets named "image1, image2, ...". I tried adding "[i]" after the "image" for each item in the code but it complained about missing semicolon before left bracket.

var image:Loader = new Loader();var target_image:URLRequest = new URLRequest("images/" + xmlData.Product[i].id + ".png");image.name = "image_"+[i];
image.load(target_image);

[code].....

View 3 Replies

ActionScript 3.0 :: Possible To Call Dynamic MovieClip Names?

Oct 17, 2011

I'm looking to get some information on something I've been wondering about for a while now. Is it possible to call a dynamic movieclip? Here's an example: I have 30 movieclips all named sequentially: A001, A002, A003, etc. I want to make a listener to dynamically know if I've clicked any one of the 30, but also know which of the 30 I've clicked.

You know, to avoid writing 30 variations of a listener. (not to mention that I have 5 categories to do this for, meaning there are 150 in total) Perhaps what I would need out of it would be the number value, as well. To perhaps place that in a variable after it has been recognized, so I can use it in the function.

View 13 Replies

Actionscript 3 :: Dynamic Instance Names - Create X Instances Of A Movieclip

Apr 18, 2011

i made a custom class where i would like to create x instances of a movieclip. But the following doesn't work:

[Code]...

I keep getting the error: Scene 1, Layer 'Layer 1', Frame 1, Line 5 1119: Access of possibly undefined property Collector through a reference with static type CustomClass.

View 3 Replies

ActionScript 2.0 :: Building Menu + Submenu With 2 Arrays

Sep 13, 2004

I'm building a menu with action script, the menu has an interval, so the items follow after each other. This is not a real problem. But the submenu is. I want to build it the same way, with the interval. But the menu array contains, some years, and with a loop a go trough this array and flash builds it with the items of the array. The submenu array, contains the quantity of the year, so the quantity of subbuttons.. But i can't fix it to use the number in the array as quantity of subitems. here is the code:

[Code]...

View 1 Replies

ActionScript 2.0 :: Building Menu + Submenu With 2 Arrays?

Sep 13, 2004

I'm building a menu with action script, the menu has an interval, so the items follow after each other. This is not a real problem. But the submenu is. I want to build it the same way, with the interval. But the menu array contains, some years, and with a loop a go trough this array and flash builds it with the items of the array.

The submenu array, contains the quantity of the year, so the quantity of subbuttons.. But i can't fix it to use the number in the array as quantity of subitems..

here is the code:

Code:
menuYearItems = [0, 4, 6, 5, 9];
menuYear = ["2004", "2003", "2002", "2001", "2000", "INFO"];
i = -1;

[code]....

View 1 Replies

Arrays :: Get The Key Names Of An Array?

Mar 14, 2011

I've been seaching on how to get the key names of a flex Array as there is no such function in the Array class. Here is my answer that may be usueful to any of you.

View 2 Replies

ActionScript 3.0 :: Arrays And Variable Names?

Jun 15, 2009

How/can you pass a array into a variables name?

var urlRequestArray:Array = ["home.txt", "contact.txt", "about.txt"]
var reqNameArray:Array = new Array("homeReq","contactReq", "aboutReq")
for (var i:uint; i < buttons.length; i++){

[code].....

View 3 Replies

ActionScript 3.0 :: Dynamically Create Arrays With Variable Array Names?

Jun 17, 2010

i need to dynamically create arrays with variable array names.
 
for example, something like this:
  
for (var n=0 ; n < nodeContainer.length ; n++) {
nodeObj = nodeContainer[n];
var name:String = nodeObj.nodeID;

[Code]....

View 16 Replies

ActionScript 2.0 :: Create A Loop That Will Put A List Of Names From External Sources Into A Number Of Arrays?

Jul 3, 2006

i am trying to create a loop that will put a list of names from external sources into a number of Arrays .so what i did is :

Code:
for (i=0; i<4; i++) {
this["loadVarsText"+i] = new LoadVars();
this["loadVarsText"+i].onLoad = function(success) {

[code].....

and i dont understand why it is not working, and how can i fix it?

View 3 Replies

ActionScript 2.0 :: Load Variable Data From An External XML File And Dynamically Displays The Item Names In A Menu - Arrays - Functions

May 18, 2005

I have been working on a Flash movie that loads variable data from an external XML file and dynamically displays the item names in a menu which may then be clicked to display other dynamically-loaded content that corresponds to the menu item that was clicked. I have now come to a standstill in the project as there is something I'd like to achieve but simply cannot work out how. This is my first attempt at working with XML in Flash and one of my early attempts at using variables. What I'm trying to achieve is; once the user has viewed the item's content, they can simply click "next" and "previous" buttons to display all of the content for the next or previous items in the XML document.

I know it probably sounds simple and I'm sure some of you could achieve this in 5 minutes (!) but I can't get my head around some of the coding. I assume previousSibling and nextSibling would come into play here as well as some sort of functions which access arrays of data for the previous and next items, but I'm just not sure how to correctly put these things to use. Rather than post my code and example images of the stage up here on the forums, I've created an html page here: [URL]

View 2 Replies

ActionScript 3.0 :: Dynamic Hit Testing Against Dynamic Instance Names?

Jun 22, 2010

Ok, Background. I have two objects both of which im spawining in though code. We will call them bullets and wolves. They have their own .AS files which tells them everything they need to know about themselves. I figured i would do most of the hit testing on the bullet.AS file, hit testing against the wolves as there were going to be a set number of wolves but not a set number of bullets.o, I named them by running a loop and putting the linenewWolf.name = i.toString();Yes, new wolf is a declared variable, and i is the name of the variable that makes the loop run. I also have a test in it, and it works fine.

However, The hit testing is where i come into an issue. Remember, its on a seperate .AS file. The wolf maker and namer is on the main flash page.The hit testing function isif(this.hitTestObject(a)){i changed up my variable name to run a second loop. first variable name is "i" and the second variable name is "a"And for some reason i get a type error 1034, which from what i understand is an error that you get when two instance names are the same. Also, If possible, i would like to add letters to the name of the object, but im not sure if flash will let me as i belive the code would look something like this

View 1 Replies

ActionScript 2.0 :: Building A Dynamic Gallery?

Jul 3, 2008

I have been looking for a while on the web, but somehow, the answer Does anyone knows a comprehensive tutorial on how to build a dynamic photo gallery with an integrated content managenent system.the only results that i found are concerning a gallery updatable via ftp and modifying the xml file

View 7 Replies

ActionScript 3.0 :: Dynamic Building Scrolling Gallery - XML?

Feb 4, 2009

What I'm trying to do is build a Dynamic XML scrolling gallery, but it's not going to be a gallery, more like scrolling images with links, that when you click on an image, it will take you to the url designated for each image in the XML.I have no experience working with AS3, so far what I've got are things I'm learning trying to build this.The issue:The issue is that when I run the script, the url designated to all the created movie clips have the same url. For example it will use first "link" on the XML on all 4 movie clips (so all the movie clips would be linked to , or it will use the last "link" in the XML for all movie clips (so all the movie clips would be linked to . How may I fix the issue above?

PHP Code:
<?xml version='1.0' encoding='ISO-8859-1'?>
<chapter_list>

[code].....

View 12 Replies

Professional :: Dynamic Building Text Box With Push Of Buttons?

Jun 18, 2010

I need it with Flash CS4, AS2...

I want to make a little app, .swf, that has a bunch of buttons on them - each button corresponds to a string of text...

So let's say, the buttons are marked as "Rd" "St" "Ln" etc...

When they click on the button, I want it to add that listing to the dynamic field box so it will look something like this

*User clicks on Rd button and "ROAD" pops up in the dynamic text box - User then clicks the "Ln" buttons, and then the dynamic text box changes to "ROAD/LANE"

User decides they don't want to use road, so they click on "Rd" button again, and the dynamic box reads "LANE" - user then wants to add "st" so they click on the corresponding button and now the text field reads "LANE//ROAD"

View 4 Replies

ActionScript 2.0 :: Building Menu Of Buttons With Dynamic Text On Top

Sep 17, 2004

I have managed to get data out from Mysql database. All it returns to me are:
1) Name of the button
2) Where it link to
3) Number of Buttons for the menu

So now, how can I build a menu of buttons such that I can display according to the database return on the number of buttons? I have already create a movieclip which is the image of a single button. With dynamic text on top of the button in the movieclip.

I just need to loop it thru the number of buttons and display the buttons on screen. But I can't seems to get it right. I have looked through the XML dynamic menu but it's not very similar to mine as I'm using PHP script to connect to the database.

View 3 Replies

ActionScript 3.0 :: How To Add Dynamic Names To MC's

May 27, 2010

I am trying to create a pretty simple image script for a flash website. What it does is to create a container named mc and then loads in an image into the mc from XML. It goes through the XML file like in a for each loop. But the problem I have is that every image container then gets the name mc. So then now when I try to build the function which makes it possible to press on one of the image containers to enlarge them, it only makes the last image larger since that is the last one to be created with the name mc. So how do I give every movieclip that I create a different name such as mc1, mc2 etc.[code]

View 8 Replies

ActionScript 2.0 :: AS 2 Dynamic Array Names?

Dec 14, 2010

I was wondering if it was possible to create the name of a NEW array dynamically. I have tried the following with no success. Does anyone know if this can be done?

Actionscript Code://Tried and failed_global["newArray"+newArrayNumber] = new Array();//Tried and failed_this["newArray"+newArrayNumber] = new Array();//Tried and failednewVariable = _this["newArray"+newArrayNumber];newVariable = new Array();

View 1 Replies

ActionScript 1/2 :: Using Dynamic Names For MovieClips

Jul 3, 2009

I am trying to simplify things by using dynamic MovieClip names. I have three MovieClips on the stage.

1) mcPage1
2) mcPage2a
3) mcPage2b

But my code isn't working. I'm guessing the "this" part is what is messing it up. Thinking that the computer doesn't know which MC is "this". It traces fine outside the function, but inside the function it traces undefined.[code]

View 2 Replies

ActionScript 2.0 :: Dynamic Sprite Names?

Nov 27, 2006

Is it possible to have dynamic sprite names? For example if I am constructing a tile map from an array how can i give each sprite object a different name and referense it later?

in actionscript you could just do

attachMovieClip("blah"+i+"_"+j...

and reference it with root[name]

how could I achieve this with actionscript 3?

View 1 Replies

ActionScript 2.0 :: How To Set Dynamic Background Names

Jul 23, 2008

All the nav links are correct but i am having problems with the background color and placing the submenu nav links.For the background color i am have created a function drawBG. At the moment i have set the name static, but i realise that sometimes i have 3 submenu.So i can't use the same name over and over again. How do i create the names dynamicly for say 3 submenu'sso i have something, likemainMenuBG - submainMenuBG - subsubmainMenuBG - subsubsubmainMenuBG

Code:
function generateMenuNew(container, name, xPos, yPos, depth, node_xml, bgMenuDepth, bgName) {

[code].....

View 6 Replies

ActionScript 3.0 :: Creating Dynamic Var Names?

Jun 22, 2010

Is there a way to make dynamic var names? Cant remember how to do this.

Something like:
NameCount = 1;
Obj.eval("Item" + NameCount)) = "hello world";
Obj.Item1 // trace "hello world"

View 3 Replies

ActionScript 3.0 :: Dynamic Array Instance Names

May 28, 2009

This should be simple but I can't come up with or find the answer anywhere. All I want to do is create a series of Arrays with instance names generated on the fly. I then want to reference these later. I have a "for" loop with a variable "count" that I want to add to a base name of rowArray and use the result to create an Array. I would think that it would look something like this:

[Code]...

View 2 Replies

ActionScript 3.0 :: Creating Clips With Dynamic Names?

Apr 6, 2009

the error I recieve i:Instantiation attempted on a non-constructor.

Relevent Code:
private var hoverText:MovieClip;
private function createTexts():void{ for (var i:Number=0;

[code].....

View 4 Replies

ActionScript 3.0 :: Dynamic Names For Class And Variable?

Sep 20, 2009

How do you make a new instance of a class with a dynamic name.

var dynamicname = new dynamicname()

i try something

var this["test"]:Class = new ["Test"]()
 
but offcourse its not this...

I need this couse i have a librairy with SWC fonts they are only reference.. I get the font name from a CSS file and after i need to make a instance of the SWC file so the font is embedded.

View 3 Replies

ActionScript 3.0 :: Create Dynamic Function Names?

May 27, 2010

I'm trying to create dynamic function names, something like this:

[Code]....

View 1 Replies







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