Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Contents Doubling In Array



Hey all, need some help.I've created an Array to load four separate jpegs. Everything works fine and dandy, except everytime I click, the trace (and the children and whatever else being added) multiplies exponentially, thus bogging down the swf file after several clicks.Any idea what's causing my events to double?Thanks in advance!Code: var thumbList:Array = ["P1_1.jpg", "P1_2.jpg","P1_3.jpg","P1_4.jpg"];var loader:Sprite = new Sprite;var container:Sprite = new Sprite();container.x = 0;container.y = 0;addChild(container);function init(nNum:Number) {    trace("Project Icons Loaded");    //--- Loader    var pictLdr:Loader = new Loader();    var pictURL:String = thumbList[nNum];    var pictURLReq:URLRequest = new URLRequest(pictURL);    pictLdr.load(pictURLReq);    pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);    function imgLoaded(event:Event):void {        container.addChild(pictLdr.content);    }    //---    th1.addEventListener(MouseEvent.CLICK, th1Load);    function th1Load(e:MouseEvent):void {        trace("Image 1 loaded");        pictLdr.content.visible = false;        thumbList.length = 0;        thumbList.push("P1_1.jpg");        init(0);    }    //---    th2.addEventListener(MouseEvent.CLICK, th2Load);    function th2Load(e:MouseEvent):void {        trace("Image 2 loaded");        pictLdr.content.visible = false;        thumbList.length = 0;        thumbList.push("P1_2.jpg");        init(0);    }    //---    th3.addEventListener(MouseEvent.CLICK, th3Load);    function th3Load(e:MouseEvent):void {        trace("Image 3 loaded");        pictLdr.content.visible = false;        thumbList.length = 0;        thumbList.push("P1_3.jpg");        init(0);    }    //---    th4.addEventListener(MouseEvent.CLICK, th4Load);    function th4Load(e:MouseEvent):void {        trace("Image 4 loaded");        pictLdr.content.visible = false;        thumbList.length = 0;        thumbList.push("P1_4.jpg");        init(0);    }    }init(0);



General Flash
Posted on: Tue May 20, 2008 4:33 am


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Contents Doubling In Array
Hey all, need some help.

I've created an Array to load four separate jpegs. Everything works fine and dandy, except everytime I click, the trace (and the children and whatever else being added) multiplies exponentially, thus bogging down the swf file after several clicks.

Any idea what's causing my events to double?

Thanks in advance!

//-----


ActionScript Code:
var thumbList:Array = ["P1_1.jpg", "P1_2.jpg","P1_3.jpg","P1_4.jpg"];

var loader:Sprite = new Sprite;

var container:Sprite = new Sprite();
container.x = 0;
container.y = 0;
addChild(container);

function init(nNum:Number) {
    trace("Project Icons Loaded");

    //--- Loader

    var pictLdr:Loader = new Loader();
    var pictURL:String = thumbList[nNum];
    var pictURLReq:URLRequest = new URLRequest(pictURL);

    pictLdr.load(pictURLReq);
    pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);

    function imgLoaded(event:Event):void {
        container.addChild(pictLdr.content);
    }
    //---
    th1.addEventListener(MouseEvent.CLICK, th1Load);

    function th1Load(e:MouseEvent):void {
        trace("Image 1 loaded");
        pictLdr.content.visible = false;
        thumbList.length = 0;
        thumbList.push("P1_1.jpg");
        init(0);
    }
    //---
    th2.addEventListener(MouseEvent.CLICK, th2Load);

    function th2Load(e:MouseEvent):void {
        trace("Image 2 loaded");
        pictLdr.content.visible = false;
        thumbList.length = 0;
        thumbList.push("P1_2.jpg");
        init(0);
    }
    //---
    th3.addEventListener(MouseEvent.CLICK, th3Load);

    function th3Load(e:MouseEvent):void {
        trace("Image 3 loaded");
        pictLdr.content.visible = false;
        thumbList.length = 0;
        thumbList.push("P1_3.jpg");
        init(0);
    }
    //---
    th4.addEventListener(MouseEvent.CLICK, th4Load);

    function th4Load(e:MouseEvent):void {
        trace("Image 4 loaded");
        pictLdr.content.visible = false;
        thumbList.length = 0;
        thumbList.push("P1_4.jpg");
        init(0);
    }
   
}

init(0);

