Looping An Array
I'm pretty new to arrays and apparently I'm completely lost as to how to loop an array..
Below I have an array of 6 movieclips I want to respond as buttons with what i thought would be the right way to loop em. Below that, in the exclaimed code, is what does work when each button is written individually.
What am i doing wrong?
Code:
var btns = [btn1, btn2, btn3, btn4, btn5, btn6];
function rollover(arr){
len = arr.length;
for(var r=0; r<len; r++){
arr[r].onRollOver = function () { arr[r].gotoAndStop(2);}
arr[r].onRollOut = function () { arr[r].gotoAndStop(1);}
}
}
rollover(btns);
/*
btn1.onRollOver = function () { btn1.gotoAndStop(2);}
btn2.onRollOver = function () { btn2.gotoAndStop(2);}
btn3.onRollOver = function () { btn3.gotoAndStop(2);}
btn4.onRollOver = function () { btn4.gotoAndStop(2);}
btn5.onRollOver = function () { btn5.gotoAndStop(2);}
btn6.onRollOver = function () { btn6.gotoAndStop(2);}
btn1.onRollOut = function () { btn1.gotoAndStop(1);}
btn2.onRollOut = function () { btn2.gotoAndStop(1);}
btn3.onRollOut = function () { btn3.gotoAndStop(1);}
btn4.onRollOut = function () { btn4.gotoAndStop(1);}
btn5.onRollOut = function () { btn5.gotoAndStop(1);}
btn6.onRollOut = function () { btn6.gotoAndStop(1);}
*/
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 02-06-2007, 09:34 PM
View Complete Forum Thread with Replies
Sponsored Links:
Looping Through Array
I have a very large array that I need to loop through. I need to perform specific actions for each item in the loop depending on its content. Currently I am using a For....In loop but this gives me the warning message: A script in this movie is causing your computer to run slowly. If it continues your computer may become unresponsive. Would you like to abort the script? (or something to that effect)
If I continue the script it eventually finishes. However I would like to know if any one can think of a better way that is slightly less computer intensive.
Any ideas? Thanx.
View Replies !
View Related
Array Looping
Hi,
instead
code:
myData=new Array(["text", b+i, p-i, 1972, "someTxt"+i, "text2"+i],
["text", b+i, p-i, 1972, "someTxt"+i, "text2"+i],
["text", b+i, p-i, 1972, "someTxt"+i, "text2"+i]);
i would like to know how is possible to produce same thing but in loop; i.e.
code:
for (i=1; i<24; i++){
myData=new Array(["text", b+i, p-i, 1972, "someTxt"+i, "text2"+i]);
}
i assumed and i'm pretty sure that i made misstake but if someone find useful to help me, i would be very pleased.
Thanks in advance
View Replies !
View Related
Array Looping
Hello
I have the following problem. I have 2 array's. One with customer names and another one with customervalue's. This code loops over the array with customers and shows for each customer a graph (that moves from left to right till _width is 99).
In the second array i have the customer value's that must be the total width of the customer. So customer "klant1" must have a final _width of "100" (see array's) and customer "klant2" a _width of "40" and so on for each customer.
The code now says that each graph has a _width of 99 and then stops. But this must be variable to the array. Can anybody help me with this.
Code:
// array aanmaken met klanten
var grafieken = new Array("klant1", "klant2", "klant3", "klant4", "klant5", "klant6", "klant7", "klant8", "eikel");
// array aanmaken met aantal stemmen voor klanten
var stemmen = new Array("100", "40", "60", "10", "70", "30", "30", "50", "90");
makeGraph(0, 0, 1, "grafiekje");
function makeGraph(mainx, mainy, mainDepth, attachMC) {
this.createEmptyMovieClip("graph", 1);
var count = 0;
graph._x = mainx;
graph._y = mainy;
// over array loopen en movieclip dupliceren
for (g=0; g<grafieken.length; g++) {
graph.attachMovie(attachMC, "grafiek"+grafieken[g], count);
oCount = graph["grafiek"+grafieken[g]];
with (oCount) {
_width=1;
_height=10;
_x = Stage.width /2;
_y = (count % 16)*25;
count++;
}
}
// over array heen loopen en breedte meegeven aan movieclips
for (g=0; g<=grafieken.length; g++) {
graph["grafiek"+grafieken[g]].onEnterFrame = function() {
if (this._width <= 99) {
this._width += ratio;
if (this._width > 100) {
trace("Maximum is bereikt");
}
}
}
}
}
View Replies !
View Related
Array Looping
Hi
i have 3 arrays created called itemArray_1, itemArray_2, itemArray_3
I would like to loop through these arrays, however, im first looping to get the name of the array to loop thgouh. eg....
ActionScript Code:
for (var i:uint = 1; i < 4; i++) {
var testArray:Array = 'itemArray_' + i;
trace(testArray);
}
Im getting a data type error, it says that the testArray is a string. How can i ge tthe testArray to act as an array
View Replies !
View Related
Looping An Array
Hi, I'm trying to make my selection of pizza toppings go accross the screen by looping them via an array. I've tried alsorts, just not entirely sure what I'm doing. It works as a trace, just not sure how to get it on my document.
Any help is appreciated.
Code:
var toppings:Array=new Array("Pepperoni","Meatfeast","Margarita","Ham & Pineapple","Chicken")
for(var i:int=0; i<toppings.length; i++){
trace(toppings[i]);
}
View Replies !
View Related
XML, Looping Through An Array
I have an XML document that loading into Flash. I have a dynamic text box on the stage that I am writing the XML to. My problem is, I have 6 group names that I am pulling from my XML file and I want to write each one of them to the text box and add a line break to the end. This is my code:
var group= this.firstChild.firstChild.childNodes;
for (var i=2; i<group.length; i++){
divBox['divInfoLinks'].htmlText = this.firstChild.firstChild.childNodes[i].attributes.name;
}
When I trace [i] it lists all 6 names, however my text box only shows the last name in the array. Any thoughts?
View Replies !
View Related
Want To Get Feedback About Looping Through An Array
Hi,
I have an array of about 3000 numbers that are used to work out a graph. The script loops through these numbers and keeps drawing lines to the next points.
Because this is all in one loop the graph appears instantly once all the lines have been drawn by the player. Because it is so large this can take about 30 - 60 seconds and in the future these arrays might be larger than 3000. So I would like to give some feedback about how far through the array the player has got but I can't figure out how to.
I was going to create a progress bar whose length is dependent on the array.length, but then I realised that, along with the graph of points won't update until the very end when the frame is rendered so will jump from 0 to 100% and won't be any use.
Is there a way I can get the progress reported without slowing down how fast flash goes through the array? (ie. I don't want to just loop through the array at the frame rate because it would be really slow).
Any ideas much appreciated
Robin
View Replies !
View Related
More XML Issues-array Looping...
The files are here:
*http://www.daveglanzproductions.com...cs-problem1.fla
*http://www.daveglanzproductions.com/xml/pics.xml
The first frame of code sets up the XML and creates an array of thumbnails, and pushes values into a "jpeg_arr":
code: loaded = false;
jpeg_arr = new Array();
picxml = new XML();
picxml.ignoreWhite = true;
picxml.onLoad = function(success) {
if (success) {
parseXmlDoc(this);
} else {
trace('xml screw up!');
}
};
//thumbnails:
//THIS CODE CREATES THE THUMBNAILS BY CREATING TWO
//EMPTY MOVIECLIPS.
function parseXmlDoc(xmlDoc) {
if (xmlDoc.loaded) {
//LENTH OF XML:
_global.xmlLength = xmlDoc.firstChild.childNodes;
this.createEmptyMovieClip("targetClip", 0);
for (i=0; i<xmlLength.length; i++) {
//populate the thumbnails
xmlThumb = xmlDoc.firstChild.childNodes[i];
imagePath = xmlThumb.attributes.thumbURL;
selectedThumb = targetClip.createEmptyMovieClip("tmb" + i, i);
selectedThumb.loadMovie(imagePath);
selectedThumb._alpha = 0;
selectedThumb._y = yPos;
yPos += 52;
//JPEG ARRAY IS CREATED BASED ON THE JPEG ATTRIBUTE IN EACH NODE
jpeg_arr.push(xmlThumb.attributes.jpegURL);
//trace(jpeg_arr);
}
//THIS IS JUST A LOAD CHECKER
if (this._framesloaded >= this._totalframes) {
loaded = true;
} else {
loaded = false;
}
}
}
picxml.load("pics.xml");
On frame 5, the code loads the files and defines a function for onPress. I've tried to add a "next" and "previous" function here, but my syntax is screwy. I could use help:
code:
//IF LOADED, THE MOVIE GOES TO FRAME 6 AND LOADS THE FILES:
if (loaded) {
stop();
//LOOP THROUGH ALL NODES, CHOOSE THUMBNAIL TO PRESS...
for (i=0; i<xmlLength.length; i++) {
selectedThumb = this.targetClip["tmb" + i];
selectedThumb._alpha = 100;
selectedThumb.num = i;
selectedThumb.onPress = function () {
//THUMBNAIL INDEX 0 WILL LOAD BIG FILE INDEX O, ETC ETC:
imageClip.loadMovie(jpeg_arr[this.num]);
}
}
} else {
gotoAndPlay(1);
}
//HELP!
_global.next = function() {
nextNode = [i];
if (nextNode > 1) {
for (i=0; i<xmlLength.length; i++) {
nextNode = i;
nextNode++
imageClip.loadMovie(jpeg_arr[nextNode]);
}
}
trace(nextNode);
}
nextBtn.onRelease = function() { next(); };
//prevBtn.onRelease = function() { prev(); };
//set properties of scroll area:
targetClip._x=3;
imageClip.loadMovie(jpeg_arr[0]);
Thanks!
View Replies !
View Related
[F8] URGENT Looping Through Array
SHORT DESCRIPTION:
I have 5 cards on the stage (named plocica0 to plocica4) and dynamic text (named pojam) in each.
Also, I have 3 different arrays (named niz1, niz2, niz3) with sentences. I want to populate these cards with sentences from the arrays but without repeating them - meaning each card should have different sentence inside.
The problem is that from time to time the mentioned repeating occurs.
My code:
PHP Code:
var niz1 = Array("Volim te.","Ljubavi moja.","Ti si zečić.","Danas je lijepi dan.");var niz2 = Array("Jučer je bilo lijepo.","Sutra je ponedjeljak.","Ti znaš plivati?","Danas radim.");var niz3 = Array("Dusche dich am Vormittag nicht!","Zeko piše.","Mario fotografira.","Mačke spavaju.");function chooseSentences() { var chosenSentences = new Array();//container for chosen sentences var chosenIndex = new Array(); var chosenArrElement:Object = new Object(); for (var i = 0; i < 5; i++) { var chooseArr = random(3) + 1; var chooseElement = random(4); chosenSentences[i] = this["niz" + chooseArr][chooseElement]; trace("chosenSentences original: "+chosenSentences[i]); var j = 0; while (j < i) { if (chosenSentences[i] == chosenSentences[j]) { do { var popped:Object = chosenSentences.pop(); trace("popped: "+popped); chooseArr = random(3) + 1; chooseElement = random(4); chosenSentences[i] = this["niz" + chooseArr][chooseElement]; trace("chosenSentences new choice: "+chosenSentences[i]); } while (chosenSentences[i] == chosenSentences[j]); } else { j++; } } //end while (j<i) chosenArrElement.array = chooseArr; chosenArrElement.element = chooseElement; chosenIndex[i] = [chosenArrElement.array,chosenArrElement.element]; } trace("final: "+chosenSentences); trace("chosenIndex: "+chosenIndex); //writting into cards: for (var k = 0; k < chosenSentences.length; k++) { _root["plocica" + k].pojam = chosenSentences[k]; } } // End of functionstop();onLoad = function() { chooseSentences();}
View Replies !
View Related
Looping Through An Array (.fla Attached)
On a scale of 1 to confused... I am dumbfounded
attached is my .fla for generating a number of test baddies whom upon entering the screen move to the left. however...
I need them to check the screen when they move to see if they collide with anything else on the screen... I think you will understand better when you see the code.
Please help me!
View Replies !
View Related
Looping Through Array With Buttons
I'm new here so a big hello to you all!
I've started to learn actionscript by building a media player. It will have four buttons to link to each movie plus forward and rewind buttons to allow a user to loop through each film. I was told to look into arrays and found this tutorial at webwasp. This tut has almost everything I need to create this functionality but when I combine it all I get weird behaviour with my forward and backward buttons at times where they move backwards before stepping forwards or vice versa. Can anyone offer me any insight into where I'm going wrong?
Code below and sample file can be found here.
PHP Code:
var myArray = new Array();
myArray[0] = "this is the first movie";
myArray[1] = "this is the second movie";
myArray[2] = "this is the third movie";
myNumber = 0;
forward.onRelease = function() {
// Set myText to the same as myNumber in the Array
myText = myArray[myNumber];
// If myNumber is 2 then...
if (myNumber == 2) {
// Reset myNumber to zero
myNumber = 0;
// Otherwise...
} else {
// Add one to myNumber
myNumber = myNumber+1;
// Close the if-else statement
}
// Close the on(release) statement
};
rewind.onRelease = function() {
// Set myText to the same as myNumber in the Array
myText = myArray[myNumber];
// If myNumber is 0 then...
if (myNumber == 0) {
// Reset myNumber to 2
myNumber = 2;
// Otherwise...
} else {
// Add one to myNumber
myNumber = myNumber-1;
// Close the if-else statement
}
// Close the on(release) statement
};
btn1.onRelease = function() {
myText = myArray[0];
myNumber = 0;
};
btn2.onRelease = function() {
myText = myArray[1];
myNumber = 1;
};
btn3.onRelease = function() {
myText = myArray[2];
myNumber = 2;
};
Many thanks,
jbw
View Replies !
View Related
Looping Array Of Webcams
Hi everyone,
I've been working on this small project and now I've hit a wall.
I want to take a still from a web cam every second or so, have the stills move downwards to the bottom of the stage, getting smaller as it does so. And for this to continue infinitely. An easy way to see it is by imagining an escalator, the stills would be the steps.
Like this:
Code:
"snapshot" appears here and captures still from webcam
------------ <--top of stage
"snapshot" moves down
down
down
down
------------ <-- bottom of stage
"snapshot" is disposed of or moves to the top where the loop continues
So far I have 10 movie clips with BitmapData from the webcam drawn into them and they loop from top to bottom. But, they all display the same image, which is just a copy of the moving web cam output.
This is what i have so far
http://members.optusnet.com.au/quasa...ebcam_loop.fla
Code:
output.attachVideo(Camera.get());
import flash.display.BitmapData
import flash.geom.Matrix
var maxElements:Number = 10 ;
var theArray:Array ;
theArray = new Array(maxElements) ;
var yvArray:Array ;
yvArray = new Array(maxElements) ;
var bit:MovieClip;
var snapshot:BitmapData=new BitmapData(output._width,output._height);
function takeSnapshot()
{
m=new Matrix()
m.scale((output._xscale/100),(output._yscale/100))
snapshot.draw(output,m)
}
var bit;
// create the movie clips
for (var i:Number = 0 ; i < maxElements ; i++){
bit = createEmptyMovieClip("bit"+i,i,this.getNextHighestDepth());
bit.attachBitmap(snapshot,0);
bit._x = 115;
bit._y = i * -142;
theArray[i] = bit;
yvArray[i] = 10;
}
onEnterFrame = function () {
//begin scrolling down
for (var i:Number = 0 ; i < maxElements ; i++) {
theArray[i]._x += xvArray[i] ;
theArray[i]._y += yvArray[i] ;
if (theArray[i]._y < -30) {
this.takeSnapshot()
}
if (theArray[i]._y > 150) { //shrink in size here
theArray[i]._yscale = 99;
theArray[i]._xscale = 99;
theArray[i]._x = 116;
}
if (theArray[i]._y > 298) { //shrink in size here
theArray[i]._yscale = 98;
theArray[i]._xscale = 98;
theArray[i]._x = 118;
}
if (theArray[i]._y > 445) { //shrink in size here
theArray[i]._yscale = 97;
theArray[i]._xscale = 97;
theArray[i]._x = 120;
}
if (theArray[i]._y > 591) { //shrink in size here
theArray[i]._yscale = 96;
theArray[i]._xscale = 96;
theArray[i]._x = 122;
}
if (theArray[i]._y > 735) { //shrink in size here
theArray[i]._yscale = 95;
theArray[i]._xscale = 95;
theArray[i]._x = 124;
}
if (theArray[i]._y > 877) { //shrink in size here
theArray[i]._yscale = 95;
theArray[i]._xscale = 95;
theArray[i]._x = 126;
}
if (theArray[i]._y > 1018) { //shrink in size here
theArray[i]._yscale = 95;
theArray[i]._xscale = 95;
theArray[i]._x = 115;
}
if (theArray[i]._y >= Stage.height ) {
theArray[i]._y = -187 ; //start from the top again
theArray[i]._x = 115;
theArray[i]._yscale = 100;
theArray[i]._xscale = 100;
}
}
}
Any help will be greatly appreciated.
Q
View Replies !
View Related
Creating An Array Of Var's And Looping Through Them
Hi,
i have a few buttons each with a dynamic text fields.
i have a var for each field determining its name, for example:
Code:
_root.restaurants_list_1;
_root.restaurants_list_2;
_root.restaurants_list_3;
i have dynamic external data, that according to it i want the buttons to be named. for example
_root.restaurants_name_1 = "Chinese";
i put the vars into an array
Code:
var rs_bt_name:Array = [_root.restaurants_list_1, _root.restaurants_list_2, _root.restaurants_list_3];
and the external data into an array
Code:
var Restaurants_names:Array = ["Chinese", "Italian", "French"];
and i want to loop through the arrays to assign the values to the dynamic text field
Code:
function buttons_names(){
for(var i:Number=0; i<_root.rs_bt_name.length; i++){
_root.Restaurants_names[0] = _root.rs_bt_name[0];
}
}
its not working, my guess is i need to define the var array as a var array some how.
help anyone ?
thanks
View Replies !
View Related
Looping Through An Array Of Functions.
Hello.
I have four functions which move movieclips using the Tween library. I want to be able to loop through these, so pressing one button over and over will make the functions run (0, 1, 2, 3, 0, 1, 2, 3 etc).
I looked into for loops but can't find a way to make it run the functions in a loop upon a key press. Can anyone help?
Regards, A.
View Replies !
View Related
Array With Looping Problem
Have been trying to solve this problem for quite some time and so hope anyone could give me a guidance how it can be done.
I have an array that contain around 5 different hats. I will have a button to click whereby it will keep changing the different 5 hats on the stage.After that, i have another button which will dulpicate the hats that is on the stage.
Thank you in advance..
View Replies !
View Related
Array Values Looping
Ok heres what im trying to do:
Thes + and - buttons next to a stake box, an array called incrementArray which contains 26 values i.e. 0.10 , 0.20, 0.30 , now what im trying to do is code it so that when the button is pressed either + or - , and the user has entered a value in the box, the value is checked and the incrementor starts so that the 1st value is higher than the one in the box, or lower is the decrementor is pressed instead of blindly starting from 1 no matter what is entered.
Example:
what i want:
I enter £1.00 into box, press + button. amount goes upto £1.50
At the moment:
I enter £1.00 into box, press + button. amount goes to £0.10 ( the first array value)
box is called = root.mainWin.betWin.pBet0
array is called = incrementArray
This is only the increase stake function , once the code is done for this its just a case of copy +past into decrease stake function.
function increaseStake()
{
// loop through array values
for (i=0;i<_root.incrementArray.length;i++)
{
// trying to check that the current array value is lower than the stake box
//amount and that the next array value is higher than the stake box amout.
//in which case the next value should be used as the 1st increment value.
if (_root.mainWin.betWin.pBet0>_root.incrementArray[i] && _root.mainWin.betWin.pBet0<_root.incrementArray[(i+1)])
{
// set stakebox to = the array value which is more than the current stake
_root.mainWin.betWin.pBet0 =_root.incrementArray[(i+ 1)];
}
}
--------
thanks
-arran
View Replies !
View Related
Looping Array Problem
i'm having a mental block here. i think this is simple but i can't figure it out. what i have is a few variable being passed in from a database. the for of these variables looks like this:
direct1clips=one.jpg|two.jpg|three.jpg
direct2clips=one2.jpg|two2.jpg|three2.jpg
etc.
i just want to loop through all of these variables and put them into arrays. this is what i'm trying but it's not working. n is coming from the database two and is the number of elements(n gets used in other places in the movie). ideas?
for (var i =1; i <=(n); i++){
arraytemp="direct"+i+"array";
arraytemp="direct"+ i + "clips".split("|");
}
View Replies !
View Related
Looping FLVs From An Array
This was modified from an earlier project and this was meant to loop, but also still be navigable, should someone walk up to this computer/kiosk and want to manually "drive" the presentation; otherwise it just loops through the array of FLVs. As usual I know I'm missing one small obvious piece and I can't seem to nail it down. Any help pointing out what should be the obvious would be greatly appreciated!
Attach Code
//------VAR and FLV ARRAY SETUP-------------------
var myInterval:Number;
var videoURL_ary:Array=["chapter1.flv","chapter2.flv","chapter3.flv","chapter4.flv","chapter5.flv","chapter6.flv"];
var amountOfSeconds:Number = 1000;
//------NETCONNECTION SETUP--------------------
var nc:NetConnection = new NetConnection();
nc.connect(null);
var myCurrentScene:Number;
//------NETSTREAM SETUP--------------------
var ns:NetStream = new NetStream(nc);
ns.onStatus = function(info) {
trace(info.code);
if(info.code == "NetStream.Play.Start") {
mcEPNBG._visible = false;
btnPlay._visible = false;
btnEPN._visible = false;
}
if(info.code == "NetStream.Play.Stop") {
myInterval=setInterval(gotoNextScene,amountOfSeconds);
}
}
ns.onMetaData = function(info) {
ns.duration = info.duration;
}
//------ATTACHING NETSTREAM--------------------
video.attachVideo(ns);
//------BUTTON CONTROLS--------
btnPlay.onRelease = function()
{
ns.play("chapter1.flv");
myCurrentScene = 0;
}
btnBack.onRelease = function()
{
gotoPrevScene();
trace(myCurrentScene);
}
btnNext.onRelease = function()
{
gotoNextScene();
trace(myCurrentScene);
}
//-----Buffer------
netStream_ns.setBufferTime(60);
//--------GO TO NEXT SCENE-------
function gotoNextScene(){
myCurrentScene++;
clearInterval(myInterval);
if (myCurrentScene<6)
{
ns.play(videoURL_ary[myCurrentScene]);
}
if (myCurrentScene>6)
{
ns.play(videoURL_ary[0]);
}
/*else
{
ns.pause(true)
}*/
}
//--------GO TO PREV SCENE-------
function gotoPrevScene(){
myCurrentScene--;
clearInterval(myInterval);
if (myCurrentScene>=0)
{
ns.play(videoURL_ary[myCurrentScene]);
}
if (myCurrentScene < 0)
{
ns.play(videoURL_ary[6]);
}
else
{
ns.pause(true)
}
}
//------PLAYPAUSE TOGGLE--------
mcPlayPause.onRollOver = function() {
if(this._currentframe == 1) {
this.gotoAndStop("pauseOver");
}
else{
this.gotoAndStop("playOver");
}
}
mcPlayPause.onRollOut = function() {
if(this._currentframe == 10) {
this.gotoAndStop("pause");
}
else{
this.gotoAndStop("play");
}
}
mcPlayPause.onRelease = function() {
if(this._currentframe == 10) {
this.gotoAndStop("playOver");
ns.pause(true);
}
else{
this.gotoAndStop("pauseOver");
ns.pause(false);
}
}
View Replies !
View Related
Looping Text Array
The problem is with the text array. I goes through once just fine but the second time through it loads twice. What's the deal?
Attach Code
stop();
#include "com/unwork/tween.as"
var txtArray:Array = ["ONE", "two", "THREE", "four", "FIVE"];
// Text
switchTxt = function (id) {
this.attachMovie('txtholder','txtholder'+id,this.getNextHighestDepth());
eval('txtholder'+id).txtdisplay = txtArray[id];
var oldid:Number = id-1;
eval('txtholder'+oldid).play();
trace(eval('txtholder'+oldid));
};
// Slideshow
var data:Array = ["images/homesplit/slide_1.swf", "images/homesplit/slide_2.swf", "images/homesplit/slide_3.swf", "images/homesplit/slide_4.swf", "images/homesplit/slide_5.swf"];
// assign dataProvider
slider1.dataProvider = data;
// set the effect transition duration
slider1.duration = 1200;
// start slideshow (timeout between images, repeat images)
slider1.start(900,true);
// listeners
var mainListener:Object = new Object();
slider1.addListener(mainListener);
// dispatched when a new transition is being played
mainListener.transitionInStart = function(target:MovieClip) {
trace('transitionInStart: '+target._name+', index: '+target.selectedIndex);
//switchTxt(target.selectedIndex);
};
// dispatched when slideshow has completed
// only then repeat is set to false
mainListener.finish = function(target:MovieClip) {
trace('finish: '+target._name);
};
View Replies !
View Related
Please Help. Array - Looping Problem.
Origional
ActionScript Code:
allLinks.push(new Link(s1[0], s1[1], s1[2], s1[3]));allLinks.push(new Link(s2[0], s2[1], s2[2], s2[3]));// seems to be a pattern here ??, would be nice to loop this.....
etc.....
My attempt to try to simplify this problem
ActionScript Code:
for(i=0;i<5;i++){ addNew = (new Link(s+i[0], s+i[1], s+i[2], s+i[3])); allLinks[i]= addNew;}
I would like to populate 'allLinks' with objects 's'. However I have been unsuccessfull in my attempts. I need this loop to work for a a large number of items so I dont really want to have to add each individual item.
I have no more ideas, i've tried just about everything I know. Even checked out these forums for this type of problem, with no luck.
I would like to make it as simple as possible.
Thanks in Advance.
Anthony - BVision.
View Replies !
View Related
Stop The Looping Of An Array
How can i stop this array from looping. I just want the images to fade in once then stop after theyre done.
import mx.transitions.Tween;
import mx.transitions.easing.*;
var mc_arr = [num_mc1,num_mc2,num_mc3];
var counter = 0;
function tweenIn(target_mc:MovieClip){
var image1_a:Tween = new Tween(target_mc, "_alpha", Regular.easeIn, 0, 100, 1, true);
image1_a.onMotionFinished = function() {
counter = (counter < mc_arr.length-1) ? counter+1 : 0;
tweenIn(mc_arr[counter]);
};
}
tweenIn(mc_arr[counter]);
View Replies !
View Related
[F8] URGENT Looping Through Array
SHORT EXPLANATION:
I have 5 cards on the stage (named plocica0 to plocica4) and dynamic text (named pojam) in each.
In code, I have 3 different arrays (named niz1, niz2, niz3) populated with sentences. I've created a function which have to populate these cards with sentences from given arrays but without repeating them - meaning each card should have different sentence inside.
I need next procedure (if possible):
- choose five sentences (one by one) from given arrays (without changing them)
- push them into new array
- then, if possible, while populating new array with sentences, compare them - in my function I've tried to create a procedure of comparsion in a way of pushing the last chosen sentence into array and then, with a counter, loop through previous sentences in that array and if found two same sentences, delete last one and repeate the procedure of choosing as long as they are the same
- the whole procedure of choosing sentences should last as long as all five of them aren't different
My code:
PHP Code:
var niz1 = Array("Volim te.","Ljubavi moja.","Ti si zečić.","Danas je lijepi dan.");var niz2 = Array("Jučer je bilo lijepo.","Sutra je ponedjeljak.","Ti znaš plivati?","Danas radim.");var niz3 = Array("Dusche dich am Vormittag nicht!","Zeko piše.","Mario fotografira.","Mačke spavaju.");function chooseSentences() { var chosenSentences = new Array();//container for chosen sentences var chosenIndex = new Array(); var chosenArrElement:Object = new Object(); for (var i = 0; i < 5; i++) { var chooseArr = random(3) + 1; var chooseElement = random(4); chosenSentences[i] = this["niz" + chooseArr][chooseElement]; trace("chosenSentences original: "+chosenSentences[i]); var j = 0; while (j < i) { if (chosenSentences[i] == chosenSentences[j]) { do { var popped:Object = chosenSentences.pop(); trace("popped: "+popped); chooseArr = random(3) + 1; chooseElement = random(4); chosenSentences[i] = this["niz" + chooseArr][chooseElement]; trace("chosenSentences new choice: "+chosenSentences[i]); } while (chosenSentences[i] == chosenSentences[j]); } else { j++; } } //end while (j<i) chosenArrElement.array = chooseArr; chosenArrElement.element = chooseElement; chosenIndex[i] = [chosenArrElement.array,chosenArrElement.element]; } trace("final: "+chosenSentences); trace("chosenIndex: "+chosenIndex); //writting into cards: for (var k = 0; k < chosenSentences.length; k++) { _root["plocica" + k].pojam = chosenSentences[k]; } } // End of functionstop();onLoad = function() { chooseSentences();}
View Replies !
View Related
Please Help. Array - Looping Problem.
Origional
ActionScript Code:
allLinks.push(new Link(s1[0], s1[1], s1[2], s1[3]));allLinks.push(new Link(s2[0], s2[1], s2[2], s2[3]));// seems to be a pattern here ??, would be nice to loop this.....
etc.....
My attempt to try to simplify this problem
ActionScript Code:
for(i=0;i<5;i++){ addNew = (new Link(s+i[0], s+i[1], s+i[2], s+i[3])); allLinks[i]= addNew;}
I would like to populate 'allLinks' with objects 's'. However I have been unsuccessfull in my attempts. I need this loop to work for a a large number of items so I dont really want to have to add each individual item.
I have no more ideas, i've tried just about everything I know. Even checked out these forums for this type of problem, with no luck.
I would like to make it as simple as possible.
Thanks in Advance.
Anthony - BVision.
View Replies !
View Related
OnPress Looping Through Array
Hey Ultrashockers, I could use help with a seemingly simple problem.
I have a series of buttons in an array calling a custom function:
ActionScript Code:
buttons[0].onPress = function() {
chooseCont(0);
};
buttons[1].onPress = function() {
chooseCont(1);
};
buttons[2].onPress = function() {
chooseCont(2);
};
I want to use a loop, instead of typing every button out:
I tried this:
ActionScript Code:
for(var i=0; i<buttons.length; i++){
buttons[i].onPress = function() {
chooseCont(i);
}
}
...but it's not working. Any ideas on what I'm doing wrong?
View Replies !
View Related
Please Help - Looping Through An Array, Duplicate
Hey all -
would anyone be so kind as to have a look at this code? Probably something simple I'm just not seeing.
/*mbNav is a var declared on previous frame, loading variables from a txt file called MindblazerVars.txt.
Two lines below load the nav variable and navURL variable into arrays.
*/
var mbNavItem = mbNav.nav.split(",");
var mbNavURL = mbNav.navURL.split(",");
/*
Loop through the mbNavURL array; duplicate a movie clip on the stage called "google," containing
a dynamic text field named "nav_txt" and a movie clip named "boing" for each iteration. "Boing"
is the movie clip that acts as the button to go to the mbNavURL value
*/
for(i=0;i<mbNavURL.length;i++) {
//trace(mbNavURL[i]);
_root.google.duplicateMovieClip("nav"+i,i);
_root["nav"+i]._x = _root["nav"+i]._x + (i*100);
_root["nav"+i].nav_txt.text = mbNavItem[i];
//trace(mbNavURL[i]);
_root["nav"+i].boing.onRelease = function(){
this.getURL(mbNavURL[i]);
}
}
When I preview, the links do not work. If I change the value of i in the line
this.getURL(mbNavURL[i]);
to a hard value, such as 0, 1 or 2, the link works! What am I doing wrong??
You can see the SWF at http://www.eemajin.com/Flash/Mindbla...003_7.3.03.swf
View Replies !
View Related
Please Help - Looping Through An Array, Duplicate
Hey all -
would anyone be so kind as to have a look at this code? Probably something simple I'm just not seeing.
/*mbNav is a var declared on previous frame, loading variables from a txt file called MindblazerVars.txt.
Two lines below load the nav variable and navURL variable into arrays.
*/
var mbNavItem = mbNav.nav.split(",");
var mbNavURL = mbNav.navURL.split(",");
/*
Loop through the mbNavURL array; duplicate a movie clip on the stage called "google," containing
a dynamic text field named "nav_txt" and a movie clip named "boing" for each iteration. "Boing"
is the movie clip that acts as the button to go to the mbNavURL value
*/
for(i=0;i<mbNavURL.length;i++) {
//trace(mbNavURL[i]);
_root.google.duplicateMovieClip("nav"+i,i);
_root["nav"+i]._x = _root["nav"+i]._x + (i*100);
_root["nav"+i].nav_txt.text = mbNavItem[i];
//trace(mbNavURL[i]);
_root["nav"+i].boing.onRelease = function(){
this.getURL(mbNavURL[i]);
}
}
When I preview, the links do not work. If I change the value of i in the line
this.getURL(mbNavURL[i]);
to a hard value, such as 0, 1 or 2, the link works! What am I doing wrong??
You can see the SWF at http://www.eemajin.com/Flash/Mindbla...003_7.3.03.swf
View Replies !
View Related
Create Variables By Looping Thru An Array
I am using this to generate some variables to pass to a backend script:
Code:
//this is the hard coded version that works
function go() {
a0 = _parent.m****ay[0]["name"] + "_" + _parent.m****ay[0]["count"];
a1 = _parent.m****ay[1]["name"] + "_" + _parent.m****ay[1]["count"];
a2 = _parent.m****ay[2]["name"] + "_" + _parent.m****ay[2]["count"];
a3 = _parent.m****ay[3]["name"] + "_" + _parent.m****ay[3]["count"];
a4 = _parent.m****ay[4]["name"] + "_" + _parent.m****ay[4]["count"];
a5 = _parent.m****ay[5]["name"] + "_" + _parent.m****ay[5]["count"];
getURL("http://localhost/update.asp", "", "POST");
}
//this is the loop I am using to be more efficient
function go() {
for (n=0; n<_parent.m****ay.length; n++) {
"a"+n = _parent.m****ay[n][""name""] + "_" + _parent.m****ay[n][""count""];
}
getURL("http://localhost/update.asp", "", "POST");
}
I've been messing around with the quotes, but this is my error:
Left side of assignment operator must be variable or property.
"a"+n = _parent.m****ay[n][""name""] + "_" + _parent.m****ay[n][""count""];
p.s. whats with the ****'s
View Replies !
View Related
Looping Text Through An Array With SetInterval
I have the following in a button, 1 case of many buttons with differing text:
on (rollOver) {
setInterval(update, 1000);
function update() {
ptext.text = "FORUMS";
stext.text = "Painting...";
}
}
on (rollOut) {
ptext.text = "";
stext.text = "";
}
In this case, instead of just statically displaying "Painting...", I'd like it to loop through an array where item 0 is "Painting", item 1 is "Photography...", item 2 is "Web Design...", and item 3 is "The Art Bar...".
...Where it loops through them at a rate of say 250ms per item; i.e., displays item 0 for 250ms, then item 1 for 250ms, then item 2 for 250ms, item 3 for 250ms, then loops back to item 0 and continues).
I know it's an array and a setInterval function, just don't have the AS abilities to get it running, and after 4 or 5 attempts I'm throwing it your way in hopes than I've done the hard work already, for someone who codes intuitively
Shawn
View Replies !
View Related
Simplifying Code: Array Looping
Can anyone suggest a better way of coding this:
code: for(i=1; i<10; i++){
if(this["WinArray"+i].slice(0,5) eq "F,F,F,F,F"){
WinMult = WinMult + 2500;
Fsnd.start();
this["WinLine"+i]._visible = 1;
}else if(this["WinArray"+i].slice(0,4) eq "F,F,F,F"){
WinMult = WinMult + 100;
Fsnd.start();
this["WinLine"+i]._visible = 1;
}else if(this["WinArray"+i].slice(0,3) eq "F,F,F"){
WinMult = WinMult + 25;
Fsnd.start();
this["WinLine"+i]._visible = 1;
}
}
F is one of 9 symbols. When 3 or more appear together in a row within any one of 9 possible combos (Winline 1 - 9 arrays), they yield a different WinMult
I thought about creating a 2D array, the first dimension being the symbol name, and the second dimension storing the three possible win values, then recalling them from within the loop. I hit my 4th IF statement and my head exploded, so I thought I'd ask for another (hundred) pair of eyes. As always, any and all help is appreciated.
View Replies !
View Related
Sequential LoadMovie And Looping An Array
I need to call several external swf's into an array:
showClips = new Array("clip1.swf","clip2.swf","clip3.swf");
Then have a function call that will evaluate which swf (!if any for first run!) is loaded into my emptyClip container, load the next one from the array and play it through, and so on - when the last one is reached it should loop back to the first clip like an infinite loop.
This is as near as my thinking got so far, (how little I know!):
max_clips = showClips.length;
newAd = function(){
for (i=0;i<max_clips;i++){
emptyClip.loadMovie(showClips[i]);
}
};
I should mention that the array size is variable so the function needs to work whether there is one or ten clips.
This probably isn't that hard, but I cannot find a straightforward tutorial on this, so if anyone knows of one please enlighten me.
View Replies !
View Related
Preloading Multiple Mp3's Using A Looping Array
I am preloading multiple mp3's dynamically using a looping array and it is working very well. However, I would like to display the percentage of the last mp3 loaded by the array. Does anyone know how I would modify the code to do this:
Code:
var my_array:Array = new Array();
my_array[0] = "Audio/audio_1.mp3";
my_array[1] = "Audio/audio_2.mp3";
my_array[2] = "Audio/audio_3.mp3";
my_array[3] = "Audio/audio_4.mp3";
count = 0;
var k;
for (k in my_array) {
var my_audio:Sound = new Sound();
my_audio.loadSound(my_array[k], true);
my_audio.setVolume(0);
var my_interval2:Number;
my_interval2 = setInterval(checkAudioProgress, 100, my_audio);
function checkAudioProgress(the_audio:Sound):Void {
var AudioKBytes = Math.ceil(the_audio.getBytesTotal()/1024);
var AudioPct:Number = Math.round(the_audio.getBytesLoaded()/the_audio.getBytesTotal()*100);
AudioPctOutput = "Loading Audio: "+AudioPct+"%"+" of "+AudioKBytes+" k";
}
count++;
}
I'm working against a deadline so any extra help would be greatly appreciated.
Many Thanks.
View Replies !
View Related
Looping An Array For Removal Of MC (Flash Mx)
Hello, I have what i believe is a basic problem, currently I have:
code:
juegoClip.elementos.malo10059.removeMovieclip();
juegoClip.elementos.malo10060.removeMovieclip();
juegoClip.elementos.malo10061.removeMovieclip();
juegoClip.elementos.malo10062.removeMovieclip();
juegoClip.elementos.malo10063.removeMovieclip();
juegoClip.elementos.maloXXXXX.removeMovieclip();
Which works for what I need, however I want some looping instead and I want to change it to something like:
code:
for (var i = 0; i<juego.malos.length; ++i) {
juegoClip.elementos.malo[i].removeMovieclip();
}
// juego.malos is an array that stores posititon and reference of MC
The thing is that it doesn't works. What am I doing wrong? Suggestions more than welcome.
Thank you very much.
View Replies !
View Related
Populating Array With Looping Code?
Hi!
make3DPoint(x,y,z) is a function which has three parameters x,y,z
How do I go about adding them into the pointsArray with a looping structure? Instead of one at a time as below????
pointsArray = [
make3DPoint(-50,-50,-50),
make3DPoint(50,-50,-50),
make3DPoint(50,-50,50),
make3DPoint(-50,-50,50),
make3DPoint(-50,50,-50),
make3DPoint(50,50,-50),
make3DPoint(50,50,50),
make3DPoint(-50,50,50)
];
anyone?
Ikonik
View Replies !
View Related
Looping Through An Array, I Dont Want Duplicates
hello,
I am wondering if anyone can help me please, I have an array containing numbers, these numbers are attached to movie clips to determine where they are on the stage, and they are generated randomly, so the movie clips are always in a new place when a certain button is pressed.
My problem is that I dont know how to avoid duplicates. The way I have done it is I have put the values in an array, and I loop through this with a for loop, from here I take the values and link them to another array that contains the movie clips, this all works well but some of the movie clips are stacked on top of one another because the same array values are coming up :S I have attached the code, so any suggestions would be gratefully recieved, I just havent a clue on this one :S
Many thanks any help is gratefully recieved :D
Attach Code
var answer:Number;
var textAnswer:String;
var playSound:String;
var xy:Number;
var xvalue:Number;
var yvalue:Number;
var i:Number;
var words:Array = new Array();
words[0] = [cat_mc, "soundCat"];
words[1] = [hat_mc, "soundHat"];
words[2] = [van_mc, "soundVan"];
words[3] = [red_mc, "soundRed"];
words[4] = [bed_mc, "soundBed"];
words[5] = [sell_mc, "soundSell"];
words[6] = [pig_mc, "soundPig"];
words[7] = [lid_mc, "soundLid"];
words[8] = [him_mc, "soundHim"];
words[9] = [box_mc, "soundBox"];
words[10] = [log_mc, "soundLog"];
words[11] = [doll_mc, "soundDoll"];
words[12] = [pup_mc, "soundPup"];
words[13] = [sun_mc, "soundSun"];
words[14] = [bus_mc, "soundBus"];
var xyValues:Array = new Array();
xyValues[0] = [282.6, 500.7];
xyValues[1] = [543.8, 500.7];
xyValues[2] = [233.6, 602.7];
xyValues[3] = [406.2, 346.2];
xyValues[4] = [666.1, 354.2];
xyValues[5] = [534.5, 612.1];
xyValues[6] = [408.0, 456.1];
xyValues[7] = [528.4, 374.8];
xyValues[8] = [408.4, 577.5];
xyValues[9] = [665.4, 456.1];
xyValues[10] = [124.4, 558.1];
xyValues[11] = [262.5, 374.8];
xyValues[12] = [666.0, 558.1];
xyValues[13] = [162.9, 456.1];
xyValues[14] = [125.5, 346.2];
//this is in a button function
for(i=0; i<xyValues.length; i++){
xy = Math.floor(Math.random()*xyValues.length);
xvalue = xyValues[xy][0];
yvalue = xyValues[xy][1];
words[i][0].x = xvalue;
words[i][0].y = yvalue;
trace("Xvalue" + xvalue);
trace("YValue" + yvalue);
}
View Replies !
View Related
Looping Array Of Netstream .flv Videos
I have so far been successful getting my array of dynamically loaded videos to stitch together and play using the code below. My first question is how do I tell the .swf to start playing the first movie in the array upon completion of the last movie in the array (loop array). I assume this is some sort of onComplete event, but I'm not sure how to tie it into the below:
My second question is what is the best way to begin pre-loading these movies from an 'Enter' page so that they buffer and run more smoothly? I assume that if I can manage this better, I will be able to use the higher-quality .flv files for optimal viewing.
I appreciate any insight that can be offered.
Thanks,
Chuck
Attach Code
import flash.events.NetStatusEvent;
var videos:Array = new Array("dolphins.flv", "sailboat.flv", "turtle.flv", "catamarans.flv", "group_boat.flv", "captain.flv", "sunset.flv", "studious.flv", "water_over.flv", "stag_diver.flv", "toucan.flv", "survey_notes.flv", "two_captains.flv", "diver.flv", "dinghy.flv", "water_underneath.flv", "chair.flv", "ruin.flv", "survey_notes2.flv");
var currentVideo:uint = 0;
var duration:uint = 0;
var ready:Boolean = true;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
myVideo.attachNetStream(ns);
ns.play(videos[currentVideo]);
var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {
duration = evt.duration;
ready = true;
};
ns.client = listener;
ns.addEventListener( NetStatusEvent.NET_STATUS, nsHandler);
function nsHandler(evt:NetStatusEvent):void {
if (ready && ns.time > 0 && ns.time >= (duration - 0.5)) {
ready = false;
currentVideo++;
if (currentVideo < videos.length) {
ns.play(videos[currentVideo]);
} else {
ns.removeEventListener(NetStatusEvent.NET_STATUS, nsHandler);
}
}
};
View Replies !
View Related
Preloading Multiple Mp3's Using A Looping Array
I am preloading multiple mp3's dynamically using a looping array and it is working very well. However, I would like to display the percetage of the last mp3 loaded by the array. Does anyone know how I would modify the code to do this:
Code:
var my_array:Array = new Array();
my_array[0] = "Audio/audio_1.mp3";
my_array[1] = "Audio/audio_2.mp3";
my_array[2] = "Audio/audio_3.mp3";
my_array[3] = "Audio/audio_4.mp3";
count = 0;
var k;
for (k in my_array) {
var my_audio:Sound = new Sound();
my_audio.loadSound(my_array[k], true);
my_audio.setVolume(0);
var my_interval2:Number;
my_interval2 = setInterval(checkAudioProgress, 100, my_audio);
function checkAudioProgress(the_audio:Sound):Void {
var AudioKBytes = Math.ceil(the_audio.getBytesTotal()/1024);
var AudioPct:Number = Math.round(the_audio.getBytesLoaded()/the_audio.getBytesTotal()*100);
AudioPctOutput = "Loading Audio: "+AudioPct+"%"+" of "+AudioKBytes+" k";
}
count++;
}
I'm working against a deadline so any extra help would be greatly appreciated.
Many Thanks.
View Replies !
View Related
AS: Looping An Array For .onRelease Problem
hey everyone. I'm having a problem with some code and maybe you can help me out.
I have two arrays. One is used for button names and the other is used for the links for the buttons. The buttons are generated dynamically with attachMovie and the names are also modified via AS. My problem comes in at looping through the links array and applying them to the buttons.
Code:
myText = ["First", "Second", "Third"];
myLinks = ["http://google.com", "http://yahoo.com", "http://aol.com"];
total = myText.length;
//<----------here is where the problem resides------------>//
for (i=0; i<total; i++) {
_root.attachMovie("button", "button"+i, i, {_x:200, _y:50+(i*33)});
_root["button"+i].text_txt.text = myText[i];
_root["button"+i].onRelease = function() {
//<-------specifically the following line--------->//
// it doesn't seem to loop through the i, however,
// if i change "i" to a specific value in the array like "1"
// it will produce "http://yahoo.com" as expected.
// also, i'm using trace instead of getURL to save time.
trace(myLinks[i]);
};
}
thanks guys.
View Replies !
View Related
Looping Array - Both Back And Forward
I'm working off the XML photo gallery tute found here: xml_flash_photogallery.htm
My wish is to have the array loop forward and backwards, so by clicking next you will eventually get back to the first value, and if you keep clicking previous you will eventually see the last value in the array.
I found some Scotty code (first line in the nextImage function) that enabled this function with the next button, but I can't figure out how to use it for the previous button. Can anyone help?
Here's the code:
ActionScript Code:
previous_btn.onRelease = function() { prevImage();};next_btn.onRelease = function() { nextImage();};/////////////////////////////////////p = 0;this.onEnterFrame = function() { filesize = picture.getBytesTotal(); loaded = picture.getBytesLoaded(); preloader._visible = true; if (loaded != filesize) { preloader.preload_bar._xscale = 100*loaded/filesize; } else { preloader._visible = false; if (picture._alpha<100) { picture._alpha += 10; } }};function nextImage() { //next line will let it start over again p<(total-1) ? p++ : p=0; if (loaded == filesize) { picture._alpha = 0; picture.loadMovie(image[p], 1); desc_txt.text = description[p]; picture_num(); } }}function prevImage() { if (p>0) { p--; picture._alpha = 0; picture.loadMovie(image[p], 1); desc_txt.text = description[p]; picture_num(); }}function firstImage() { if (loaded == filesize) { picture._alpha = 0; picture.loadMovie(image[0], 1); desc_txt.text = description[0]; picture_num(); }}
View Replies !
View Related
[AS3] Looping Array Is String Instead Of Number?
Below is a sample code. I could not figure out why i is string and not Number/int.
ActionScript Code:
//The code below does not workvar numArray:Array = [1,2,3,4];for(var i:int in numArray){ trace(i); trace(numArray[i]);}
ActionScript Code:
//The code below worksvar numArray:Array = [1,2,3,4];for(var i:String in numArray){ trace(i); trace(numArray[i]);}
View Replies !
View Related
Looping From 0% To 100% Based On Array Length
I'm trying to get an object to zoom from 0% to 100% based on whatever length my allText array is.
So, allText.length is currently 18 - 100/18 is 5.55555555555556 (variable in "myPreloaderXY") so the object should run 18 times at "myPreloaderXY" and it will stop at 100 -which is what I want.
However, it stops at 89. And if I change the length of the array to anything else it stops at a different number.
What am I doing wrong?
Thanks
Charles
I've setup a 3 frame test below:
------------------------------------------------------------------------
frame 1
allText = new Array(textForCard1,textForCard2,textForCard3,textForCard4,textForCard5,textFor Card6,textForCard7,textForCard8,textForCard9,textForCard10,textForCard11,textF orCard 12,textForCard13,textForCard14,textForCard15,textForCard16,textForCard17,textF orC ard18);
var nCounter:Number = 1;
var myPreloaderXY:Number = 0;
var preloadCounter:Number = 100/allText.length;
trace ("preloadCounter "+preloadCounter)
frame 2 is empty
frame 3 is this:
if (nCounter < allText.length) {
percentLoaded = Math.ceil((myPreloaderXY/100)*100);
trace ("percentLoaded "+percentLoaded)
myPreloaderXY = myPreloaderXY + preloadCounter;
nCounter++;
gotoAndPlay("frame2");
}
else if (nCounter == allText.length){
trace("counter ended")
stop();
}
------------------------------------------------------------------------
View Replies !
View Related
Trouble Looping Through An Array, Loading Jpegs
Hi,
I'm trying to use loadMovie to load a series of jpegs into a movieclip -- changing them as the movie loops. I've set up an array, and wound up having to use a string variable to load the jpegs. I also set up a dynamic text box to display the string variable, for testing purposes only. When the movie loops, the dynamic text changes, but the movieclip does not (when I do a trace, the variable doesn't appear to change either. strange). What am I doing wrong?
this.onLoad = function() {
output_str = workImg_array[inputNum];
work.loadMovie(output_str);
trace(output_str);
inputNum++;
};
var output_str:String = workImg_array[inputNum];
var inputNum:Number = 0;
var workImg_array:Array = new Array();
workImg_array[0] = "c_www4.jpg";
workImg_array[1] = "c_asi1.jpg";
workImg_array[2] = "w_to1.jpg";
workImg_array[3] = "w_cmi1.jpg";
Help! and let me know if there's a better way to explain this. Thanks!!!
View Replies !
View Related
Looping Thru Array To Create Instance Of A Class
Hello - I am new to as 3 - I have been combing forums for an answer ... to no avail. Here is the deal: I am creating a site for a medical center in France. I want the list of treatments to appear 1 by 1 with a nice animation. The list of treatments is changing fairly often so I am using an array to create instances of a Symbol ( called CONTENEUR_TRI_TEXTE ) that has been exported as a class ( called CONTENEUR_TRI_TEXTE) using the Linkages options in the library.
This symbol contains 3 dynamic text fields (TITRE_txt, DESC_txt and PRIX_txt ) respectively the name, description and price of the surgery.
I have obviously used simplified versions of the descriptions and prices here, for the sake of clarity - so, don't be mistaken: one can't get Heart surgery for 100€ in France!
Since I am a newbie, I tried a hard-coded version of the code on 1 instance of the class, to check that everything was in place - and it works.
HERE IS THE HARD CODED VERSION
ActionScript Code:
//Declare variables for text content
var TITRE1:String = "Heart Surgery";
var DESC1:String = "Surgery on your heart";
var PRIX1:String = "100€";
//Add child CONTENEUR to stage
var SV_HEART:CONTENEUR_TRI_TEXTE=new CONTENEUR_TRI_TEXTE();
stage.addChild(SV_HEART);
SV_HEART.x = 200;
SV_HEART.y = 200;
//Assign variables to each text box + embd fonts
SV_HEART.TITRE_txt.text=TITRE1; SV_HEART.TITRE_txt.embedFonts=true;
SV_HEART.DESC_txt.text=DESC1; SV_HEART.DESC_txt.embedFonts=true;
SV_HEART.PRIX_txt.text=PRIX1; SV_HEART.PRIX_txt.embedFonts=true;
Problem is when I use 2 dimensional arrays to create these instances, I get compile error:
Line 21: var SURGERIES[i]:CONTENEUR_TRI_TEXTE=new CONTENEUR_TRI_TEXTE();
1086: Syntax error: expecting semicolon before leftbracket.
HERE IS THE CODE USING ARRAYS:
ActionScript Code:
//Declare arrays details
var SV_HEART:Array = new Array();
SV_HEART[0] = "Heart Surgery";
SV_HEART[1] = "Surgery on your heart";
SV_HEART[2] = "100€";
var SV_BRAIN:Array = new Array();
SV_BRAIN[0] = "Brain Surgery";
SV_BRAIN[1] = "Suregry on your brain";
SV_BRAIN[2] = "200€";
//Declare OVERALL SURGERIES array
var SURGERIES:Array = new Array();
SURGERIES[0] = SV_HEART;
SURGERIES[1] = SV_BRAIN;
//START LOOP THRU SURGERIES ARRAY
for(var i:int=0; i<SURGERIES.length; i++ )
{
//Add child CONTENEUR to stage
var SURGERIES[i]:CONTENEUR_TRI_TEXTE=new CONTENEUR_TRI_TEXTE();
stage.addChild(SURGERIES[i]);
SURGERIES[i].x = 200;
SURGERIES[i].y = 200;
//Assign variables to each text box + embd fonts
SURGERIES[i].TITRE_txt.text=SURGERIES[i][0]; SURGERIES[i].TITRE_txt.embedFonts=true;
SURGERIES[i].DESC_txt.text=SURGERIES[i][1]; SURGERIES[i].DESC_txt.embedFonts=true;
SURGERIES[i].PRIX_txt.text=SURGERIES[i][2]; SURGERIES[i].PRIX_txt.embedFonts=true;
}
I suspect this is not actually a simple syntax error - Any suggestions as to where the solution might be would be extremely appreciated
Thanks
View Replies !
View Related
Looping Through Array And Building A Bulleted List
i'm getting a recordset in from coldfusion. it contains a variable with a value that is a list of features seperated by commas.
I need to try and get those features to display as a bulleted list.
I'm attempting to use "split" and then loop through the array and create a new line of text for each item in the array but I really don't have a clue of how to do that. I'm used to attaching mc's based on array items but this is beyond me...
here's what i have (attempting to loop through);
Code:
helmArray = helm.split(",");
trace(helmArray);
item=helmArray[5];
trace(item);
helmLength=helmArray.getLength();
for(var i=0; i<helmLength; i++){
helmText=helmArray(i)+"
";
trace(helmText);
}
}
}
View Replies !
View Related
Looping, Then Referencing Dynamic Clips From Array
i'm looping thru xml nodes and using this to attach clips to an empty mc:
Code:
item = _root.mainHolder.links.linkHolder.attachMovie("linkClip", "linkClip" + i, i);
my question is how can I reference the previously attached clip so I can determine the _y property of the current item(clip).
I'd like to do something like this.
item._y= previously attached clip._y-previously attached clip.height
that way my dyn clips can resize based on how much text...
get it?
View Replies !
View Related
AttachMovie - Looping Thru An Array To Attach 6 Movie Clips Into An Empty Clip
Heres my issue...
Im loading in 6 different external icon button images using an XML file into an movieclip. well now i dont want external images to load from an xml file, i want the images to be inside flash in the library. I gave them a linkage name and made an array of them called menuIcons.
how do i get my icon images to load into flash without loading external images from an xml file...
heres my code..
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes = this.firstChild.childNodes;
numOfItem = nodes.length;
for (var i=0; i<numOfItem; i++)
{
menuIcons = ["healthySkin", "environMoist", "lowerSkin", "drySkin", "waterInfusion", "healthyCellular"];
var t = home.attachMovie("item", "item" + i, i + 1);
t.angle = i * ((Math.PI * 2)/numOfItem);t.onEnterFrame = mover;
t.nameClip = (nodes[i].attributes.nameClip);
t.content = (nodes[i].attributes.content);
t.icon.inner.loadMovie(nodes[i].attributes.image);t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
}
thanks
slalonde44
View Replies !
View Related
Looping In Php Or Flash, Array In Flash Or Not?
I have a databse containing alot of links.
I have figured out how to get one link into flash but only one at the time.
So i guess Ill need to loop my code either in flash or php.
What is the best way to do this.
I want one dynamic box displaying the name and it should be a link.
So that when people post a name and a link only the name will show.
But thats not the most important thing right now,, first thing first.
How do i get all of the database into flash.
Let say I have only url, name and date stored in my database.
View Replies !
View Related
Looping Sound And Looping Animation Sync
I'm working on a navagation interface for a new site, and I'm running into a few issues.
1) when you click on a button, it activiates an MC. within that MC, the first frame is the initial "off" state, and clicking on a button triggers the rest of the clip to play, from frame 2. I have a sound that starts in frame 2, and I set up an animation of a VU meter that is supposed to be synced very closely to the music. In the last frame of the MC is an action, gotoandplay, that sends it back to frame 2. The idea here is that once the button is pressed, the music loops and the animation loops with it.
When I test the movie, do a publish preview, or view the swf file in the flash player, the animation seems to be synced to the music for the first few times it loops, but then the animation drifts ahead of the music, getting progressively further out of sync with each loop. The other real problem here, is that when viewing the swf in any web browser, the animation is immediately behind the music, and seems to be running much slower than it should.
you can see the swf here:
http://www.lsrdigital.com/flash/index.html
Does anyone have any ideas about how to get this to work the way I am trying to get it to?
the .fla file is here if you want to look at it as well:
http://www.lsrdigital.com/flash/LSR.fla
2) The other problem I'm having is that the stage is set to be 680 pixels wide, and the graphic that fills the background is 680 pixels wide, BUT Flash MX publishes the movie at only 679 pixels wide! You can see the line of white pixels on the right side of the movie here:
http://www.lsrdigital.com/flash/index.html
I've double checked the html file and the table cell holding the movie element is 680 pixels wide. You can also tell that Flash is cutting off the last column of pixels because the background image is visibly just missing the edge to the right of the screws.
Any ideas on that one?
View Replies !
View Related
Looping External Mp3 Not Looping Perfectly
Hi there
I have a looping external mp3 file playing in the background of my flash (Flash MX 2004) movie.
Unfortunately it does not loop perfectly even though I know the mp3 file loops perfectly in sound editing programs.
There seems to be a slight delay.
Here is my code
function Play_Background_Audio() {
myMusic.loadSound(audioFile,true);
myMusic.onSoundComplete = function() {
myMusic.loadSound(audioFile,true);
};
};
audioFile = "home.mp3";
myMusic = new Sound(myMusicMc);
Play_Background_Audio();
Any help would be much appreciated.
Thanks
Paul
View Replies !
View Related
Looping & Non-looping Components In Same Movie
I'm new to using Flash MX, and would be grateful if someone could give me some advice for this animation I'm trying to do.
I'm making a banner for a website that is being designed by someone else. The background consists of four photos that fade in and out continuously (I think "looping" is the correct term) as soon as the animation (movie?) opens up. That part wasn't too hard!
However, the client wants a name (in white text) to gradually fade in on top of the looping background, and stay visible and static for as long as the looping animation plays. As well, after the white name fades in and becomes static, she needs another name (in gold text) to gradually appear and start fading in and out below it.
So the sequence is:
- Looping background begins to play.
- The name (in white text) gradually fades in (say at around frame 50) and stays visible (alpha at 100%) while the background is looping.
- Around frame 100 a second name (in gold text) fades in and then starts fading in and out continuously in synch with the looping background.
I can't figure out how to do this. Do I need multiple time lines? Or triggers in various frames? Or different scenes?
I have a sinking feeling that I'm going to have to use Actionscript for this, and although I'm perfectly willing to learn, I haven't a clue where to start. Could anyone help, please?
View Replies !
View Related
|