ActionScript 2.0 :: Unable To Make Arrays Storing Functions?
Feb 1, 2004
I just had a quick question, anyone know if it's possible to have arrays indexing a series of functions say something a bit like this as an example? AS]genelist[0] = Math.random()*10;[/AS] I am currently trying to get some geneticsstuff i did in director to flash so it can be used in a game, gonna suck if i to have a LOAD of variables with different names
View 5 Replies
Similar Posts:
Feb 1, 2004
anyone know if it's possible to have arrays indexing a series of functions say something a bit like this as an example?
[AS]genelist[0] = Math.random()*10;[/AS]
I am currently trying to get some geneticsstuff i did in director to flash so it can be used in a game, gonna suck if i have to have a LOAD of variables with different names...er this is in mx btw
View 5 Replies
Jan 5, 2008
I am trying to randomly pick out a function and activate it over a time period.
if I store the function names in an array, then randomly select one via a function inside a setInterval, how could I instigate a function call? ... have a look:
Code:
var functions:Array = new Array("fade","duplicate","explode");
function fade(){
do this...
[Code]....
View 8 Replies
Jul 8, 2009
Currently working on a project where I have to load in a ton of images and store them in corresponding arrays. The images are listed in seperate xml files bus.xml, car.xml, train.xml. The structure of the 3 files is the same e.g.
<images>
<image>car01.gif</image>
<image>car02.gif</image>
<image>car03.gif</image>
</images>
Now inside of the main class I have arrays for the images.
var busArray:Array;
var carArray:Array;
var trainArray:Array;
How would I create a function to recursively read each XML file and load the images into the array. I only want to create one Loader class. The bit that confuses me is how do I do the loop to load each file and once its loaded one file move onto the next until all the files from that XML file are loaded.
I thought it might be something like this,
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, imageLoaded);
for(i = 0; i < xmlFileLength; i++) {
loader.load(new URLRequest("car01.gif"));
} private function imageLoaded(e:Event) {
//add image to its array
//move onto next image
}
What I am thinking I need is a Flag of some sort to say the previous image is loaded. Move onto the next, but not sure how to structure it.
View 3 Replies
Oct 11, 2009
I'm trying to create a 7x7 grid of textfields. I'm storing the textfield properties in an array. Here is the code I have for that -
var instances:Array = [];
for (var k:int = 1; k < 50; k++) {
var inst.TextField = new TextField();
addChild(inst.[k]);
[Code]......
For some reason this doesn't do anything. I don't know why not. Am I storing or accessing the textfield properties incorrectly in the array?
View 2 Replies
Jan 21, 2011
The code
for ( var i:int = 0; i < markers.length; i++ )
{
markers[i].addEventListener( MapMouseEvent.CLICK, function( e:Event ):void
[code].....
View 3 Replies
Jun 7, 2008
I have 5 functions.I want one pulled out of an array and performed at random.How could I code this? //im only using 2 funcs for space ..
Code:
var way:Array = new Array("null","left")
var orientation:Number;
function null() {};
[code]....
View 2 Replies
Apr 4, 2012
I'm certain it's possible to use Arrays as the parameters in Functions,but I've tried repeatedly over the last few days, and they never seem to work.
View 5 Replies
Feb 9, 2010
I have a program which fills an array with data loaded from an external XML file. I've used the debugger to step through the program, and what I am seeing is this: Inside the function where the array is filled, the data is inside the array and everything is fine. However, when I go to another function, the array retains its structure but all the values are empty. I have no idea why it's doing this... though maybe it's some sort of scope issue? I've defined the array in the class, and everything is fine until I try to reference data outside of the function which it was put in. That being said, in a separate function, more data is added to the array and that data is still retained throughout the class.
View 1 Replies
Dec 23, 2010
I have been told that it is dangerous to pass arrays into functions because doing so can cause memory leaks.Could someone please explain how and why this happens?
View 1 Replies
Apr 1, 2009
Can I store function names in arrays, which then can be used to fire those functions when that array value is called? So basically - I mouse click, and that += 1 to my num var.
Code:
var myF:Array = new Array("thisone","thatone");
var num:Number = 0;
function thisone()
[Code]....
I dont know how to make a function call from a string value!
View 3 Replies
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
Dec 6, 2010
When I experimented with it, I tried to push one string and one function named "moveRight" into the array,
Code:
_behaviours.push("1", moveRight);
trace("_behaviours: " +_behaviours);
But when I trace the content of the array, I get
Code:
_behaviours: 1,function Function() {}
Why is my function moveRight, being renamed to "Function", and how do I call the different functions if I have several of them in one array? The purpose of all this is to make a simple AI system for my game enemies. After the enemies are added to stage, a special function would calculate a random number based on the number of entries in the array and then make the enemy perform the chosen function.
View 3 Replies
Jun 6, 2010
I've got a project thats getting a bit big, so Im taking the actionscript out into separate as files. I want all the basic functions to be in BasicFunctions.as and the make a library for more specific functions. I find that a lot of people use the import statement but I cant get that to work with a simple Hello World trace, yet the include statement works fine (see attached). I understand that import/include work differently, but which is the better method? If import, then is that heavier to work with. Any rate, what's the best way to organise code when it gets to the 1000+ lines?
[Code]....
View 9 Replies
Feb 9, 2009
I want to loop through a array to call my functions, but can't get the syntax right?
var myArray:Array = ['function1()', 'function2()'];
for (var key:String in myArray){
// I want to call the function here
}
View 1 Replies
Feb 9, 2009
I want to loop through a array to call my functions, butcan't get the syntax right, is this possible?[code]....
View 1 Replies
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
Sep 8, 2011
Is it possible to put a function into an array and execute it from calling it via the array?I did this before in as2 [code]
View 2 Replies
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
Jul 16, 2011
I have a site that plays either .mp3 or .flv files depending on what is selected from the menu. Menu loads in from xml. I get "unable to make connection with server or unable to find flv on server" when I try to play the video. But the video and audio files are all in the same directory and the mp3 files play fine. I think I'm having a problem with the setMedia command. Here's the code that loads the video and audio files.
[Code]...
View 9 Replies
Jan 18, 2012
i am looking for some kind of library which does CRUD easily using PHP and MYSQL.My goal is to make some app in flash AS3.0 , where i will be receiving some data from user and storing in data base , and perform CRUD opertaions. I dont want to be so much involved in writing php and sl query.My scenario is:
Data types : [ like user_profile data, etc]
add under data types 1 to many fields with various types..
Database tables and realtions etc should be done by my DREAM library, then user when select a Dtat Type, he is presented with related fields to fill up data.
I will be using Flash AS3.0 ( Builder or IDE ) to perform .If only i can find some php library i think AMFPHP can connect flash with php
View 2 Replies
Mar 4, 2012
Is there a way to make an mc switch arrays?
View 9 Replies
Dec 26, 2006
why cant the variable "height" modify the position of y? =S im new at ac so i dont know if an element of an array can be a variable? and how do i make it a variable?this is a par of the code im writing to make a group of movieclips appear offstage in a random positions as long as it is offstage (i know the array is not random since i give the values of each element but i tried by putting y= math.random * number?... but in the coordinates i didnt knew how to specify that it could be any random number exept the lenght of the stage)
onClipEvent (load) {
myArray = new Array ();
myArray[0]=-100;
[code].....
View 8 Replies
Oct 26, 2007
I'm trying to create something (which has probably been created a 1000 times before) that will fade in and out a series of images. I load the images into my movie and then I want to make some action script to loop through them to fadeIn/Out.So to begin with I want to store all the image names in an array and then loop through this. But I'm having problems accessing the movie clips from the array. Where am I going wrong?
Code:
var images:Array = new Array();
images = [wine_mc, sunset_mc, poppies_mc, pool_mc, eastView_mc]
[code]....
View 1 Replies
Jan 10, 2012
I have two arrays contains several movie clips. I used for loop to inject first array in timeline object succefuly. But then I realized, what the hack I will do about the second array I need to start them simultaneously and every array must have different destination at x and y.. Imagine banner 745x100px, I need to animate different movie clips from sides to some destination.
Code example:
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
var mainArray:Array= [amcMC, tantrumMC, blokMC, misMC, futMC, laoMC, cauMC, deepMC, plusMC, noMC, copMC ];
[Code] .....
I need to apply slightly different tweens on second array and trigger them simultaneously, or with small offset.
View 2 Replies
Apr 27, 2010
im making a platform game project but as of yet im still un able to make the camera move up and down when the charater jumps or stands on a platform?
[Code]...
View 1 Replies
Jan 7, 2005
Im new to AS but Im working everyday to improve, Im trying to make a menu but Im having difficulties with moving the menu:
I have a bar in 500 length and mask of 100 And I have 5 buttons. When I click 1 ofthem I want it to bring the correct positon of the bar with easing. Btw the registration point of thebar is upper left corner
View 4 Replies
Feb 26, 2004
I was wondering how to do the box effect like on [this] site. The lines move up and across to form a box. I have tried a few things that I could think of, but have't got it.
View 2 Replies
Nov 2, 2009
I retrieve XML data in Flex via HttpService. I have the resultFormat property on the HttpService instance set to HTTPService.RESULT_FORMAT_OBJECT. The result contains data similar to this:
<!-- ... -->
<children>
<item><!-- ... --></item>
[Code]....
I get an array named item beneath the element children when there is more than one item sibling. If there's only one, the conversion can't distinguish it from a scalar.
What do I need to change to have Flex convert all item elements to an array with 0 or more elements?
What would I have to do to get an array member children, dropping the item wrappers altogether?
The XML is generated by Struts on the server side. I always have the option to change the structure of the document there, but right now I'm interested in what I can do with Flex.
View 2 Replies
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