This tutorial will cover one of the most interesting and powerful Variable Types in Actionscript,"The Arrays.
Well to get this Simple for you , the Array is an Object that lets you save, access and manipulate the content of the Arrays.
The Array is an object whose properties are identified by a number representing their position in the array, this Number is referred by "index", All Array starts with the Index 0.
and there is no better than example to clarify this, I will Create an Array Called ourArray.


ourArray[0] = "Monday"
ourArray[1] = "Tuesday"
ourArray[2] = "Wednesday"
ourArray[3] = "Thursday"

Now let's discuss what we can do with this Arrays, Normally Arrays stores a lot different data from Strings , Integers , Complex object to Arrays , which means that you can create a multi-dimension Array by inserting an Array into another.
This is an Array holding a different type of Variable.

//lets create ourArray
var ourArray = new Array("I am String into my our Array" );

//lets create myArray
myArray[0] = "I am a String";
myArray[1] = 5; // I am a number.
myArray[2] = ourArray ; // I am an Array

trace(myArray[2][0]); // The output will be "I am String into my our Array".


The Array Object has several method for manipulating the array.
Array.concat : Concatenates the parameters and returns them as a new array. Example:

num1=[1,3,5];
num2=[2,4,6];
num3=[7,8,9];
nums=num1.concat(num2,num3)
trace(nums);
// creates array [1,3,5,2,4,6,7,8,9]

Array.join : Joins all elements of an array into a string.. Example:

a = new Array("Mon","Tue","Wed")
trace(a.join());
// returns Mon, Tue, Wed
trace(a.join(" - "));
// returns Mon - Tue - Wed
trace(a.join(" + "));
// returns Mon + Tue + Wed


http://www.consumerbag.com/

Posted in Libellés : 0 commentaires Publié par y. elhafyani à l'adresse 6:55 AM  




Slideshow is really kinda rare at the internet , I tried to look at some ready Slideshow that need just some modification and here we are ready , but it seems that I can't find what I want, that why I want to write this tutorial to help some people like me that are interested in a slide show .

This slide show is made with Flash 8 and ActionScript 2, and Will use the XML File .

The XML File "filelist.xml" would look like something like this :


<?xml version="1.0" encoding="utf-8"?>
<imagelist> <pix>img1.jpg</pix>
<pix>img2.jpg</pix>
<pix>img3.jpg</pix>
</imagelist>

At the First Frame Paste This Code



var counter:Number = 0;


var XMLValue:XML = new XML();
XMLValue.ignoreWhite = true;
XMLValue.load("filelist.xml");
XMLValue.onLoad = function(success) {

if (success) {
ChangeClip(XMLValue);
intervalId = setInterval(ChangeClip, 10000, XMLValue );
}

};



function ChangeClip(XMLValue) {
element = XMLValue.firstChild;

if(element.childNodes[counter].firstChild.nodeValue==undefined){
counter = 0;
}




this.createEmptyMovieClip("ourMovieClip",this.getNextHighestDepth());
ourMovieClip._alpha = 0;


loadMovie(element.childNodes[counter].firstChild.nodeValue, "ourMovieClip");

easeType = mx.transitions.easing.Regular.easeOut;
var begin = 20;
var end = 100;
var time = .5;
var mc = ourMovieClip;

ballTween = new mx.transitions.Tween(mc, "_alpha", easeType, begin, end, time, true);

counter++;


}

Now let's Analyse the code a little bit for more understanding to this slideshow.

var XMLValue:XML = new XML();
XMLValue.ignoreWhite = true;
XMLValue.load("filelist.xml");
XMLValue.onLoad = function(success) {

if (success) {
ChangeClip(XMLValue);
intervalId = setInterval(ChangeClip, 10000, XMLValue );
}

};
This Snippet of Code will load the xml file , and will launch the function ChangeClip() with an interval of 10 seconds , which means that the function will be repeated each 10 seconds and will change the picture.

function ChangeClip(XMLValue) {
element = XMLValue.firstChild;

if(element.childNodes[counter].firstChild.nodeValue==undefined){
counter = 0;
}




this.createEmptyMovieClip("ourMovieClip",this.getNextHighestDepth());
ourMovieClip._alpha = 0;


loadMovie(element.childNodes[counter].firstChild.nodeValue, "ourMovieClip");

easeType = mx.transitions.easing.Regular.easeOut;
var begin = 20;
var end = 100;
var time = .5;
var mc = ourMovieClip;

ballTween = new mx.transitions.Tween(mc, "_alpha", easeType, begin, end, time, true);

counter++;


}

This Snippet of code is a function that will load the image or the Movie Clip in the Stage and will increase the value of the counter

the Transition that was used here is a type of transition that wasn't documented in the flash class documentation , there is a lot different method for doing this kind of transition , so you can have a different type of transition.

Download the FLA Image SlideShow

Posted in Libellés : , 0 commentaires Publié par y. elhafyani à l'adresse 10:12 AM  

 
Copyright 2005-2008 Flash RIA .