...

View Full Version : Create a random image changing script



alexmel7
05-04-2009, 09:00 PM
Hi, I want to create a script that randomly selects one image from a set of images and then fades into another random image from the set of images. Does anyone know of a script that exists that does this or something close to it?

Aldo
05-04-2009, 10:06 PM
..IŽll been searching for the same thing,
then I found this:

http://www.codingforums.com/showthread.php?t=129968

Now I need this get to work on my handset
nokia 6300 with flashlite 2.0

Don't work as screensaver!! :eek:

It seems that the problem is in the xml file (The phone only
reads the swf file) , although
plays well every time I openup normally..

I need some help

alexmel7
05-05-2009, 02:38 AM
Awesome, thanks Aldo. Can anyone help me modify this script so that instead of one set of pictures that crossfade into each other, I can have several picture holders that crossfade one picture into another, then randomly select another picture holder to crossfade a picture, etc. It would be set up like the pic below:

http://wri.eas.cornell.edu/example.jpg

gnomeontherun
05-05-2009, 08:58 AM
Hmm that would be a lot of code changes.

Are you wanting to create all of the movieClips with actionscript or are they already created on the stage?

You'll have to have some kind of function to select a random frame first, which depends on how you have (or want) to setup the containers.

alexmel7
05-05-2009, 04:11 PM
I haven't set up any of the movie clips yet. I didn't want to start without knowing the best way to approach this. Essentially all I have is my saved pictures and an empty fla.

gnomeontherun
05-05-2009, 09:54 PM
Good stuff.

Ok then. First task, creation of 8 movieClip holders. You interesting in tackling this yourself and posting your progress? I'll help!

Lets do it all with actionscript. Its more fun.

http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001394.html

This is some information about how to create a container movieClip. Task #1 is to replicate it so there are 8 displayed, and also they need to be positioned and sized (._y, ._x, ._width, ._height)

alexmel7
05-06-2009, 03:15 PM
Thank you for taking the time to help me and aid me in learning actionscript. Here is what I have so far:


_root.createEmptyMovieClip("box1_mc", 1);
box1_mc._x = 100;
box1_mc._y = 0 ;
box1_mc._width = 166;
box1_mc._height = 126;
_root.createEmptyMovieClip("box2_mc", 2);
box2_mc._x = 315;
box2_mc._y = 0;
box2_mc._width = 166;
box2_mc._height = 126;
_root.createEmptyMovieClip("box3_mc", 3);
box3_mc._x = 540;
box3_mc._y = 0;
box3_mc._width = 166;
box3_mc._height = 126;
_root.createEmptyMovieClip("box4_mc", 4);
box4_mc._x = 100;
box4_mc._y = 155;
box4_mc._width = 166;
box4_mc._height = 126;
_root.createEmptyMovieClip("box5_mc", 5);
box5_mc._x = 540;
box5_mc._y = 155;
box5_mc._width = 166;
box5_mc._height = 126;
_root.createEmptyMovieClip("box6_mc", 6);
box6_mc._x = 100;
box6_mc._y = 310;
box6_mc._width = 166;
box6_mc._height = 126;
_root.createEmptyMovieClip("box7_mc", 7);
box7_mc._x = 315;
box7_mc._y = 310;
box7_mc._width = 166;
box7_mc._height = 126;
_root.createEmptyMovieClip("box8_mc", 8);
box8_mc._x = 540;
box8_mc._y = 310;
box8_mc._width = 166;
box8_mc._height = 126;

gnomeontherun
05-06-2009, 05:16 PM
Perfect. Now we need to load a set of images. There is a good example in the thread posted above, and here is a tutorial. Basically you need to load the images from XML into an array so we can then assign them randomly.

http://www.kirupa.com/web/xml/XMLwithFlash3.htm

alexmel7
05-07-2009, 04:50 AM
Like this?


_root.createEmptyMovieClip("box1_mc", 1);
box1_mc._x = 100;
box1_mc._y = 0;
box1_mc._width = 166;
box1_mc._height = 126;

_root.createEmptyMovieClip("box2_mc", 2);
box2_mc._x = 286;
box2_mc._y = 0;
box2_mc._width = 166;
box2_mc._height = 126;
_root.createEmptyMovieClip("box3_mc", 3);
box3_mc._x = 472;
box3_mc._y = 0;
box3_mc._width = 166;
box3_mc._height = 126;

_root.createEmptyMovieClip("box4_mc", 4);
box4_mc._x = 100;
box4_mc._y = 167;
box4_mc._width = 166;
box4_mc._height = 126;

