1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.geom.Matrix;
ciel._visible=false; // Movie clip de l'image de base
var bitmapData = new flash.display.BitmapData(550,400,true,0x00000000);
var myMatrix:Matrix = new Matrix();
myMatrix.scale(1, 1);
bitmapData.draw(ciel,myMatrix);
var largeur:Number=60;
var hauteur:Number=50;
var nb_hexa:Number=0;
var origine_x:Number=-20;
var origine_y:Number=-55;
for (pos_x=1;pos_x<=20;pos_x++)
{
for (pos_y=1;pos_y<=20;pos_y++)
{
if ( (!((pos_x+2)%2) && !((pos_y+2)%2)) || ((pos_x+2)%2 && (pos_y+2)%2) )
{
nb_hexa++;
this["conteneur"+nb_hexa]=this.createEmptyMovieClip(this["conteneur"+nb_hexa],this.getNextHighestDepth());
this["bitmapData_"+nb_hexa]=new BitmapData(largeur,hauteur,true,0x00FF0000);
this["conteneur"+nb_hexa].image=this["conteneur"+nb_hexa].createEmptyMovieClip(this["conteneur"+nb_hexa].image,this.getNextHighestDepth());
this["conteneur"+nb_hexa].image.attachBitmap(this["bitmapData_"+nb_hexa],this.getNextHighestDepth());
this["conteneur"+nb_hexa].onPress=function() { this.startDrag(); };
this["conteneur"+nb_hexa].onRelease=function() { this.stopDrag(); };
this["conteneur"+nb_hexa]._x=origine_x+((pos_x-1)*((largeur/3)*2));
this["conteneur"+nb_hexa]._y=origine_y+(pos_y*(hauteur/2));
this["bitmapData_"+nb_hexa].copyPixels(bitmapData,new Rectangle(this["conteneur"+nb_hexa]._x,this["conteneur"+nb_hexa]._y,largeur,hauteur),new Point(0,0));
// Création du clip masque
this["conteneur"+nb_hexa].masque=this["conteneur"+nb_hexa].createEmptyMovieClip(this["conteneur"+nb_hexa].masque,this.getNextHighestDepth());
// Attach du movie contenant l'hexagone
this["conteneur"+nb_hexa].masque=attachMovie("hexa_vide","masque",this.getNextHighestDepth());
// Application du masque
this["conteneur"+nb_hexa].image.setMask(this["conteneur"+nb_hexa].masque);
}
}
}
stop(); |
Partager