ActionScript 3.0 :: How To: Call 3 Array Positions
Jan 19, 2009im trying to get this project done. Basically i'm pulling info out of an XML file:
Code:
<COVER>
<COVER_FILE_LOC>myImage1.png</COVER_FILE_LOC>
[code].....
im trying to get this project done. Basically i'm pulling info out of an XML file:
Code:
<COVER>
<COVER_FILE_LOC>myImage1.png</COVER_FILE_LOC>
[code].....
I am trying to put certain x and y positions into an array so that I can randomly change positions based on the positions stored into that array for example
Code:
Select all var rbtxp:Array = new Array(-65, 1, 580, -920, 1316, 684);
var rbtyp:Array = new Array(-234, -1248, -550, 268, -72, 525);
Code:
Select all testMc.x = Math.floor(Math.random()* rbtxp.length);
testMc.y = Math.floor(Math.random()* rbtyp.length);
addChild(testMc);
i have this array with positions:
[Code]...
let each movieclip go to it's original position out of the array?
my intention: creating a sketchpad that records mouse movements so the drawing can be played back.
problem: _xmouse and _ymouse are not being saved in the array. i get an 'undefined' error when trying to read a position that should exist somewhere in the array.
code:
history = new Array();
history[0] = new Array();
history[0][0] = new Array();[code].....
my intention: creating a sketchpad that records mouse movements so the drawing can be played back. problem: _xmouse and _ymouse are not being saved in the array. i get an 'undefined' error when trying to read a position that should exist somewhere in the array.
[Code]....
I have thumbs placed on the stage. I create an empty mc to load swf. But my thumbs disappear from the stage when I test the movie ( html or swf) if I settle the _ and _y position of the empty mc.why the emptymovieclip positions affect the positions of my thumbnails?
View 2 RepliesIn the below code, "sector" is an indexed array.fsector1, fsector2,fsector3 are Associative arrays.The "gotoAndStop" command doesnt work properly.The last trace command, "curTerr" returns the same value as "curSec",leading me to assume i did not define "curTerr" properly.
Actionscript Code:
function loadmaptest(){ sector = ["fsector1","fsector2","fsector3"] fsector1 = new Array(); fsector1["terrain"] = "grass"; fsector2 = new Array();
[code]....
PHP Code:
var nc = 25;
var vd = 80;
[code].....
how these syntax problems confuse me !! I just want to create a name dynamically to push to one of multiple arrays.
[Code]...
i hv 3 arrays row1 row2 row3,I need to call array into a for loop one by one
var rowno:int=1
for(i:int=1;i<10;i++){
this['row'+rowno].push(value)<<< showing error [code].....
what is the right way to use array dynamically???
I have global variables:
_global.var1Array
_global.var2Array
_global.var3Array
_global.var4Array
and so forth.The issues is I need to call a variable from within the array but depending on an option the user has chosen it needs to call the right one.At the moment I am trying
end = "_global.var"+userOption+"Array["+array#+"]";
userOption being the needed array
array# being the needed entry within the array.
However when I try and use this I of course just get it like a string, not as a variable...
is there a way to call on my functions for one button..for example my home btn on CLICK event does 5 different functions. Is there a way to put those functions in some sort of an array and just call on that...
[Code]...
I'm trying to make two duplicated movie clips check for any of the others ie bullet239 hitting badguy92
View 12 RepliesI've defined an array which stores the function name, like this:
var aresetButtonTop:Array = new Array(resetTop1,resetTop2,resetTop3,resetTop4,resetTop5);
Then I have a button named"btnresetTop" which when clicked will call one of the five functions stored in the above array(aresetButtonTop). The functions are called at run-time depending upon some conditions. I need to figure out how I can call those functions using the array index. I'm using the following code to call the function. The value of i has been already calculated.
btnresetTop.addEventListener(MouseEvent.CLICK, aresetButtonTop[i]);
After doing this I'm getting the following error when I click the button:
TypeError: Error #2007: Parameter listener must be non-null. at flash.events::EventDispatcher/addEventListener() at gallerytest_fla::MainTimeline/thumbTopClick()
Note: thumbTopClick() is a function inside which all these codes are written.
I need to find out whether it is posible in AS3 to call a function name using the array index or not.
Can I call a function when building an array in Flex 3?
public function gridBuilder(myArray:Array):void {
var i:uint;
for (i=0; i<myArray.length; i++){
[Code]....
MyArray is the result of a remote call to the database. I then prepare the array to be used in a dataGrid. I also want to call a function that provides a grade. Unfortunately, my function appears to be called only once. Is it possible to call a function when you're building an array? see the "Grade:" bit.
I want to access the frame labels of a movieclip on the stage. How do I put them in an array in the timeline code? Like this? toolTipArray:Array = new Array(movieclip("framelabel"), movieclip("framelabel")...)
View 3 RepliesI want to loop through a array to call my functions, but can't get the syntax right, is this possible?
var myArray:Array = ['function1()', 'function2()'];
for (var key:String in myArray){
// I want to call the function here
}
So I'm attempting to call a random item from an array which is all fine and dandy, but I'm attempting to fill the array with functions, and therein lies my problem.Here is my code, it's just a test file I made to keep it simple while I learn how to do it:
Code:
var functionArray:Array = new Array('a', 'b', 'c');
function a():void
[code].....
i have some actionscript that makes a
ExternalInterface.call('someFunction');
call.is it possible to reference the html object that made the call to someFunction directly using the ExternalInterface.call call?
Assume that the object that makes the call also has some Callbacks (via ExternalInterface.addCallback) that are accessible via javascript.
Currently:
Actionscript source
ExternalInterface.call("someFunction");
ExternalInterface.addCallback("someCallback",someASfunction);
[code]....
So I'm attempting to call a random item from an array which is all fine and dandy, but I'm attempting to fill the array with functions, and therein lies my problem.Here is my code, it's just a test file I made to keep it simple while I learn how to do it:
Code:
var functionArray:Array = new Array('a', 'b', 'c');
function a():void
[code].....
I need to call a varargs function:
function doSomething(... args): Object {
// do something with each arg
}
However, I'm building the arguments for this dynamically:
var someArgs: Array = ['a', 'b', 'c'];
doSomething(someArgs);
The problem is, when I call the function in this way args ends up being a 1-element array with someArgs as the first element, not a three-element array.How can I call doSomething with someArgs as the argument array?(For the search engines, this is argument unpacking)
I'm making numerous ExternalInterface calls to JavaScript methods and have a helper function for doing so:
[Code]...
However this means the JavaScript method will only be passed one argument - the array of arguments - meaning I have to change the JavaScript to accomodate this, e.g. instead of:
[Code]...
I have an array of strings. Each string is a name of a class. How can I call the library item with the class name that corresponds to the string in the array?
View 1 RepliesI'm trying to create a swfPanel for Flash CS5.5 using JSFL.I created my interface in flash and try to communicate with a JSFL command.So, in my .fla file, I use an ExternalInterface with callBack to call a specific function in JSFL,and then swfPanel.call() for the return.The problem I encounter is that I can't pass an Array as argument for the call function (after the AS3 function name). Here's the code :
In AS3 :
function init():void{
ExternalInterface.addCallback("callBackPanel", JsflCallback);
MMExecute("fl.runScript( fl.configURI + "AirMobileFramework/AirMobileFrameworkPanel.jsfl", "checkSettings" );");[code]....
When calling panel.call("callBackPanel", result[0], result[1]); there is no problem, my callback is well called, but when using panel.call("callBackPanel", result); I've an error :
La ou les erreurs JavaScript suivantes se sont produites lors de l'exécution de AirMobileFramework :
La ou les erreur(s) JavaScript suivantes se sont produites :
i filled an array with some objects, i want to be able to call a random object from that array, for instance:i trace array[2] but i want the outcome to be random. Sort of like the shuffle function in PHP.
View 1 RepliesI have 35 textboxes with the names "t1" to "t35". How would I call these names in a for loop? I have tried this with no luck:
[Code]...
I know I'm doing something wrong with the ("t"+i) but I dont know how how to combine a string and number like that.
if you look at the code:: barn is an instance of an MC on stage. I have a few buttons stored in an array which i want to attach scripts with a for loop. Why does adding an item from the array not work when placed inside the function call?
[Code]...
Checked out the kirupa easy random color code, but is it possible to call random values from an array of colors? these examples don't seem to be working.. Code:
[Code]...
Ok.. so here's the basics of the code:
ActionScript Code:
var stackNum:TextField = new TextField();
stackNum.everythingcondensedhere = everythingcondensedhere
stackNum.type = TextFieldType.DYNAMIC;
[Code]....
It creates a textfield (and an image, but not important) and a movieclip, adds the MC to the stage and adds the image(itemLoader) and the textfield(stackNum).
And then it adds it to an array at [x][y].
Then later it calls the .stackSize, adds 1 to it, and tries to update the textfield.
Everything works except for updating the textfield, I just can't figure out what I need to use to point to it and have it change.
I have created a 2 dimensional array call table and want to assign each and every elements in that array to 0. The codes below shows how I have done it:
var table = new Array();
table = [ [0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0] ];
Just like to find out if there is a simpler way to do it. I've tried doing it with a 'for' loop but I always get 'undefined' values. How to do it?