ActionScript 2.0 :: Store Movieclip In Arrays
Apr 6, 2010how do you store a MovieClip in an Array?
View 5 Replieshow do you store a MovieClip in an Array?
View 5 RepliesI've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.
View 7 RepliesI have a basic xml file and i want to store the content in two arrays. I have little knowledge of actionscript. The XML file is the following:
<?xml version="1.0"?>
<quiz>
<item>
[Code]....
can a shared local object (.sol) store nested arrays? like:
myArray = new Array([a, b, c], [1, 2, 3]);
I have a series of variables created that store the distances between two points. I need to find the shortest distance between the two points so I'm storing the results in an array, then sorting the array to show me the smallest number which is the shortest distance. But the problem I have is that I don't need the number I need the variable in the calculation that relates to that number. Make any sense? So if the equation (herexPos - column3Begin) produces the smallest number I need to be able to reference column3Begin after I've sorted the array.
[Code]...
I'm trying to use associative arrays to store my variables but am looking for a solution to change the value of array1[i] to array2[i]. Since it's an associative array, the only way I know how to loop through these kinds of arrays is by the following:
Code:
for(var i in array1) {
trace(array1[i];
}
What I would do when using indexed arrays to change the value of array1[i] to array2[i] would be something like this:
Code:
for(i=0; i<array1.length; i++) {
array1[i] = array2[i];
}
However, I can't see any way you can do this with associative arrays because they do not have a numbered index such that in a loop you could
say array1[i] = array2[i] .
So I'm looking for a way to do this with associative arrays.
I am looking to take a movieclip that has been added to a container, and display that on a seperate movieclip. I have an animation that stops randomly on one of these clips, with a button that lets the user move to the next page if they like that selection. I would like that selected movieclip to display in another movieclip on this next page.[code]
View 2 RepliesI'm trying to create a game and have come across something that I have never really played with and am not sure if it is what I need to use in this instance or if it's as powerful of a resource as I am hoping.I have a movieClip that is an animated man. I can move him around my stage by clicking on him and then clicking where I want him to go. But I'm eventually going to need to store information about him. Such as his x and y position on the stage, attributes about him that are custom to my game.Real Quick: The man represents an army and when the user clicks on him, I want to display things like, Military Units in this army, number of men remaining in each unit, experience and so on. If you have ever played any of the "Total War" games you will know what I'm talking about.
View 1 RepliesMy stage have 3 movieclip that is mc1,mc2 and mc3.each of them are now alpha=0.I have a button on stage too and when click on it, 1 of the movieclip will be change to alpha=1.
here is my script:
var mcArray:Array = [mc1,mc2,mc3];
for (var j:int = 0; j < hotSpot.length; j++)
{
mcArray[j].alpha=0;
[Code]...
I have been trying to attach a certain number of movieclips (linkage name: player) to the stage with a random x and y value. I have put an irrelevant movieclip on the stage with this code attached:
Code:
onClipEvent (load) {
fielder= new Array();
[code].....
I'm currently trying to program a flash game using actionscript 3.0 where users would step on insects. Basically, I added multiple instances of insects movieclip and remove them by using hitTest function. When the mouse_mc. hitTestObject(insect), there were times the insect was not removed.
Here are the errors I encountered:
Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/swapChildren()
at SteppingGame/hitTest()
Error #1009: Cannot access a property or method of a null object reference.
at insectmc/onEnterFrameEvent_SF()
Also, is there anyway I could simply my code like creating multiple arrays of movieclip insectmc?
Here's my as3 code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.ui.Mouse;
import flash.display.Sprite;
[Code] .....
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..)
I have neither the capacity nor the integrity to overcome as3, how to build a system wherein if I were to press movieclip instances in a certain order, would move me to a certain frame if I did. I am trying to do this without making 100 eventlisteners and relying on an array instead. If I could say anything about how as3 is about implementation of values, I'd say it's a bit like using the titanic to deliver a piece of cheese on toast, but I guess what I need to know specifically is
How to make a function that relies on a certain set of array values.
How to splice that entire array after the array reaches a certain number of values.
How to move to frame 2 if the array does possess the correct values.
How to stay on frame 1 if it does not.
So far I have
var inacertainorder:Array = new Array();
var i:*;
i = 0;
function toframetwo(event:MouseEvent)
{gotoAndPlay(2)};
if(inacertainorder[i] == "0,1,2")
{stop();}
else inacertainorder.splice[i>3]
{gotoAndStop(2);};
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...
I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:
var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........
I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.
[Code]....
I'm stucked here. I want the font type "BauhausMedium" to apply when ft_01 is clicked, font type "Haettenschweiler" to apply when ft_02 is clicked, etc... at the same time I want all" ft_01a", "ft_02a", "ft_03a" movieclips to hide except for the movieclip similar to the clicked button. E.g. if "ft_02" was clicked ft_02a to be visible =true and rest to be visible = false (ft_01a, ft_03a).
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]...
I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.
View 5 RepliesI'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:
var ar1:Array = [1,2,3,4,5,6,7,8,9];
var ar2:Array = ['a','b','c','d','e','f','g','h'];
function merge(...multi):Array[code].....
Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.
A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:
ActionScript Code:
for(var i:int=0;i<vQuantity;i++){
ranArray.push( new Object() );
[code].......
correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:
AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
AllBrigades [0] [2].push (MyUnit);
But when I trace this I just get undefined.
I am using this script inside of a movie clip called "TILE00".loadMovie("clips.swf", slot1)Now I duplicate this movie clip usingfor(i=1;i<=1000;i++){TILE00.duplicateMovieClip("TILE0"+i, i);}Now for some reason when the movie clip duplicates, it does not keep the the file "clips.swf" loaded insideWhat happens is each copy of the movie clip loads the file all over again.This causes major lag because it has to reload the same file 1000 times!!If there any way just to keep the file loaded?It would be great if something like this was possible:This in the main timeline:loadMovie("clips.swf", holder)This inside the movie clip:loadMovie(_root.holder, slot1)So that the file only has to load once
View 4 RepliesI am trying to create a history of the actions, perhaps stored in an array, I make in flash so that I can have a button that allows the user to go back to a previous action
View 3 RepliesI'm developing an AIR application and I need to store password there so user don't have to write it everytime when he launch the application. I want to ask you if you know some way how to store the password in no plain string. I can store it in the file but everybody can read it there... Is there any way how to encrypt and then decrypt saved password?
View 2 RepliesHow To Save A Move Clip As A .jpg Or .gif File Using Actionscript
View 5 RepliesI'm developing a Flex app which is connected to a webservice - but I'm curious about what is generally best practice for handling the data locally. My webservice provides fairly small XML docs containing all the details about a certain object - is it considered better to parse that XML into objects for use in my UI, or just store the XML and access it directlyMy instincts say the former, though I'm sure doing a lot of parsing / encoding XML objects that I'm wondering if I shouldn't just add and remove elements when needed.
View 2 RepliesI get this error with the following code 1067: Implicit coercion of a value of type String to an unrelated type uint.
ActionScript Code:
main.ana.colorPickerS.addEventListener(ColorPickerEvent.CHANGE, colorChangeHandler2);
function colorChangeHandler2(event:ColorPickerEvent):void {
[code]........
Right now I have need of several 56x5 grids of very simple information (0-9) in each slot-- I am just wondering what the most space-saving/easiest way of doing this is?
I could very easily make arrays for each grid, but it would take a lot of space. In the past when I had a similar problem and a lot of time on my hands I created (by hand) png files where each pixel had a separate color based on the information in that spot. I think this is a very good space saver but is very time consuming to create..
Is there a better option? Or is there an easy way to create the png files without wasting so much time painting them by hand?
I'm getting back into AS after a few years, and it's taking a bit to get used to the syntax of AS 3.0.
Anyway, I don't know the answer to the following in AS 2.0, so I wonder if it's even possible.
Basically, I want to know if there is a way to call a variable, the name of which is stored in another variable.
How would I write something like "NextToDisappear.alpha = 0;" and have it interpreted as "MC4.alpha = 0" instead of giving an error message complaining that variables don't have alpha properties?
In other words, is there a way to make it interpret a variable as its contents and not as itself when on the left side of an equals sign? Similar to the difference between quotes and no quotes when working with the contents of text variables.
What I would like to know is, if someone has scored points on a game i'm creating - could that be stored as a "value" that could be displayed at the end of the game in another frame ?
Here's what I have at the moment
A dynamic box with the description and var of "score"
An action on a frame with the script:
score = 0;
A button that once clicked runs this action script (which adds to the score):
on (release) {
_root.score += 100;
}
Is there a way afterwards to get the total amount from "score" to be used elsewhere ?