_root.createEmptyMovieClip("box5_mc", 5);
box5_mc._x = 472;
box5_mc._y = 167;
box5_mc._width = 166;
box5_mc._height = 126;

_root.createEmptyMovieClip("box6_mc", 6);
box6_mc._x = 100;
box6_mc._y = 334;
box6_mc._width = 166;
box6_mc._height = 126;

_root.createEmptyMovieClip("box7_mc", 7);
box7_mc._x = 286;
box7_mc._y = 334;
box7_mc._width = 166;
box7_mc._height = 126;

_root.createEmptyMovieClip("box8_mc", 8);
box8_mc._x = 472;
box8_mc._y = 334;
box8_mc._width = 166;
box8_mc._height = 126;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
randomImage();
}
}

gnomeontherun
05-07-2009, 08:54 AM
Good now you can trace the values to see if things are there correctly. Right now its going to also try to call randomImage() which isn't there, so it will cause errors at the moment.


function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}

Now from here we'll have to create a custom function. I guess I need to know how many images you'll have (approx.) and how you want to select them (randomly of course, but should all images be displayed before recycling or does it matter?)

alexmel7
05-07-2009, 04:35 PM
When I run it, the only output is "undefined". I have 65 images which I would like to be used before recycling. Here is my code:


_root.createEmptyMovieClip("box1_mc", 1);
box1_mc._x = 100;
box1_mc._y = 0;
box1_mc._width = 166;
box1_mc._height = 126;

_root.createEmptyMovieClip("box2_mc", 2);
box2_mc._x = 286;
box2_mc._y = 0;
box2_mc._width = 166;
box2_mc._height = 126;
_root.createEmptyMovieClip("box3_mc", 3);
box3_mc._x = 472;
box3_mc._y = 0;
box3_mc._width = 166;
box3_mc._height = 126;

_root.createEmptyMovieClip("box4_mc", 4);
box4_mc._x = 100;
box4_mc._y = 167;
box4_mc._width = 166;
box4_mc._height = 126;

_root.createEmptyMovieClip("box5_mc", 5);
box5_mc._x = 472;
box5_mc._y = 167;
box5_mc._width = 166;
box5_mc._height = 126;

_root.createEmptyMovieClip("box6_mc", 6);
box6_mc._x = 100;
box6_mc._y = 334;
box6_mc._width = 166;
box6_mc._height = 126;

_root.createEmptyMovieClip("box7_mc", 7);
box7_mc._x = 286;
box7_mc._y = 334;
box7_mc._width = 166;
box7_mc._height = 126;

_root.createEmptyMovieClip("box8_mc", 8);
box8_mc._x = 472;
box8_mc._y = 334;
box8_mc._width = 166;
box8_mc._height = 126;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
randomImage();
}
}

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}

gnomeontherun
05-07-2009, 06:03 PM
Do you have an XML file like the one exemplified in the same folder as your FLA? You should make one and put it in there, and if you have one already post a few lines of it. Something isn't getting picked up.

alexmel7
05-07-2009, 06:08 PM
I have it in the same folder as my FLA. My pics are in a subfolder called "pics". Here is the code:


<xml>
<images>
<a title = "pics/adirondack1.jpg" />
<b title = "pics/cayugaboces1.jpg" />
<c title = "pics/OU1.jpg" />
<d title = "pics/questar1pic1.jpg" />
<e title = "pics/stlawrencelewis1.jpg" />
<f title = "pics/tst1.jpg" />
<g title = "pics/WFL1.jpg" />
<h title = "pics/orleansniagra1.jpg" />
</images>
</xml>

gnomeontherun
05-08-2009, 10:04 AM
Well right now you have two loadImages functions, I didn't catch that last time...duh. You should remove the first one without the trace() statements for the moment, but keep a copy of it! Does that make it work?

alexmel7
05-08-2009, 03:23 PM
I tried that and I still get "undefined" as the output. Maybe it's the way I have things set up? I have an empty frame on the first frame of the root timeline where I'm putting all my actionscript. Here is the revised code:


_root.createEmptyMovieClip("box1_mc", 1);
box1_mc._x = 100;
box1_mc._y = 0;
box1_mc._width = 166;
box1_mc._height = 126;

_root.createEmptyMovieClip("box2_mc", 2);
box2_mc._x = 286;
box2_mc._y = 0;
box2_mc._width = 166;
box2_mc._height = 126;
_root.createEmptyMovieClip("box3_mc", 3);
box3_mc._x = 472;
box3_mc._y = 0;
box3_mc._width = 166;
box3_mc._height = 126;

