Actionscript 3 :: Concatenate Arrays When Using Different Image Files?
Dec 6, 2011
It is possible to reference an array inside of an image file name, here's the scenario.
I have a list of images that only differ by the number at the end of the name (for example. orangeimg1.jpg, appleimg2.jpg, strawberryim3.jpg, etc. Is it possible when referencing the image that I could somehow reference the array in the file name rather than repeating the same code over and over again?
I have two different arrays set up one for fruit which has (orange, apple, stawberry) and I have another array with the numbers (1, 2, 3). I have jpg images for each of these combinations but how to I reference that in one line when I'm trying to refer to these images. I thought something like source = "[fruit].img.[number].jpg" would work
Again I've found some information on the web but it doesn't refer to how it would work if I was coding a source for my images.
View 2 Replies
Similar Posts:
Apr 7, 2010
im trying to load 7 xml files into a question array, im unsure as to whether i need 7 arrays or if i can load it into one single array. each xml file has a set of questions for a quiz i am making i have managed to load the first set of questions but i dont really know how to proceed
View 2 Replies
Jul 26, 2009
I thought ActionScripting would be easy, since I'm pretty familiar to many other Quote:
_root.myArray = [_root.zero,_root.one,_root.two,_root.three,_root.f our,_root.five,_root.six,_root.seven,_root.eight,_ root.nine,_root.ten,_root.eleven,_root.twelve,_roo
[code]........
View 0 Replies
Oct 17, 2003
I have 10 pictures (using arrays) appearing ramdomly and I need to center them (what should i use? _x, _y...). Also, I have to create one back button and one next button. what script should I apply to these buttons? Please see my script below
this.onLoad = function(){
mypictures = ["tibet.jpg", "tibet2.jpg", "camel.jpg", "forest.jpg", "einstein.jpg", "bear.jpg", "dragon.jpg", "af1.jpg", "ceppu.jpg"]
[code].....
View 1 Replies
Nov 24, 2007
How do I concatenate variable names in AS3?Something like this:
for(var i:int=0 ; i<5 ; i++) {
var "myVar"+i:Array = new Array();
}
View 5 Replies
Dec 19, 2011
I'm trying to make a tile-based AS3 game that uses PNG images as the base for maps that loads them from the library and converts the data to an array with each pixel of data being an individual tile. Essentially, if I had a 128x128 pixel PNG with say, green pixels being converted to "GRASS" in my array, I could then cycle through the array and add tiles to the map movieclip accordingly. I've looked at the ByteArray class and I can't seem to decode the data into a usable format.
View 1 Replies
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.
ActionScript Code:
var a:Array = new Array(
"a1.jpg",[code]....
View 4 Replies
Nov 25, 2008
When I use the code below the "!" never appears in the output text field. I tried removing nameInput.text and then the "!" will appear. But with nameInput.text in the code, any string I try to add after it does not appear.
View 3 Replies
May 27, 2009
How can I prevent concatenating when using the addition operator? totalCost_txt.text = (firstCost_txt.text + secondCost_txt.text)I can replace the "+" with any other operator and it works. (huh?)
View 3 Replies
Apr 6, 2011
I'm trying to make a function which ideally you tell it to go to the next level and it sorts everything out to transition to the next level for you. Currently I use this to get from level 1 to 2...
[Code]....
Also I need to make it so it checks if levelText == whatever on press of the Enter key, as well as the mouse click on GoButton.
View 2 Replies
Dec 23, 2009
I'm starting out with AS3 and migrating some old code. I have several dynamic variables in AS2 but they are using _root which isnt available in AS3.How would I go about switching the following variable to AS3? I have at least a dozen different variables similar to this one.
Code:
for (i = 0; i < (k-1); i++) {
pivot = _root["AI"+i][i][i]; // existing AS2 code
[code]......
View 3 Replies
May 26, 2010
I have this code to push "Variable1" in to MyArray:
ActionScript Code:
_root.MyArray.push(Variable1);
Note:
"Variable1" is a number stored as a string.
When "Variable1" changes, the code above is called upon to add the new "Variable1" value in to MyArray. Then I have this code which is called upon to find the sum of all the values within "MyArray":
ActionScript Code:
for (i=0; i<=_root.MyArray.length-1; i++) {
_root.MyArray_Total = _root.MyArray_Total + MyArray[i];
}
My problem is that rather than adding the values contained within MyArray (as if they were numbers), the values are being concatenated instead.
Example:
If MyArray values were 1, 2, 3
I want the MyArray_Total to = 5
But instead... MyArray_Total = 123
I tried making a new variable named "Variable1_num", declaring it as a number, making it equal to "Variable1", and then pushing "Variable1_num" in to "MyArray"... but that didnt seem to work either.
View 1 Replies
Nov 20, 2007
I'm trying to concatenate a name and variable number. Then trace it, so answer3 should output from my loaded xml data "water". Instead all I can get to trace is the word "answer3". If I type "answer3" in the trace I get the variable im looking for. If I type [this.getCorrectAnswerNumber()] in the trace I get number 3. How do I go about concatinating the word answer and a dynamic number.
Heres my code...
Code:
trace("answer"+[this.getCorrectAnswerNumber()]);
View 7 Replies
Sep 29, 2011
I have an application that I'm migrating from flex 3 to flex 4.5. In this application, there is some mx Image components that load a simple swf file (image). Spark image doesn't load swf files, so I was wondering, should I keep the mx Image, or should I change it to SWFLoader? Is there any advantages to using one or the other?
View 1 Replies
Apr 13, 2004
I went to [URL] to turn a GIF image into arrays that represent each pixel. How do I take the code that it spits back at me and display it in Flash MX?
View 2 Replies
Mar 30, 2011
The course contain ten chapters that all have to report that when a user completed them. When they all are, the status is set
to "completed" for the course. First off the theory behind it:
1. I just completed a chapter.
2. Load a string with then numbers "0,0,0,0,0,0,0,0,0,0", one for each chapter. All 0's, no chapter is completed, all 1's, all chapters are completed, you get the picture.
3. Add a 1 for, lets say chapter 5, would look like this "0,0,0,0,1,0,0,0,0,0".
4. Check if the course is complete, like this: "1,1,1,1,1,1,1,1,1,1", or not.
5. If complete, set status to "complete", if not, set to "incomplete".
In practice:
import flash.external,*;
String(ExternalInterface.call("LMSGetValue, "cmi.suspend_data, TheCourseStatus"));
String(ExternalInterface.call("LMSSetValue, //..add the number "1" to
[code]....
So, after this rant. How do I,
1. Get the string.
2. Add the course number/value to the string
3. Then update the string, and..
4. ..set the appropriate status.
I found out that "I need to concatenate them together with a delimiter so I can separate the string on re-entry", but I don't know how to do that.
View 0 Replies
Jun 29, 2008
var c = mainSubThumbs.SubThumbsHolder[materialType].subthumb_mc[id] what i have obviously doesnt work. materialType and id are my variables that I want to be added onto these mc instances..
View 9 Replies
Oct 18, 2003
I have to add one back button and one next button to my image viewer (built with arrays).what script should I apply to these buttons? what line of script should i add to my main code.
this.onLoad = function(){
mypictures = ["tibet.jpg", "tibet2.jpg", "forest.jpg", "einstein.jpg", "bear.jpg", "dragon.jpg", "af1.jpg", "ceppu.jpg"]
[code]........
View 1 Replies
Feb 11, 2009
Tag Team back again! I feel like I'm on the right track here, but I'm lacking some operative vocabulary along with a fundamental understanding of how this might work.
Some background: There's a great Quality Measures Flash app here. I'm not trying to go all out and pull from an XML to load my content - I just want to accomplish something similar, though much simpler, using the items in my library.
[Code]...
View 1 Replies
Oct 18, 2003
I have to add one back button and one next button to my image viewer (built with arrays). what script should I apply to these buttons? what line of script should i add to my main code.
this.onLoad = function(){
mypictures = ["tibet.jpg", "tibet2.jpg", "forest.jpg", "einstein.jpg", "bear.jpg", "dragon.jpg", "af1.jpg", "ceppu.jpg"]
[Code]....
View 1 Replies
Sep 19, 2010
I have a submit button that I'm pulling in from XML.
It needs to be XML because it is translated.
Therefore... the length is varying depending on the language.
I simply want to add an arrow to the end of the word using Webdings #4 (it looks like a solid arrow, not like > but solid)..
View 2 Replies
Mar 2, 2010
I have the following code in actionscript 3:
var async:AsyncToken;
async = bridge.retornamenu();
The bridge is a remote object, instantiated. The retornamenu() is the function that I want the remote object open in amfphp.
However the retornamenu() is a dynamic function, which turns another function, but I can not run it at runtime,
example
var stringfunction:String = "retornamenu()" // this name is dynamic.
var async:AsyncToken;
async = bridge.stringfunction;
But this way does not work, not perform the function retornamenu();
View 1 Replies
Jun 14, 2010
I can't for the life of me come up with anything that works...
function setCurrentCMI(id){
if (_level0.strInteraction+id==""||_level0.strInterac tion+id=="undefined") {
//does nothing, user hasn't been here yet
[code]......
View 0 Replies
Oct 4, 2006
I am trying to add a image to the container but am having problems. The image variable is loading fine but not attinching itself to the empty MC I have on the container.
[Code]...
View 5 Replies
Sep 19, 2010
I have a submit button that I'm pulling in from XML.It needs to be XML because it is translated.Therefore... the length is varying depending on the language.I simply want to add an arrow to the end of the word using Webdings #4 (it looks like a solid arrow, not like > but solid)...
View 4 Replies
Sep 19, 2010
I have a submit button that I'm pulling in from XML.
It needs to be XML because it is translated.
Therefore... the length is varying depending on the language.
I simply want to add an arrow to the end of the word using Webdings #4 (it looks like a solid arrow, not like > but solid)...
View 1 Replies
Jan 21, 2011
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.
View 1 Replies
Aug 26, 2009
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 Replies
Sep 26, 2011
I'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.
View 3 Replies
Feb 17, 2009
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].......
View 8 Replies