ActionScript 1/2 :: Trace A Random Object In An Array?
Oct 29, 2011I have a simple array[code]...
now i want to check which animal was chosen? [code]...
what do i write in the if brackets?
I have a simple array[code]...
now i want to check which animal was chosen? [code]...
what do i write in the if brackets?
I have a class in which I have declared an array. The functions in that class are designed to make changes to the array, but it's not working:
[Code]...
Anything I do to customerCheck treats it as if it were a new array. This is especially obvious when using customerCheck.push in addCharToCheck() -- the trace always shows a blank array before push and an array with one object in it after the push... then next time it does the same. I know I'm making some sort of fundamental error regarding the scope of the array within the class but I just cannot find any good information on how to fix it! Moving to AS3 (been coding it for all of about 3 weeks) is a nightmare so far, and it seems to be the 'easy' stuff that causes me problems
I am having issues with a global array. I have an actionscript file called MyGlobal.as at the same level as my main FLA:
[Code]....
I am able to trace that first element while trace is called within the function... but if I try to trace that first element outside of the function it is "undefined". Do I need to return the array at the end of the function? I tried that but I cant seem to get it working correctly.
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 need to create an array with objects when using random numbers. This is the script I have:
ActionScript Code:
if(_root.EnemyCar.hitTest(_root.kill)){
_root.EnemyCar.removeMovieClip();
var lol6 = Math.floor(Math.random()*200);
if (lol6==2){_root.attachMovie("EnemyCar", "EnemyCar", _root.getNextHighestDepth(), {_x:74, _y:-100})};
if (lol6==1){_root.attachMovie("SwatVan1", "SwatVan1", _root.getNextHighestDepth(), {_x:114.9, _y:-45})};
if (lol6==0){_root.attachMovie("OilTanker", "OilTanker", _root.getNextHighestDepth(), {_x:74, _y:-250})};
}
As you can see the random number is from 0-250, I want to be able to have enemycar spawning from 2-20 and other movie clips spawning from 20-40 etc.
I think it would be simplest to explain it like this:
[Code]...
I'm trying to trace the path of an object by using setPixel on the object's position every frame in a BitmapData/Bitmap pairing. These pixels aren't showing up normally and I suspect I have a fundamental misunderstanding of the BitmapData class. Here's what I'm doing:
public var contrailBase:BitmapData;
public var contrail:Bitmap;
private var contrailColor:uint;[code].....
Using this code, the red pixels don't show up. If I initialize contrailBase to 0xFF000000 instead then I get a black screen on which the red pixels DO draw, but I need the bitmap to be transparent except for the contrail. What am I doing wrong?
I want a movieclip consisting of a dynamic text box that, from the time it's loaded onto the stage, loads a randomly selected text string from an array, and continues to loop until the clip is removed from the stage. I also want the text strings to appear in the text box for random intervals between 500 and 3000 milliseconds.
While I've found tutorials here and elsewhere on loading one element from an array, usually triggered by a button, I don't know how to combine/alter it with the other elements.So I want this movieclip on the stage randomly flashing phrases from an array, some for a barely perceptible time, and others for a readable time.
I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.
Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded
how do i do the following correctly?
Code:
var myArray:Array = [a,b,c,d,e,f];
trace(myArray._name);
[code].....
I have a array where I put the products id and the amount of that same product in it.when I trace the cart array, flash walks trough all the keys (from 0 to 23443) and that takes a long time.Is there a other way to do it? like this maybey:[code]How can you trace the key of an array in AS?
View 1 Repliesbelow code is array for my combo box's data. Now I would like to trace this array. I could not trace of any data of "zone" Object. How we can trace any value of this type of array ?
var zone:Array=[
{label:"Nepal", data:"1:00"},
{label:"China", data:"2:00"},
{label:"Bhutan", data:"3:00"}
];
I am undergoing some experiments on creating object arrays before I attempt to implement it on my main flash document.
Ive created an object array with 3 variables, and im attempting to change the values, then trace the values back to see if its working. Ive tried many things but I keep getting [object: Object] back in the output window.[code]...
I copied some code over to a similar function, which traces out the array index number using indexof(e.target).For some reason I'm getting the usual undefined property errors, but it is tracing other properties in the array using e.target?[code]
View 9 RepliesI am trying to trace out the contents of an array, my code is this.
Code:
var shortArray:Array = shuffle[newNumber,35];
trace (shortArray);
the error is:
1120: Access of undefined property shortArray.
I have this code working which has an XML file. This is the code for XML menu(no drop down) for website , i am working on, but i wonder when i traced the value of both arr2 & arr1 it returns 0, although i pushed the value.[code]
View 2 RepliesI'm working through some tutorials from my instructor to eventually build a simple e-com website for a state park. Basically, I'm using the two as3 files shown below and trying to get "bob" in my output with an array function and trace. Load store function is intentionally coded out. When I test project, nothing comes up in output, and I have no errors.
Main012.as:
package {
import flash.display.MovieClip;
public class Main012 extends MovieClip {
public function Main012() {
[Code] .....
I have a question i need to get the length of an array but outside the onLoad()
here is my code:
var O:XML = new XML();O.ignoreWhite = true;O.onLoad = function(success) {
var photos:Array = this.firstChild.childNodes; _root.PanelH = photos.length*200; trace(PanelH);};trace(PanelH);O.load("VideosBank.xml");
The Action script code below takes the strings in the array (pgtit) and creates a dynamic navigation bar I am trying to trace the index number of the array being click I just seem to get -1.
var pgtit:Array=["link1","link2","link3","link4"];
var xPos = 0;
var menuHolder:MovieClip = new MovieClip;
addChild(menuHolder);
[code]....
I am having a color array with values like 0x2EFE2E, 0xFFFF00, etc. but when i am trying to trace the values in the array, it prints something else like 95455. I think these are some converted values. But i tried using parseInt(val, 16), uint(val). None of these works. Basically, i just want to take values from this array and assign it to particleColor (a uint) and use like this:
[Code]....
I've got some xml that I want to use to populate the labels on an array of buttons that I'm putting in with attachMovie. the button(s) load (well, the first one does) and I've got a trace statement that shows the exact data I want in the button labels. But the numbers just refuse to appear in the button labels.the labeling is correct; I've been looking at this for three days and checked the path and naming at least a dozen times.
Code:
for(i=0; i<total; i++){
patMenuHolder_mc.attachMovie("patentBtn", "patentBtn"+i, i, {_x:xPos, _y:yPos})
[code]....
I'm not sure if this is at all possible, but I've been trying this for hours with no prevale. I can only presume I'm over complicating things.
I've generated a awkward looking string using variables, and arrays:
Code:
var someVar:string = "hello";
var myArray:Array = new Array("test0", "test1", "test2");
var myString:string = someVar+"World_"+myArray[2]);
[Code].....
i feel like i've done this 100 times before, im not sure why it isnt working now
for each
(var HH3 in Stat) {
trace(Stat[HH3]+"="+HH3)
}
what i want to do is trace to show the Key And Value pairs of the array
Ive been trying to get this piece of code to work
[Code]..
But the trace always comes out to be undefined. Also, I have searched, and the basis for that code is (working) code from one of the results I found when I searched
how to trace all properties of an Object regardless of data type?
View 4 Replieshow to display item name in object. I have got object and i would like to get its child but i don`t know name of that item. So i thought that i may trace that name but i don`t know how.
View 1 RepliesHow do you trace the location of a object?
View 2 RepliesIs there something that will let me trace all of an object's properties? (and wow typing the message before coming up with a title makes a difference)
View 1 RepliesIs this possible? I need to add a Click event to a button (actually several) in a swf that I've loaded. Is this possible? I'm currently trying to trace the objects but getting nowhere.
View 5 RepliesI have an array that I want to shuffle but at different percentages. Like "Hello" would show up 80% in the Output window. "Bye" would show the other 20% of the time. How do I do this?
Code:
var myArray:Array = new Array("Hello", "Bye");
function randomIt()
{
[code]....