_root.createEmptyMovieClip("box4_mc", 4);
box4_mc._x = 100;
box4_mc._y = 167;
box4_mc._width = 166;
box4_mc._height = 126;

_root.createEmptyMovieClip("box5_mc", 5);
box5_mc._x = 472;
box5_mc._y = 167;
box5_mc._width = 166;
box5_mc._height = 126;

_root.createEmptyMovieClip("box6_mc", 6);
box6_mc._x = 100;
box6_mc._y = 334;
box6_mc._width = 166;
box6_mc._height = 126;

_root.createEmptyMovieClip("box7_mc", 7);
box7_mc._x = 286;
box7_mc._y = 334;
box7_mc._width = 166;
box7_mc._height = 126;

_root.createEmptyMovieClip("box8_mc", 8);
box8_mc._x = 472;
box8_mc._y = 334;
box8_mc._width = 166;
box8_mc._height = 126;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}

alexmel7
05-10-2009, 05:04 PM
any suggestions?

gnomeontherun
05-10-2009, 09:05 PM
Suggestions ugh. I really do hate parsing XML in Flash, and this is why. Some reason I just can't grasp it without working with it, but check out this link and work with the trace to see what data you can get.

http://www.kirupa.com/web/xml/index.htm

So start tracing these


trace(this);
trace(xmlFirstChild);
trace(xmlFirstChild.childNodes);
trace(xmlFirstChild.firstChild.childNodes);

This will show you how it progresses down the chain, and there might be an extra childNodes in the current thing depending on how you structured your xml file.

alexmel7
05-11-2009, 05:39 PM
When I add:


trace(this);
trace(xmlFirstChild);
trace(xmlFirstChild.childNodes);
trace(xmlFirstChild.firstChild.childNodes);

I get the following output:


undefined
<xml><images><a title="pics/adirondack1.jpg" /><b title="pics/cayugaboces1.jpg" /><c title="pics/OU1.jpg" /><d title="pics/questar1pic1.jpg" /><e title="pics/stlawrencelewis1.jpg" /><f title="pics/tst1.jpg" /><g title="pics/WFL1.jpg" /><h title="pics/orleansniagra1.jpg" /></images></xml>
<xml><images><a title="pics/adirondack1.jpg" /><b title="pics/cayugaboces1.jpg" /><c title="pics/OU1.jpg" /><d title="pics/questar1pic1.jpg" /><e title="pics/stlawrencelewis1.jpg" /><f title="pics/tst1.jpg" /><g title="pics/WFL1.jpg" /><h title="pics/orleansniagra1.jpg" /></images></xml>
<images><a title="pics/adirondack1.jpg" /><b title="pics/cayugaboces1.jpg" /><c title="pics/OU1.jpg" /><d title="pics/questar1pic1.jpg" /><e title="pics/stlawrencelewis1.jpg" /><f title="pics/tst1.jpg" /><g title="pics/WFL1.jpg" /><h title="pics/orleansniagra1.jpg" /></images>
<a title="pics/adirondack1.jpg" />,<b title="pics/cayugaboces1.jpg" />,<c title="pics/OU1.jpg" />,<d title="pics/questar1pic1.jpg" />,<e title="pics/stlawrencelewis1.jpg" />,<f title="pics/tst1.jpg" />,<g title="pics/WFL1.jpg" />,<h title="pics/orleansniagra1.jpg" />

bigtiger
05-12-2009, 06:58 AM
I tried that and I still get "undefined" as the output. Maybe it's the way I have things set up? I have an empty frame on the first frame of the root timeline where I'm putting all my actionscript. Here is the revised code:


_root.createEmptyMovieClip("box1_mc", 1);
box1_mc._x = 100;
box1_mc._y = 0;
box1_mc._width = 166;
box1_mc._height = 126;

_root.createEmptyMovieClip("box2_mc", 2);
box2_mc._x = 286;
box2_mc._y = 0;
box2_mc._width = 166;
box2_mc._height = 126;
_root.createEmptyMovieClip("box3_mc", 3);
box3_mc._x = 472;
box3_mc._y = 0;
box3_mc._width = 166;
box3_mc._height = 126;

_root.createEmptyMovieClip("box4_mc", 4);
box4_mc._x = 100;
box4_mc._y = 167;
box4_mc._width = 166;
box4_mc._height = 126;

