ActionScript 2.0 :: Dynamically Accessing The Arrays?

Feb 2, 2007

I've have a question about dynamically accessing arrays. I'm going to have a number of arrays, char_a, char_b, char_c, etc.....

The values of these arrays will be used to load in other movie clips, x, y, scale, color, etc...

_root.char_a =[15,20,100]

I have a function to load in movie clip based on a given array, the variable I'm passing to the function is going to be a, b, c, etc... So if I pass 'a' to the function I want to load in the movie clip based on the values in "char_a", [15,20,100].

function loadCharLoc(name) {
x = this['_root.char_' + name][0];
y = this['_root.char_' + name][1];
moviename = 'grid_char_'+name;
_root.main_grid.attachMovie(moviename, moviename, getNextHighestDepth(), {_x, _y:y});

When I trace the values of x or y I get undefined.

View 3 Replies


Similar Posts:


AS3 :: Arrays - Accessing XML Data Randomly

Oct 21, 2011

After reading data from XML source I like to be able to show one random item from data whenever, say, clicked a button. I think I can accomplish this by storing the data into an array and use it from the array. I would like to learn if possible to do it directly from xml without storing it into another array.

var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("XML_NOTES.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);

[Code].....

View 2 Replies

ActionScript 3.0 :: Accessing Arrays In And Out Of Functions?

Nov 21, 2005

I'm creating a soundboard, and and I've been using Flash for about 2 weeks and Actionscript for about a week, so you'll have to excuse my ignorance. I've used google to look for specific things to no avail so here I am.Okay, so, I have a soundboard that, when pressing a button, it will hide or show certain buttons on the page, to give the feeling of multiple pages. All my visibility stuff works like a champ.

Right now, in the working version of my soundboard, I'm not using functions to instantiate my linkable objects, create the array, or populate the array to hold the linkable objects. I would like to use functions to make my code less obtuse. I looked around for a while trying to figure out how to pass an array of objects into a function but i haven't had much success. I'm not quite sure if it's even possible to do. These are the errors I get:

1120: Access of undefined property playArraySound001.
1061: Call to a possibly undefined method play through a reference with static type Class.
1120: Access of undefined property playArraySound001.
1120: Access of undefined property GordonSoundArray.
1136: Incorrect number of arguments. Expected 1.

The first code is what works, the next code is the stuff that doesn't work.This is the working version

Code:
//////////// CODE FOR PLAYING SOUNDS
//// This is creating an instance of the Linkable object
var playArraySound001:Link_10_minutes = new Link_10_minutes();
var playArraySound002:Link_3_eggs = new Link_3_eggs();

[code]....

View 5 Replies

ActionScript 3.0 :: Soundboard Accessing Arrays In And Out Of Functions?

Oct 24, 2009

I'm creating a soundboard, and and I've been using Flash for about 2 weeks and Actionscript for about a week, so you'll have to excuse my ignorance. I've used google to look for specific things to no avail so here Okay, so, I have a soundboard that, when pressing a button, it will hide or show certain buttons on the page, to give the feeling of multiple pages. All my visibility stuff works like a champ.

Right now, in the working version of my soundboard, I'm not using functions to instantiate my linkable objects, create the array, or populate the array to hold the linkable objects. I would like to use functions to make my code less obtuse. I looked around for a while trying to figure out how to pass an array of objects into a function but i haven't had much success. I'm not quite sure if it's even possible to do.

[Code]...

View 0 Replies

Arrays :: Accessing Variable From Other Class Returns Null

May 10, 2011

I did a separate levelData class to be able to flexibly add levels. I was happy with it until my supervisor ordered me to convert my levelData into XML. I did an XML version of the levelData's data (question, answers, correct answer...). I used the old class and converted it so that it fetches the XML.

All seems well, I did traces of my answers array and it printed nicely...

But the headache started when I tried this.

// This code appears in a different class with
// currentLvl:LevelData initialized in the constructor.
quizHolder.ansA.ansHud.text = currentLvl.choices[1];

[Code].....

LevelData Class in PasteBin: [URL]

View 2 Replies

ActionScript 3.0 :: Accessing Mc's On Stage That Were Created Using A Loops And Arrays?

Feb 4, 2010

basically what im trying to do is create a jigsaw game, simple eh! i have nothing on the stage at compile time, only four items in the library. these are four different puzzle pieces with export names of "piece01" "piece02" "piece03" and "piece04". my AS goes like this:

ActionScript Code:
var puzzlePieces:Array = ["piece01","piece02","piece03","piece04"];
var len:int = puzzlePieces.length;
var pieceList:Array = [];

[Code]....

how do i or what name do i give the addEventListener to? (if that makes sense)
to be able to drag them.

View 5 Replies

ActionScript 2.0 :: Can't Create Arrays Dynamically

Sep 20, 2010

What I am trying to do is create an array of 12 out of an unknown number of thumbnails (there are 23 at the moment though this will change).So basically first 12 in array1, second 12 in array2 an so on until all thumbnails are in an array. So I need to create each array using a dynamic name, in this case 'pagearray' I.E pagearray1, pagearray2, pagearray3.

So here is the code I am trying though I have only managed to get the code to create the one array so far. The last one. This code is within a for loop that iterates through all the thumbnails.[code]...

View 2 Replies

ActionScript 2.0 :: Dynamically Create And Name Arrays?

Jul 24, 2006

I always seem to have problems when there are square brackets involved in naming things

What I am trying to do is dynamically name an array. I have been trying to do it like this:

ActionScript Code:
var myI:Number = 1;
var ["tmpAr"+myI]:Array = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)

[Code]....

View 4 Replies

Arrays :: Dynamically Removing Movieclips When Clicked

Oct 27, 2011

I have a game where i add some cartoonish ants, that when they are clicked, they need to be removed from stage. There are 4 differend kinds of ants, so im doing a Math.random for picking which one to add. (ant 1+2+3 have 50% chance to spawn and 4th 50%) rnd_nbr = (Math.random() * 5)+1;

I have a timer doing 10 tick, and i reset the timer to make neverending. Then i have a math random and if sentences adding mc' to the stage with movement from Tweener, and event listeners for clicks. But i cant figure out how to remove them when clicked. I have done alot of failed tries right inside the click_candy_anty function. I've left them commented out.

[Code]...

View 2 Replies

Arrays :: Dynamically Populate Text Fields In Flash?

Sep 1, 2010

I am trying to figure out how to dynamically populate textfields in Flash. The text in the fields will either say ON or OFF based on the value of bstatus.var bstatus will either have a value of 0 or 1 I have the following textfields listed below.I'm not sure if the syntax is correct, but I was thinking that the text fields would be in an array, and I would create a for loop--that will go through the array in order to have the fields populated.

var textFields:Array = new Array();
textFields[0] = compTxt.text;
textFields[1] = bathLightTxt.text;

[code].....

View 1 Replies

Arrays - Make For Each Loop Dynamically Depth Of Iteration?

Mar 24, 2012

I hope I am clear enough. My data set is populated I have

comment:CommentVO;
comment.replies=[comment:CommentVO,comment:CommentVO,comment:CommentVO];
_comments:Array = [comment:CommentVO,comment:CommentVO,comment:CommentVO]

I've correctly populated my _comments Array and the replies array in my CommentVO Obj.

[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

IDE :: Accessing Dynamically Named MCs?

Nov 10, 2009

Trying to get from AS2 to AS3 and the simpliest things are taking too long.I have some movieclips on the main timeline named...

btnSm1_mc
btnSm2_mc
btnSm3_mc

[code].....

View 2 Replies

ActionScript 3.0 :: Accessing MC Within A  Dynamically Load MC?

Jun 28, 2009

I'm developing a website for school and in an effort to make it eaier to update i'm attempting to make it as dynamic as possible. So far I've been able to load in MC's dynamically. These MC's banners are made up of smaller MC's themselves. When the mouse goes over one the banners, I want to access one of it's child MC's. This is what I have so far:

//the banners to be loaded are set in the library to export with a class matching their respective names
//when page loads...

[code].....

View 5 Replies

ActionScript 3.0 :: Array Of Arrays - Dynamically Loads Images Into A Movieclip Entitled 'gallery'

Sep 25, 2009

I've created a photo gallery that dynamically loads images into a movieclip entitled 'gallery'. Right now the images are listed in an array. is it possible to make an Array of Arrays so that I could load different Arrays for different image galleries? Is this somewhat how it would work? Lets say I were to switch to a section entitled 'landscapes' which we will pretend is the array "var a:Array = new Array();" for now.

[Code]...

View 7 Replies

ActionScript 3.0 :: Accessing Dynamically Created Objects?

Mar 17, 2009

If objects are created dynamically in AS3, using code like this:

for (var num:Number = 0; num<10; num++){
var txtFld:TextField = new TextField();
txtFld.text = 'This is the original text';
this.addChild(txtFld);
}

then later, i want to changet the text of one of the TextFields, how can I do that? The only instance listed in the variables is a single instance of "txtFld" and it is the last one that is created. How can I access the others?

View 1 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

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

Actionscript 3 :: Accessing An Instance In A Dynamically Added MC?

Apr 11, 2011

I've added a movie clip dynamically using the following code:

var apie=new cPie()
apie.x=100
apie.y=100
stage.addChild(apie)

I now have a pie on my stage. Yum. Assuming this works like a movie clip placed on the stage by dragging and dropping, I added this in to change an instance in the pie.

[Code]...

View 2 Replies

ActionScript 3.0 :: Accessing Custom Objects Dynamically?

Sep 8, 2009

I have a mc in my library called recentArticlesButton, exported as a movie clipHere's my code:

Code:
public class ABCDEF extends MovieClip {
private var recentArticlesButton:RecentArticlesButton = new RecentArticlesButton;

[code]........

View 4 Replies

ActionScript 3.0 :: Accessing Child In Dynamically Created MC?

Oct 16, 2011

I have a MC with 2 children in library:

myParent1 -> myChild1
-> myChild2

when I put it on stage in editor and run following script, both trace are valid and give response "true":

ActionScript Code:
trace (myParent1.myChild2.visible);  // true[code]....

but when I put MC on stage dynamically via addChild, the first trace gives
compiler error while second trace works(error: Scene 1, Layer 'Layer 1', Frame 1, Line 81120: Access of undefined property myParent1)

[code]....

View 3 Replies

ActionScript 2.0 :: Accessing Object Properties Dynamically?

Jun 21, 2007

I have a custom property called Player (like a basketball player) that has properties for points per game (ppg), rebounds per game (rpg), etc.I'm designing a piece where users can get averages and compare players across many different categories.

I have a String variable "stat" that tracks which property they want to compare. I can use "stat" in a sorton function, but need to use it to access the object property. So when the user chooses "ppg" or "rpg" i can access Player.ppg and Player.rpg by using the stat variable. Player.stat doesn't work.

View 2 Replies

ActionScript 3.0 :: Accessing Object Properties Dynamically?

Jun 27, 2010

hat is the correct way to access an object dynamically? I have tried this with no success:

Code:
i += 1;
var myVar = this[myObject. + "myProperty" + i];

[code].....

View 3 Replies

Actionscript 3 :: Accessing External Library Symbols Dynamically?

Aug 14, 2010

I am loading an external SWF containing uninstantiated MovieClip Symbols. I can get the SWF loaded, no problem. If I call:loader.contentLoaderInfo.applicationDomain.getDefinition( "TestClip" ) as ClassI get the class of a Library symbol called "TestClip", which I can then instantiate. Jawesome.The issue I'm having is that basically I want to have access to all of the Library symbols without needing to explicitly know their names. I was hoping to use:

describeType( loader.contentLoaderInfo.applicationDomain );

...to get reflective access to the Library symbols, but the XML returned doesn't seem to include any references to them. Perhaps I'm calling it on the wrong object? I also don't want to have to explicitly create coded instances to gain access. This is for a tool for Flash artists, and it's important to avoid code, even simple code.

View 1 Replies

ActionScript 3.0 :: Accessing Dynamically Created Movie Clips?

Aug 23, 2010

I'm trying to build a relatively simple photo gallery where the images are loaded via XML into thumbnail movieclips that have been dynamically generated, positioned and added to the display stack. I used a simple for loop to generate the thumbs and traced the thumb.name to make sure they all had unique instance names. I then added a listener to the thumb mcs in the for loop and created a function that traces the instance name of each thumb mc, to see if all is working, however, every thumb mc traces the same instance name. My question is how can I create the thumbs dynamically in a loop and, essentially, make them buttons that would display the big the full size photo.

Here is my prototype code:

ActionScript Code:
for (var i=0; i<12; i++) {
var thumb_mc:MovieClip = new thumb();
// Positioning: The xy coordinates are in an array outside the for loop.

[Code]......

View 4 Replies

ActionScript 3.0 :: Accessing A Movieclip Of Dynamically Loaded Swf File

May 16, 2009

in (swfA.fla) I have this code in frame1

var module1:Loader = new Loader();
var admin = new MovieClip();
addChild(admin);

[Code]....

(my thought here is that 'admin' contains swfB.swf?) - this would seem very simple... but it...

...does not work and gives me this [seriously unhelpful] error:

TypeError: Error #1010: A term is undefined and has no properties.
at swfA_fla::MainTimeline/frame1()

View 7 Replies

ActionScript 3.0 :: Flash Dynamically Declaring/accessing Objects?

Dec 8, 2010

So heres my code in my main game loop:

Code:
if (! initialized)
{
for (var c = 1; c < 1000; c++)

[Code].....

The error given is "1120: Access of undefined property particle4." However, everything traces correctly, but the individual particles cannot be accessed outside of the loop. Eventually I want to add the next particle at the mouse position on every click, but obviously I can't do that without being able to access the individual particles. I also read about having to use getChildByName() to access names set in AS3, but I haven't been able to get that to work either.

View 2 Replies

ActionScript 3.0 :: Accessing Children Of Dynamically Added MovieClip

Jan 8, 2011

Code:
function saveAction(evt:MouseEvent):void{
var choice=evt.target.name;
var inputText:String = saveName.text;
}

I have this and I am trying to make a variable from the contents of the input box. Simple ya? The issue is that it is a child of another clip that is being added dynamically, so it doesn't think the input exists. How do I declare the input? How can I target it's contents? Also I have a remove function that is meant to remove this same parent clip.

Code:
function closeSaveWindow(evt:MouseEvent):void{
removeChild(saver);
}
'saver' is a variable created in another function, so I think there is a scope issue there. To try to fix that I declared 'saver' as a movie clip as a global var.

View 1 Replies

ActionScript 3.0 :: Accessing A Property Of An Instance Inside A Dynamically Created MC

Sep 17, 2009

Im dynamically creating an instance of a movieclip, call it a game piece. This game piece has 4 frames, each with a movieclip called base(although one is red, one blue, one green, one yellow). When the game piece is created I set the frame to indicate player color. Im also changing the alpha of base to 1.0 when its being dragged, 0.5 when its dropped.

Using the following code, everything works fine if the game piece color is set to the base in frame 1 (red). If the game piece is created and the timeline moved to a frame other than 1, I throw an error when trying to access base.alpha (this would be the second, third, and fourth instances of base in the game piece timeline). Heres the strange part, this is only a problem when the game piece is first created and added to the display list. Once created, even after the error has been thrown, I can access the alpha of bases 2, 3, and 4 in the drag start/stop listeners. Heres a link to the work in progress, and the relevant sections of code (shortened for brevity, t1 is the top left piece on the pallet, others just repeat the same code):[URL]
 
[Code]....

View 3 Replies

AS3 :: Flash - Dynamically Adding Buttons To Stage And Accessing In Different Function?

Jan 11, 2012

I am trying to add multiple different versions of the same button to the stage and to be able to access them later on by assigning them an ID. The way I assumed this would be done is to have a class for the button where an internal static variable is defined so that the ID can be found in the next function. This does not seem to be working, as the ID is constantly showing as the last number given, so in this case 6.I assume that I am doing this wrong? Here is my code so you can better understand:

package src {
import flash.display.MovieClip;
import flash.events.*;

[code]......

View 2 Replies







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