Probleme pour executer un script

Résolu
cs_Zanglar Messages postés 3 Date d'inscription jeudi 11 mai 2006 Statut Membre Dernière intervention 16 octobre 2006 - 14 oct. 2006 à 22:38
cs_Zanglar Messages postés 3 Date d'inscription jeudi 11 mai 2006 Statut Membre Dernière intervention 16 octobre 2006 - 16 oct. 2006 à 16:53
Bonjour, je ne connais rien en flash et j'ai tenté de faire le tutorial qui se trouve ici:
http://oos.moxiecode.com/tut_01/index.html
qui peut se resumer a ces quelques lignes:


Make a movieclip(ctrl-F8), name it 'tile'. In the first frame draw a
white square with a black hairline, make it 16x16 (width x height),
center it. In the second frame, make a copy of the first one and fill
it with black. Now we got two simple tiles.


Now lets make function that draws our simple map.

But first let´s go back to the tile-movieclip we made earlier, open the
library(ctrl-L), rightclick the tile-mc choose linkage, check 'export
this symbol', then write 'tile' in the identifer-field.



Now open your actionscript window on the first frame on the main timeline. Put the myMap-array there.

On to the mapdrawing-function.

et voila le code a utiliser:
--------------------------------------------------------------------------------------------------

// ### code start
// no scaling of the flashmovie...
fscommand ( "allowscale", false );
// constants of the tiles width and height
tileW = 16;
tileH = 16;
// our map-array
myMap = [ [1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,1],
[1,0,1,0,0,0,0,1],
[1,0,0,0,0,1,0,1],
[1,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1] ];

// the mapdrawing-function
function buildMap (map) {
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var i = 0; i < mapHeight; ++i) {
for (var j = 0; j < mapWidth; ++j) {
this.attachMovie("tile", "t_"+i+"_"+j, ++d);
this["t_"+i+"_"+j]._x = (j*tileW);
this["t_"+i+"_"+j]._y = (i*tileH);
this["t_"+i+"_"+j].gotoAndStop(map[i][j]+1);
}
}
}

// calls the mapdrawing-function with the argument myMap
buildMap (myMap);
// ### code end

-------------------------------------------------------------------------------------------------
je suis censé obtenir un damier de 8*6 ou les 1 de myMap representent les cases noires et les 0 les cases blanches  et soit je n'obtient rien (quand je met le script dans le videoclip) soit je n'obtient qu'une case noire (quand je met le script dans le scene1)

j'ai uploadé une video de ce que je fais au cas ou mais l'upload entraine une perte de qualité:
http://www.youtube.com/watch?v=SIX6NADBF94

J'espere sincerement que quelqu'un pourra m'expliquer d'ou vient le probleme parce que je suis sur que c'est un simple probleme de configuration ou d'endroit ou mettre le script.
Merci d'avance.

4 réponses

cs_Girou Messages postés 1203 Date d'inscription lundi 10 mars 2003 Statut Membre Dernière intervention 23 juillet 2009 2
16 oct. 2006 à 12:06
Salut,

essaye en remplaçant ta fonction buildMap par ceci

function buildMap (map) {
   var tileW:Number = 16;
   var tileH:Number= 16;
   var mapWidth:Number = map[0].length;
   var mapHeight:Number = map.length;
   for (var i:Number = 0; i < mapHeight; ++i) {
      for (var j:Number = 0; j < mapWidth; ++j) {
         var _mc:MovieClip= this.attachMovie("tile", "t_"+i+"_"+j, this.getNextHighestDepth());
         _mc._x = (j*tileW);
         _mc._y = (i*tileH);
         _mc.gotoAndStop(map[i][j]+1);
      }
   }
}

@+
3
cs_Zanglar Messages postés 3 Date d'inscription jeudi 11 mai 2006 Statut Membre Dernière intervention 16 octobre 2006
16 oct. 2006 à 13:21
Merci beaucoup. Ca marche meme si je ne comprends pas ton code pour l'instant, j'ai encore du boulot :). Le code que j'ai n'est donc plus a jour?
0
cs_Girou Messages postés 1203 Date d'inscription lundi 10 mars 2003 Statut Membre Dernière intervention 23 juillet 2009 2
16 oct. 2006 à 15:29
Salut,

c'est de l'actionscript 1 (pour flash 5 si tu va revoir ta source )
L'adaptation que j'ai proposé est en AS2

@+
0
cs_Zanglar Messages postés 3 Date d'inscription jeudi 11 mai 2006 Statut Membre Dernière intervention 16 octobre 2006
16 oct. 2006 à 16:53
OK Merci
0
Rejoignez-nous