_root.createEmptyMovieClip("box5_mc", 5);
box5_mc._x = 472;
box5_mc._y = 167;
box5_mc._width = 166;
box5_mc._height = 126;

_root.createEmptyMovieClip("box6_mc", 6);
box6_mc._x = 100;
box6_mc._y = 334;
box6_mc._width = 166;
box6_mc._height = 126;

_root.createEmptyMovieClip("box7_mc", 7);
box7_mc._x = 286;
box7_mc._y = 334;
box7_mc._width = 166;
box7_mc._height = 126;

_root.createEmptyMovieClip("box8_mc", 8);
box8_mc._x = 472;
box8_mc._y = 334;
box8_mc._width = 166;
box8_mc._height = 126;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}


This should be work.



function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}
}

gnomeontherun
05-12-2009, 07:14 AM
Yes?


xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.firstChild.childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.firstChild.childNodes[i].attributes.title;
}
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}

alexmel7
05-12-2009, 02:25 PM
Yes sir, that worked bigtiger. Thanks. Here is code and output:


_root.createEmptyMovieClip("box1_mc", 1);
box1_mc._x = 100;
box1_mc._y = 0;
box1_mc._width = 166;
box1_mc._height = 126;

_root.createEmptyMovieClip("box2_mc", 2);
box2_mc._x = 286;
box2_mc._y = 0;
box2_mc._width = 166;
box2_mc._height = 126;

_root.createEmptyMovieClip("box3_mc", 3);
box3_mc._x = 472;
box3_mc._y = 0;
box3_mc._width = 166;
box3_mc._height = 126;

_root.createEmptyMovieClip("box4_mc", 4);
box4_mc._x = 100;
box4_mc._y = 167;
box4_mc._width = 166;
box4_mc._height = 126;

_root.createEmptyMovieClip("box5_mc", 5);
box5_mc._x = 472;
box5_mc._y = 167;
box5_mc._width = 166;
box5_mc._height = 126;

_root.createEmptyMovieClip("box6_mc", 6);
box6_mc._x = 100;
box6_mc._y = 334;
box6_mc._width = 166;
box6_mc._height = 126;

_root.createEmptyMovieClip("box7_mc", 7);
box7_mc._x = 286;
box7_mc._y = 334;
box7_mc._width = 166;
box7_mc._height = 126;

_root.createEmptyMovieClip("box8_mc", 8);
box8_mc._x = 472;
box8_mc._y = 334;
box8_mc._width = 166;
box8_mc._height = 126;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}
}



Output:


pics/adirondack1.jpg
pics/cayugaboces1.jpg
pics/OU1.jpg
pics/questar1pic1.jpg
pics/stlawrencelewis1.jpg
pics/tst1.jpg
pics/WFL1.jpg
pics/orleansniagra1.jpg

gnomeontherun
05-12-2009, 03:42 PM
Ha, silly me. Ok now we need a function to randomly assign these images to the containers.

Since we have all of the images in the array imageFileName, we can push and pop the values from this array as we use the images and put them into a new array that will hold the displayed images (so we don't get repeats). This will put the first images into the containers, and then we'll write another function to handle the changing of images. Here is something to get you started. NOT TESTED, just made from my head.


function assignInitialImages(imageFileName)
{
usedImages:Array = new Array();

imageFileName.sort(function(){return random(2)});

for (z=1;z<9;z++)
{
var clip = "box" + z + "_mc";
var newImage = imageFileName.pop();
loadMovie(clip, newImage);
usedImages.push(newImage);
}

}

alexmel7
05-12-2009, 04:12 PM
Awesome. Should usedImages:Array = new Array(); be var usedImages:Array = new Array(); though?

Also, why is that I cannot see the images yet when I test the movie?

gnomeontherun
05-13-2009, 08:44 AM
You are correct, should put var in front. Like I said I just wrote that quickly to describe the concept, but if its not working (not surprised) start by tracing both clip and newImage to see if they are holding the correct values. You may need to access clip like this or something like this with _root as a prefix (since its used above, Flash gets picky sometimes about paths).


_root[clip]

alexmel7
05-13-2009, 02:22 PM
If I put in the following, the only output I get is still from the trace for the image file names.


function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}
}

function assignInitialImages(imageFileName)
{
var usedImages:Array = new Array();

imageFileName.sort(function(){return random(2)});

for (z=1;z<9;z++)
{
var clip = "box" + z + "_mc";
var newImage = imageFileName.pop();
loadMovie(_root[clip], newImage);
usedImages.push(newImage);
trace(clip);
trace(newImage);
}

}