Displaying Array Contents
Hi! Ok, I'm trying to simplify a really complicated process. My first step is display the contents of part of an array. I use a movie clip and duplicateMovieClip, but nothing has ever displayed and I've spent more hours on this than I ever want to think about. My question basically is: how do go from an array of words to a movie clip to showing a word in the Flash movie in a certain place. Below is what I have been attempting to piece together. If anyone knows ANYTHING, I would be a very happy lady! Thanks!!!
Stephanie

//This is placed in a box, which is a movie clip instance

onClipEvent (load) {
var startX = 100;
wordClip = new Array();
wordArray = ["It", "works", "now", "I", "can", "go", "to", "bed"];
trace(wordArray);
var n=5;
var count = random(wordArray.length);
trace (count);
duplicateMovieClip ("wordClip", "newwordClip", n);
newwordClip = wordArray[count];
trace(newwordClip);
setProperty ("newwordClip", _visible, true);
setProperty ("newwordClip", _x, _root.box);
setProperty ("newwordClip", _y, getProperty("box", _y));
newwordClip.play();
n += 1;
trace (n);
}

Array Labels Instead Of Contents?
OK...I can't seem to see this (and I bet its real simple):

In my flash project I have 3 rather long lists of words (in 3 separate arrays). I then assign the contents of these arrays randomly to 3 predefined subject arrays for each user that visits my site:

User 1
Words Array 1 = Subject Array 2
Words Array 2 = Subject array 1 and so on...
(I know it probably sounds odd, but I have to do it this way).

Anyway, I would like to keep track of which word lists are assigned to which subject group for each visitor by writing them to a text file via perl. I have no problem in doing it so that I see every word in all of the arrays being assigned for every person. I would rather be able to just have a text file of array names showing what word array has been assigned to what subject array (like what I've done above) instead of array contents.

Long story short; is there away to do this? (maybe by assigning a variable to an array name without affecting the array itself???)

Thanks
RD

Using Contents Of Array In A Path Name
How do I use the contents of an array in a path name? (Like _root.[contentsofarray].blah.blah

For example, say I have a string in an array-- and that string is the name of an instance of a movie clip. And I want to use the name of that instance in a path name.

What's the syntax for doing this? Anybody know? : )

Using Flash MX.

Losing Array Contents
I'm tracing the contents of an array in one function and when the next function starts, the same exact trace function returns "undefined". Its crazy.


PHP Code:



finder_xml = new XML();
finder_xml.onLoad = Start;
finder_xml.load("finder.xml");
finder_xml.ignoreWhite = true;

// Intialize variables
function Start(success) {
    if (success == true) {
        rootNode = finder_xml.firstChild;
        trace(rootNode);
        firstGroup = rootNode.firstChild;
        totalFeatures = firstgroup.childNodes.length;
        trace(totalFeatures);
        secondGroup = firstGroup.nextSibling;
        totalModels = secondGroup.childNodes.length;
        trace(totalModels);
        firstFeature = firstGroup.firstChild;
        trace(firstFeature);
        nextFeature = firstFeature.nextSibling;
        trace(nextFeature);
        firstModel = secondGroup.firstChild;
        trace(firstModel);
        nextModel = firstModel.nextSibling;
        trace(nextModel);
        extractFeatureData();
        trace(productFeature[1]);//These traces return "undefined".
        trace(productFeature[2]);
        trace(productFeature[3]);
        trace(productFeature[4]);
        trace(productFeature[5]);
        trace(productFeature[6]);
        trace(productFeature[7]);
        trace(productFeature[8]);
        trace(productFeature[9]);
        featureLayout();
    }
}
function extractFeatureData() {
    var productFeature = new Array();
    var productCode1 = new Array();
    var productCode2 = new Array();
    var productCode3 = new Array();
    var productAdvice = new Array();
    var productOption1 = new Array();
    var productOption2 = new Array();
    var productOption3 = new Array();
    var productNode = new Array();
    featureCount = totalFeatures;
    featureNode = firstFeature;
    trace("featureNode before loop = "+featureNode);
    for (i=1; i<=featureCount; i++) {
        productNode[i] = featureNode;
        trace("productNode = "+productNode[i]);
        productFeature[i] = featureNode.attributes.name;
        trace("productFeature = "+productFeature[i]); //This trace works.
        productCode1[i] = featureNode.attributes.code1;
        productCode2[i] = featureNode.attributes.code2;
        productCode3[i] = featureNode.attributes.code3;
        productAdvice[i] = featureNode.attributes.advice;
        productOption1[i] = featureNode.attributes.option1;
        productOption2[i] = featureNode.attributes.option2;
        productOption3[i] = featureNode.attributes.option3;
        featureNode = featureNode.nextSibling;
    }
}
function featureLayout() {
    featureCount = totalFeatures;
    trace("featureCount = "+featureCount);
    y = 0;
    spacing = 26;
    for (i=1; i<=featureCount; i++) {
        _root.listBox1.attachMovie("FeatureText", "FeatureText"+i, i);
        var name = "FeatureText" + i;
        trace(name);
        _root.listBox1[name]._y = y;
        trace(y);
        trace(productFeature[i]); //This trace returns "undefined"
        _root.listBox1[name].featureName.text = productFeature[i];
        //_root.listbox1[name].currentNode = classGroupNode[i];
        y = i*spacing;
    }
}




Here is the XML:


PHP Code:



<?xml version="1.0" encoding="UTF-8"?>

<project>

<features>
<feature name="Number of Keys" code1="100" code2="110" code3="120" advice="keys are useful for playing" option1="61" option2="76" option3="88" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Key Action" code1="200" code2="210" code3="220" advice="keys are useful for playing" option1="Organ Type" option2="Weighted" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Yamaha Education Suite" code1="300" code2="310" code3="320" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Song Book" code1="400" code2="410" code3="420" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Portable Grand" code1="500" code2="510" code3="520" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Recording" code1="600" code2="610" code3="620" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Removable Storage" code1="700" code2="710" code3="720" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Score/Lyric Display" code1="800" code2="810" code3="820" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
<feature name="Vocal Harmony" code1="900" code2="910" code3="920" advice="keys are useful for playing" option1="Yes" option2="No" option3="null" clicks1="0" clicks2="0" clicks3="0"></feature>
</features>

<products>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR1100" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR2100" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
<product model="PSR550" picurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" detailurl="/yamahavgn/Images/Education/Lifestyle/0302-01.jpg" codelist="100,300,500" clicks="10"></product>
</products>

</project>

What's The Best Way To Delete The Contents Of An Array?
What's the best way to delete the contents of an array?

I want to delete the conects of an array, but want to keep the array itself.

I'm not quite sure what the best way to do this would be?

If I just use delete, then this will delete the array itself, but I don't want this as I want to keep the array variable.

Any help would be appreciated.

Thanks.


OM

Push Contents Of One Array Into Another
Hi guys - if one array is called MyArray and the second is called MyArray2, how do I push the contents of the first array into the second?

I've tried passing the array contents into a text box and then pushing the text box contents into the second array and about a dozen other methods. I'm very much an amateur at this and I'm tearing my hair out over here...

Separating Contents Of An Array
Right now I have an array with a bunch of different file and folder names in it. I want to separate the files and folders in to two separate arrays. How would I check the arrays to see if the elements have a "." in them, and then if they do have a "." in them, put them into files array.

Display Contents Of Array
hey,
so i am just hoping that someone has done this before and it is a quick copy paste for you.

I am working on a site where the only access that I have to anything from the database is VIA an array that I can display by listing the variables. but it gets a little bit messy (to say the least).

I am looking for a way to recursively loop through an array and display the contents either in a component that i will build or just tracing out.

I currently have the following:

Code:
public function printArray (obj) {
trace(obj);
for (var item in obj)
{
trace(item + " = " + obj[item]);
printArray (obj[item]);
}
}
it works fine but returns a mess. I am looking to make something like print_r does in PHP where it either indents or just intelligently displays the contents.

Please let me know if you have done anything like this before and how it works.

cheers, marc

How To Return Name Of An Array Not It's Contents?
Hey there, thanks for checking this. I have an array that holds some other arrays and I want to return just the name of the arrays that it holds, not their contents. In this example I want to trace the string "myDays_ar" but can only get the contents.

ActionScript Code:
var myDays_ar:Array = ["Sat", "Sun", "Wed"];var myMonths_ar:Array = ["January", "July"];var my_ar:Array = [myDays_ar, myMonths_ar];trace(my_ar[0]);//RETURNS: Sat,Sun,Wed  

I have tried

ActionScript Code:
trace(my_ar[0]._name);

and

ActionScript Code:
trace(my_ar[0]._name.toString());

but can't get what I want!
If anyone could help I would be really grateful
Thanks!
Schm

Separating Contents Of An Array
Right now I have an array with a bunch of different file and folder names in it. I want to separate the files and folders in to two separate arrays. How would I check the arrays to see if the elements have a "." in them, and then if they do have a "." in them, put them into files array.

How To Erase An Array's Contents
I'm trying to figure out to erase all of the contents of an array I have so I can reuse it within a loop in a function. Basically I want to create an array each time I enter the loop, add new values to it, save that array to another name and then go back into the loop and reuse the same array.

Problem is when I trace the array it continues to adding new values to the array. I'm using the ".push" method to update my array.

Any ideas?

Make The Contents Of The Array Into Variables
I am running an array that creates 10 random numbers. I want to make the contents of the array (the 10 random numbers) into variables where I can then proceed to work with them. This is the actionscript I am using:

Array.prototype.pickRandom = function(){
return this.splice(random(this.length), 1);
}

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

//pick all the numbers in random order
while (numbers.length) {
trace(numbers.pickRandom());
}

The only problem is I don't know how to make the contents of this array into variables... Anyone have the heart to show a little code? Thanks.

Displaying Array Contents Without Comma?
Hello,

I have an array that contains individual letters and numbers. What I want to do is display the contents of this array as a string, but without commas between them, so that means I can't use .toString.
Any suggestions?
I am working in Actionscript 1.0.

thanks,
Brent

[F8] Reading Entire Contents Of 2D Array
I've got a 2D object array that hold varying data:

StudentArray[0].FirstName
StudentArray[0].LastName

StudentArray[1].FirstName
StudentArray[1].LastName
StudentArray[1].Grade

StudentArray[2].FirstName
StudentArray[2].LastName
StudentArray[2].Address

Each index number can hold different attributes (some might have "grade", others "address"), and we don't know what each in each set, as they are read in via outside data sources.

The question: How can I loop through each array element and whatever info might be stored in it, without knowing the name of the attributes ahead of time?

Thanks in advance!

Randomly Picking Contents Of An Array
Does anyone no how to randomly pick items from an array without ever picking the same item again until everything has been randomly picked at least once. I'm building a online radio and I don't want the "station" to play the same song until all the songs have been played at least once.

Has anyone tried to do this? If so any help would be appreciated.

Thanks,

MK

Putting Contents Of An Array In Textfields
Yow, I have a problem ...

I have an Array with several Items (between 10-15)
Now i wanted to give out these Items in Textfields dynamically.
Can sumone help me out?

much appreciated

cheers

ChromeD

Problem Reversing An Array's Contents
I seem to be having trouble reversing the contents of an array

this is the code:

Code:
stop();
// Attributes arrays
var nd:Array = new Array();
var ns:Array = new Array();
var sp:Array = new Array();
var idnum:Array = new Array();

// Load XML
var newsXML:XML = new XML();
newsXML.ignoreWhite = true;
newsXML.onLoad = function()
{
trace("this " + this);
var nodes:Array = this.firstChild.childNodes;
trace("nodes: " + nodes);
for(i=0;i < nodes.length; i++)
{
idnum[i] = nodes[i].attributes.id;
trace("idnum[i]: " + idnum[i]);
nd[i] = nodes[i].attributes.date;
trace("nd[i]: " + nd[i]);
ns[i] = nodes[i].attributes.story;
trace("ns[i]: " + ns[i]);
sp[i] = nodes[i].attributes.spacer;
trace("sp[i]: " + sp[i]);
}
// Display Text
var stringCache:String;
for(n=0; n < idnum.length; n++)
{
trace(idnum[n]);
trace(nd[n]);
trace(ns[n]);
trace(sp[n]);
theNews.text += nd[n] + "
" + ns[n] + "
" + sp[n] + "
" + "
";
}
theNews.text = stringCache;
}
newsXML.load("updates/adNews.php");
i've tried changing the 'for' loops for both the 'n' and 'i' variables to decrement them and also tried idnum.reverse(); but i can;t get it to work.

It's a news page so i'm basically trying to get the newest story(which is attached to the highest id number in the databse) to post first and then post the rest in descending order.

anyone have any suggestions?

thanks

PLEASE Help. Dynamically Populating Array With Folder Contents?
Hi there. I would be every so appreciative if someone could just point me in the right direction here. You see, what I'd like to do is use all the .swf files located in a root folder of mine and dynamically populate an array with them. So that if I add additional .swfs, my array updates accordingly.

I have a hunch this isn't exactly the correct way to go about populating an array with a bunch files that I continually add to. . . so hopefully someone out there might be able to give me a bit of guidance? Please?

Thank you so much for your help; I appreciate you reading my post.

Delete And Create To Flush Array Contents?
When you want to clear out the contents of an array in Flash MX is it a bad idea to just delete the array and create it again?

for example:

Delete myArray;
myArray = new Array();

I'm wondering:
1. If the way Flash handles (and doesn't handle) memory management would cause some problems.

2. Is it considered good coding practice.

I'm assuming in this example that myArray does not contain any other arrays or objects that need to be tossed first.

Thanks for the help.

Examine Array Contents (counting Like Values)
I am using Flash MX 2004 Pro.

An array of a known length (lets say 10), can contain values (say from 0.01 to 9999.99).
How would I ensure that there are no more than X occurances of the same value within the array?

I was thinking of looking at each value and checking along the array to see how many times that value is repeated. Has anyone any pre written function/code that will do this?

Many thanks.
Gav

Help Displaying Array Contents Spaced Over Time
I'm using Actionscript 2.0 in Flash MX 2004.

My goal is to randomly display movie clip names ("C1", "C2", etc) from an array. I want these movie clip names to not display all at once, but to show up one second apart from each other.

I have some code posted below which is in the first (and only) frame of my Flash file. I have created an array (interactiveON) which holds all of the movie clip names.

I then create an Array (ary) which generates and holds random numbers.

I can get the movie clip names from "interactiveON" to display in a random order, however instead of having them all show up in the output window at once, I want them to display one at a time, 1 second apart from each other, and then stop once all names have been displayed.

If anyone can help me solve this puzzle it would be much appreciated.



Code:
// Create Array (interactiveON) with my content
var interactiveON:Array = new Array(6);
interactiveON[1]="C1";
interactiveON[2]="C2";
interactiveON[3]="C3";
interactiveON[4]="C4";
interactiveON[5]="C5";

//-------------------------

//Set up an Array (ary) of random numbers
n = 6;
ary = [];

// Assign random numbers to "ary"
for (i = 0; i < n; ++i) ary[i] = i;
ary.sort( function() { return random(2)? 1 : -1; });
trace(ary); // Returns string of numbers 0-5, randomized

// Convert random numbers to new Array
for (j=0; j<n; ++j){
trace(interactiveON[ary[j]]); //Returns the cells of "interactiveON" in random order
}

How To Get Array Contents To Text Field As Rows?
Hi,

Here is a beginner question:

How to get arrays contents to show on own rows instead of one continuous row?

I have tried this:

ActionScript Code:
for (n=0; myArray.length; n++) {
myArray[n]+"<br>";
}

text_txt = myArray;
There must be something missing...

- jari-

Loading Contents From Randomized Array Sequentially...
Hi there,

I have this function which randomizes an array loaded from a text file that contains the names of folders that contain the content to be loaded. The problem is that all the content is preloaded at once (12 thumbnail-sized swf's, that in turn load images), before it displays it in Flash. How would I go about displaying each image as soon as it is loaded, while the rest are still being loaded?
Here's the code I have:

First frame:

ActionScript Code:
stop();toArray = new Array();my_var = new LoadVars();my_var.onLoad = function(success) {if (success) {toArray = this.toArray.split(",");gotoAndPlay(2);}};my_var.load("content/inspiration/inspirationContents.txt");


Second Frame:

ActionScript Code:
randomNumArr = [];for (i=0; i<12; i++) {randomNumArr.push(i);}addContent = function (clipNum) {var ranNum = Math.floor(Math.random()*(randomNumArr.length));this["daThumb_"+clipNum].daImageTarget.loadMovie("content/inspiration/"+toArray[randomNumArr[ranNum]]+"/preview/loadThumb.swf");randomNumArr.splice(ranNum, 1);};


And then on the third Frame I add all the contents:

ActionScript Code:
addContent(1);addContent(2);addContent(3);...addContent(12);stop();


Any input is really appreciated!!

Thanks,

Rufus

[AS] Loading Contents From Randomized Array Sequen
Hi there,

I have this function which randomizes an array loaded from a text file that contains the names of folders that contain the content to be loaded. The problem is that all the content is loaded at once (12 thumbnail-sized swf's, that in turn load images), before it displays it in Flash. How could I alter my 'addContent' function to display the items that have been loaded straight away, instead of adding them "manually" on the third frame??


Here's the code I have:

First frame:

ActionScript Code:
stop();
toArray = new Array();
my_var = new LoadVars();
my_var.onLoad = function(success) {
        if (success) {
                toArray = this.toArray.split(",");
                gotoAndPlay(2);
        }
};
my_var.load("content/inspiration/inspirationContents.txt");


Second Frame:

ActionScript Code:
randomNumArr = [];
for (i=0; i<12; i++) {
        randomNumArr.push(i);
}
addContent = function (clipNum) {
        var ranNum = Math.floor(Math.random()*(randomNumArr.length));
        this["daThumb_"+clipNum].daImageTarget.loadMovie("content/inspiration/"+toArray[randomNumArr[ranNum]]+"/preview/loadThumb.swf");
        randomNumArr.splice(ranNum, 1);
};


And then on the third Frame I add all the contents:

ActionScript Code:
addContent(1);
addContent(2);
addContent(3);
.
.
.
addContent(12);
stop();


Any input is really appreciated!!!

Thanks,

Gene

Dynamically Load Array Based On Folder Contents
Tough one...

I'd like to have the contents of an mp3 folder entered into an array (containing strings of each file name in the folder).

I'd like this to be totally dynamic so I can modify a playlist simply by dropping more mp3s into this folder.

File names must come in as strings in an array (i.e. "js bach - air on the g string.mp3")

How about it? Any thoughts or ideas?

Thanks
-dave-

Populate Array In Flash With The Contents Of A Directory(folder)
Hi all,

I'm trying to get Flash MX 2004 to read the contents of a specified directory (containing .jpg files) and populate an array that I can then read from the array to view the images within the flash movie.

I want to be able to add more images to the directory without having to edit hard coding of the array everytime. Plus I don't want to have to name all the images "image0.jpg, image1.jpg, image2.jpg" etc...

Can anyone help???

Many Thanks


Craig

Sound Doubling
hey folks.
basically i have an animation which together is about 2000 frames long i would say, probably less. anyways ive broken the animation down into scenes about 10 of them.
now my problem is with the audio, for the first 5 scenes, the sound plays fine, but then for some reason its like the sound doesnt wait for the animation and it whizzes off and plays sound from like 3 scenes along.
all the sounds are set to stream, and all the sounds are in their own layer and the layer ends when the sound does. the audio problem has nothin to do with the animation, because when i import the sound layers only into another flash movie, the same thing happens.
i have flash MX, i dont know if there are any updates that deal with this problem or not. but its really bothering me, because there is no real reason for it happening.
thanx for ur help guys
Ross

ps: ive also posted this onto the flash sound forum, im not sure if im allowed to post it here too, theres more people in this forum. sorry if ive broken a rule.

Doubling Variables
hello. I have an issue with some code I wrote, I was wondering if anyone could help...

I have event controls on movie clips imbedded into another movie clip with an event control on it. Therefore I used the eventListener and x/ymouse position to create the inner buttons. My problem is nextFrame(); did not work so i used variable frame inside of gotoAndPlay(frame); with an incrementing variable. However, it jumps to frames 1,2,4,6 (skipping frames 3,5,7) I can't figure out why my variables are doubling up. Here is the code:

var frame:Number = 0;
var my_event = new_Object();
my_event.target = but1;
Mouse.addListener(but1);

but1.onMouseDown = function(){
if (this.hitTest(_root._xmouse,_root._ymouse, true)){
but1.onPress;

frame = frame - 1;
gotoAndPlay(frame);

}
}
frame=0;
var my_event2 = new_Object();
my_event2.target = but2;
Mouse.addListener(but2);

but2.onMouseDown = function(){
if (this.hitTest(_root._xmouse,_root._ymouse, true)){
but2.onPress;

frame = frame + 1;
gotoAndPlay(frame);

}
}

any help would be greatly appreciated

Doubling The Score
Hi,

Is is possible to double the users score in a game with the use of a math function, i have tried the following but its been unsuccessful.

_root.score*2;

and

_root.score == _root.score*2;

Can anyone help?

Thanks

Random, Non-doubling Numbers.
Does anyone know how to get random numbers that dont reoccur until all of them have been used? know what im trying to say?

Interval Doubling On Speed
Greetings fellow flashers
I have troubles with interval doubling on speed; What I have is an mc (bigbox) that scrolls through my movie (the goBb function), and 3 mc's within (box1, 2 & 3) that I use as buttons.
What I want them to do is to stop scrolling on rollOver and continue on rollOut, what happens just fine the first time.
After that my scroller goes berserk, doesn't stop on rollOver, but rather doubles up on speed on each consecutive rollOut.
How do I stop it, and then set it off again each time?

Here's the code I've been using, I've commented out a couple lines just to make it more clear:

code:
var bby = bigbox._y;
function goBb() {
bigbox._y = bby;
bby--;
if (bby<=-30) {
bby = 180;
}
}
var scrolly = setInterval(goBb, 50);
bigbox.box1.onRollOver = function() {
clearInterval(scrolly);
};
//bigbox.box2.onRollOver = bigbox.box3.onRollOver = bigbox.box1.onRollOver;
bigbox.box1.onRollOut = function() {
var scrolly = setInterval(goBb, 50);
};
//bigbox.box2.onRollOut = bigbox.box3.onRollOut = bigbox.box1.onRollOut;

Thanx

Sound Starts Doubling Over...?
Previously i posted that the sound wasn't syncing up with my animation when i exported it in flash. I figured out that it starts doubling over on itself at a certain scene and i have no clue as to why.

can anyone help? Is there something I can do to fix the audio track?

Is There A Tool Fo Doubling Length?
Is there a tool to double triple or quadruple the length of frames in the movie (aka: would put a frame between everyother, or something line that). Or do I just have to expand the length of my movie by hand.
Thanks,
-Alex K

Scroller Question - I'm Doubling It Up
i wonder if you guys knows about this cool scrollbar tutorial available at kirupa:

http://www.kirupa.com/forum/showpost...1&postcount=63

well if you go through it, you'll notice that the mousewheel scrolling acted as a global function, even if your mouse is not inside the scrolling area it'll still be working.

i was wondering if anyone of you knows how to make it only scrolls when the mouse is in the content area. this is because i'm trying to have two scrollable area in my flash movie, but if i used that original code, both the contents scroll up and down when i moved my mouse, help!!!

i can get it quite good, just need something to start with, thanks

Hide Contents Of Swf? Is There Any Way Of Hiding The Contents Of My Main Swf?
When my main swf site is loaded in a browser, is there any way of hiding the contents of my swf from users? Right now, anyone can just go to the 'activity' window and download any of my pictures, scripts, etc....and i don't like that.
Thanks,
Dave

Doubling Frame Length Of Instances Automatically
I have done an animation that I realised now is far too quick. I resolved the problem by changing the frame rate from 24 fps to 12 fps. However as a result some of the transitions aren't as smoothe as they were before.

Do you know how I can quickly resolve this issue without manually going through all the instances and doubling their frame length?

Many thanks,

leao

[MX04]ScroolPane Doubling Up Text (getting VERY Annoyed)
Hi
I've been using the scroll pane componant to display long pieces of text(I've basically just turned the text blocks into movie clips). For most of my text blocks this has worked fine, except for two of the longest ones where either only part of the text appears and there is a big blank space where the rest should appear(the pane still compensates for the where the text should be) or the text sort of breaks itself appart and displays one block over top of the other. Has anyone ever encountered this before and have a solution?

Frame Doubling When Importing Animated Gifs
Hey guys!
It's time to help out your buddy from serverside. I'm putting some animated gifs into a flash movie. I have about 20 gifs that I need to put in there, but the problem is that when I put some of them in there the frames of some are doubled. As in two frames appear in one frame and they're on top of each other. This happends randomly. One some gif's the effect happens, on others it doesn't. Here's an example:
http://alisic.net/byob/byobrace.html
See, on the first gif it doesn't happen but on the second gif there's this strange doubling. For reference, I've attached the second gif so you see how it should display.
Has anything like this happened to anyone yet?
The way I import them is I choose Insert -> New symbol and then I import the gif onto the stage. I'm using Flash 8.

Key Events Of A Loaded SWF Are Doubling/ Tripling As Reloade
Loaded SWF's KEY events are doubled, tripled, etc. as the SWF is reloaded (via Movie Clip Loader class, AS 2.0).

site....http://www.renickwoods.com

I'm dynamically loading the pictures from one XML source.... but I've divided them into chapters and loaded that node per section of the site. As you load a certain chapter in and go back to the home menu, each additional time you reload the child swf, the KEY events are firing x number of times.

I've tried from the outer swf 'home' button to remove the child key listner.

I've tried canceling it from within the loaded swf after certain points.

Any ideas how to keep the re-loading swf from multiplying its Key Events?

Movie Clip Render Problem: Pixel Doubling?
Hi, I am trying to simply use some icons as movie clips. I'm experiencing the problem in both Vista and XP that movieclips rendered at 100% scaling (exactly) are rendered with the center pixel column looks like it's doubled!

It does not look like this while editing, but in testing or viewing the published result, the icons are just slightly bigger than they should be. If the scaling is just slightly off from 100% it doesn't do this. The same bitmap from which the movie clip was created renders fine at 100%. I need these to be movieclips because I want to do some AS with them.

Has anyone else experienced this? I can't find a single reference to it... I'm using Flash 6.

Array, Array HELP - Importing A External File Into N ARRAY - Almost There
I am reading and external file with the following code:

ActionScript Code:
on (release, keyPress "<Enter>") {
lv = new LoadVars();
lv.onLoad = function() {
questions1 = this.filelist0.split(",");
answers1 = this.filelist1.split(",");
for(i=0;i<questions1.length;i++)
//trace(questions1[i]+"   "+answers1[i]);
trace(questions1[i]);

//assumes same number of scores in each list
};
lv.load("questions.txt");
}


When I parse the file it puts it into an columar format as it should...however I need it to look like this:

questions1=new Array ("2+4=?","What is the capital of Illinois?","What color is the sky?","10x(5+2)=?");

answers1=new Array ("8","springfield","blue","70");


How do I do that?

Text file look like this:

&questions1=2+4=?,What is the Capital of Illinois?,What color is the sky?,10x(5+2)=?")&
&answers1=8,springfield,blue,70&

Swap Contents In A MC
I am working on a template for a window-style website. Right now I am working on having the user move the window around by dragging the titlebar. I don't really like how the whole MC is visible while dragging so I thought of replacing the original MC with an MC of just the frame of the window. When the user presses down the mouse button while over the title bar the frame will appear, then when they release the original window will re-appear and the stopDrag(); function will execute.

Does anyone know an easy way of swapping the contents of an MC with another while still retaining all of the actions within a Movie Clip?
I've thought of making a frame MC in the original one and just have it above everything else and have it invisible, then have it become visible when the user clicks and have a background inside the frame that would block out the original window. But I would like to have the background behind everything visible when dragging, so that was no good.

Any ideas?

Createtextfield And Add Contents
Hi I have a question:

I have created a textfield using the code below:

counter=5;
for (i=0; i<counter; i++) {

help = "t_txt"+i;
here.createTextField(help, 1, 100, 100, 1, 1);
here.t_txt0.autoSize = true;
here.t_txt0.text += "blablabla";

}

This works except for the contents. I would like to change the value of t_txt0 in this line:

here.t_txt0.text += "blablabla";

to t_txt1, t_txt2, etc. I tried several options but I can't get it to work. Does anyone know what code to use to solve this?

Missing Contents
Hi I created a game interface in flash mx 2004 that has 3 panels that when on click of a button it the contents in the panel will scroll. I want to ask why the one, two or all the panels' content got missing at the end of the scrolling. The 3 panels are supposed to show 3 pictures at the end of the random scrolling.

Getting Contents Of A Directory
Is there anyway to get the contents of a directory like the directory where .swf file is in without the use of outside scripts? So that flash can see what image file names are in there and then load them.

Move Contents Of One .fla To Another?
I have one .fla containing actions, images, text, accross several layers.

I'd like to move all of this content into another .fla (preferably inside its own movie clip) so that it can exist on a keyframe on the stage.

I can't see how to do this without copying over every individual item? I don't want to load a swf into my other document, I need the source.

Any help please?

Saving SWF Contents
Can we save the over moviclip as image(JPG) using actionscript like with the SharedObject class

Emptying A MC Contents First?
Hi There,

Im using the fix below to load smoothed images to Flash 8 and use as a background for my flash movies..... however normally I can just load a bitmap to a certain target and it replaces the contents, however this script seems to load the images on top of each other, so when I do an alpha fade it really bogs down.....

Is there anyway to have it replace its own contents first?

import flash.display.*;

function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our
// unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(
"bmc",
target.getNextHighestDepth());

// Create a listener which will notify us when
// the bitmap loaded successfully
var listener:Object = new Object();

// Track the target
listener.tmc = target;

// If the bitmap loaded successfully we redraw the
// movie into a BitmapData object and then attach
// that BitmapData to the target movie clip with
// the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;

var bitmap:BitmapData = new BitmapData(
mc._width,
mc._height,
true);

this.tmc.attachBitmap(
bitmap,
this.tmc.getNextHighestDepth(),
"auto",
true);

bitmap.draw(mc);
};

// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}

Then I am using for example:

loadBitmapSmoothed("flashbacks/hallways.jpg",my_mc)


Thanks for any help!

Copyright © 2005-08 www.BigResource.com, All rights reserved