-
Problem generating clickable movieclips actionscript
Hi everybody! This is my first post here, I'm not such a board-fanatic, but maybe I could become one fast :wink:
This is my actionscript problem (AS2)
The aim if this script is to load images from a xml, show them on screan, and when clicking on one of them, show the big one. I know there are a lot of ready-made scripts, but as I would like to learn AS, I try to do it myself....
Now the problem actually is the onRelease... in this example whatever the picture i clic, I always get: "clicked on image: 5" as output.. (when 5 images are loaded...)
Anybody has a clue?
I suppose there are a lot of mistakes and maybe better ways to do in this script, but as I said, I'm a newbie, so don't hesitate to tell me!
Thanks a lot!!!
Vincent (French speaking)
Code:
//////////////////////////
//PARAMETERS
//////////////////////////
espacement = 10;//l'espacement en px entre les images
displayinterval = 200;//interval de chargement des images en ms
xmlfile = "test.xml";//fichier xml a utiliser (peut etre variable);
//////////////////////////
//LOADING IMAGES AND LINKING
//////////////////////////
Fichier_XML = new XML();
Fichier_XML.ignoreWhite = true;
Fichier_XML.load(xmlfile);
Fichier_XML.onLoad = function(Reussite)
{
if (Reussite)
{
_root.x = Fichier_XML.childNodes[0];//Is the main Node: <main>
for(i = 0; x.childNodes[i] != undefined; i++)
{
var mc = createEmptyMovieClip("picture"+i, i);
mc.createEmptyMovieClip("thumb", 0);
loadMovie(x.childNodes[i].childNodes[2].firstChild,mc.thumb); //the node here contains an jpg URL
mc.onRelease = function ()
{
trace("clicked on image: "+i);
}
}
totalpictures = i;//to know how many images have been loaded...
}
}
//////////////////////////
//POSITIONING
//////////////////////////
this.onEnterFrame = function()
{
nombreparrangee = 3;
for(i=0;i<totalpictures;i++)
{
//colonne de 0
colonne = Math.ceil((i+1)/nombreparrangee)-1;
//ligne (0,1,2) a partir de 0
ligne = (i-(colonne*nombreparrangee));
//le saut par bloc
saut = picture0._width+espacement;
//Application des parametres
this["picture"+i]._x -= (this["picture"+i]._x-(espacement + (colonne*saut)))/5;
this["picture"+i]._y -= (this["picture"+i]._y-(espacement + (ligne*saut)))/5;
}
}
-
Ryan Thomson
hmm, I would think that would work.. try changing:
PHP Code:
mc.onRelease = function ()
to
PHP Code:
this["picture"+i].onRelease = function()
-
no
thanks for your answern but by doing this....
Code:
if (Reussite)
{
_root.x = Fichier_XML.childNodes[0];//Is the main Node: <main>
for(i = 0; x.childNodes[i] != undefined; i++)
{
var mc = createEmptyMovieClip("picture"+i, i);
mc.createEmptyMovieClip("thumb", 0);
loadMovie(x.childNodes[i].childNodes[2].firstChild,mc.thumb); //the node here contains an jpg URL
this["picture"+i].onRelease = function()
{
trace("clicked on image: "+i);
}
}
totalpictures = i;//to know how many images have been loaded...
}
then they're not clickable anymore... they've just gor the normal mouse when rolling over
but thanks for answering
-
I got it!!
this is it:
PHP Code:
if (Reussite) { _root.x = Fichier_XML.childNodes[0];//Is the main Node: <main> for(i = 0; x.childNodes[i] != undefined; i++) { mc = createEmptyMovieClip("picture"+i, i); mc.createEmptyMovieClip("thumb", 0); loadMovie(x.childNodes[i].childNodes[2].firstChild,mc.thumb); //the node here contains an jpg URL mc.indice = i; mc.onRelease = function() { trace(this.indice); } } totalpictures = i;//to know how many images have been loaded... }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|