gnomeontherun
05-13-2009, 02:33 PM
See bolded area for a change, this is a good reference about this topic.

http://www.sanctifiedstudios.com/dynamic-movie-clip-referencing-in-actionscript/


function assignInitialImages(imageFileName)
{
var usedImages:Array = new Array();

imageFileName.sort(function(){return random(2)});

for (z=1;z<9;z++)
{
var clip = "box" + z + "_mc";
var newImage = imageFileName.pop();
loadMovie(this.clip, newImage);
usedImages.push(newImage);
trace(clip);
trace(newImage);
}

}

bigtiger
05-13-2009, 04:50 PM
function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
}
}

function assignInitialImages(imageFileName)
{
var usedImages:Array = new Array();

imageFileName.sort(function(){return random(2)});

for (z=1;z<9;z++)
{
var clip = "box" + z + "_mc";
var newImage = imageFileName.pop();
loadMovie(_root[clip], newImage);
usedImages.push(newImage);
trace(clip);
trace(newImage);
}

}
@alexmel7, That's great !! Get fun with coding !!

I have modified some code, this should be,


function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
trace(imageFileName[i]); // Should give you the file name for each image in the trace window
}
assignInitialImages(imageFileName);
}
}

function assignInitialImages(imageFileName)
{
var usedImages:Array = new Array();

imageFileName.sort(function(){return random(2)});

for (z=1;z<9;z++)
{
var clip = "box" + z + "_mc";
var newImage = imageFileName.pop();
loadMovie(newImage, this[clip]);
usedImages.push(newImage);
trace(clip);
trace(newImage);
}

alexmel7
05-13-2009, 05:35 PM
Awesome! Now I get the following output (and when I test the movie multiple times, I can see it is randomly assigning an image to each box!):


pics/adirondack1.jpg
pics/cayugaboces1.jpg
pics/OU1.jpg
pics/questar1pic1.jpg
pics/stlawrencelewis1.jpg
pics/tst1.jpg
pics/WFL1.jpg
pics/orleansniagra1.jpg
box1_mc
pics/orleansniagra1.jpg
box2_mc
pics/cayugaboces1.jpg
box3_mc
pics/WFL1.jpg
box4_mc
pics/adirondack1.jpg
box5_mc
pics/questar1pic1.jpg
box6_mc
pics/stlawrencelewis1.jpg
box7_mc
pics/tst1.jpg
box8_mc
pics/OU1.jpg

gnomeontherun
05-13-2009, 08:43 PM
Thanks for that, I get wrapped up in one issue that I often forget something completely obvious, like calling the function :) This is kind of fun, like a tutorial help thread all in one.

You can remove the trace functions, we won't mess with those functions so they shouldn't break.

Now we need to come up with an event handler to switch the images in and out randomly. How do you want that to function again? Like ever # seconds one of the boxes is randomly selected and the image swapped (we'll add a nice fade or something) or does it need to respond to some other kind of event?

alexmel7
05-13-2009, 11:17 PM
Yeah, it doesn't need to respond to an event. Just a nice calm fade between two pictures in one box, then a fade between two pictures in another box...continuously until all pictures are used than start again. I have to add the rest of the pictures to the xml file for a total of 65.

gnomeontherun
05-14-2009, 08:37 AM
So you will next to use a mixture of the setInterval functions, Tween Class, and reuse the concepts of pushing and poping values from those arrays to make a function.

Basically try using setInterval to call a new function every 5 seconds (or whatever you want) that handles the transitions. Don't worry about what to do when it hits the end just yet.

http://www.actionscript.org/resources/articles/120/1/Intervals-in-Flash-with-setInterval/Page1.html

http://www.kirupa.com/developer/actionscript/tween.htm

alexmel7
05-14-2009, 07:32 PM
Ok, don't laugh. I tried to come up with something and I feel like I learned a lot, but I'm pretty sure it's far from right. Here it is:


import mx.transitions.Tween;
import mx.transitions.easing.*;

function changeBox() {
myInterval = setInterval(transition_image, 2);
function transition_image() {
clearInterval(myInterval);
var pictureTweenOut:Tween = new Tween (newImage,"_alpha",Normal.easeOut,100,0,3,true);
usedImages.push(newImage);
var pictureTweenIn:Tween = new Tween (newImage,"_alpha",Normal.easeIn,0,100,3,true);
}

}

alexmel7
05-18-2009, 10:06 PM
Any thoughts on the code?

alexmel7
05-21-2009, 01:21 PM
anyone?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum