flash - Display in full screen squares -
in flash as3, created 25 squares event (when click in 1 of square displays in total screen) works on square on middle (it's normal because it's in middle) other exceeds screen... how can display them on same middle?
package { import flash.display.*; import flash.events.*; import gs.*; import flash.text.textfield; public class fenetre extends movieclip { var mc:movieclip; var bol:boolean; public function fenetre(px,py,largeur) { mc = new movieclip(); // instanciation de l'objet movieclip mc.x = px; // détermination de sa positon en x mc.y = py; // détermination de sa positon en y addchild(mc); // affichage de l'objet mc mc.graphics.beginfill(0xffffff); mc.graphics.linestyle(.1,255);//épaisseur contour, couleur de contour mc.graphics.drawrect(-largeur/2,-largeur/2,largeur,largeur); mc.graphics.endfill(); mc.scalex = mc.scaley = .166; //.5=0.5 // mc.buttonmode = true; mc.addeventlistener(mouseevent.click,onclique); } private function onclique(e:mouseevent):void { bol=!bol; if(bol){ tweenlite.to(mc,1,{scalex:1,scaley:1,oncomplete:plein_ecran()}); } else { tweenlite.to(mc,1,{scalex:.166,scaley:.166}); } } private function plein_ecran(){ var num:int=movieclip(parent).numchildren-1; movieclip(parent).setchildindex(this,num); } private function decharger(){ //trace("decharger"); } public function createtextfield(x:number, y:number, width:number, height:number, nbre:int):textfield { var result:textfield = new textfield(); result.x = x; result.y = y; result.width = width; result.height = height; result.text = nbre.tostring(); addchild(result); homecoming result; } }
}
i display squares in main class :
package { import flash.display.*; import flash.text.textfieldautosize; [swf(width=600,height=600)] public class main extends movieclip { var fenetre:fenetre; var xml:charge_xml; var milieux,milieuy:int; var i,j,k,l,maxx,maxy:int; public function main() { milieux=milieuy=5; xml=new charge_xml(); j=5; l=0; for(j=0;j<milieuy;j++) { // gère les positions en x for(i=0; i<milieux;i++) { // gère les positions en y et x - remplissement des cases l++; fenetre = new fenetre(100*i+100,100*j+100,600); fenetre.createtextfield(100*i+100,100*j+100,20,20,l); addchild(fenetre); } } } }
}
sorry english language ! i'm french ... !
thanks help!
a quick prepare problem tween square center position @ same time tween scalex , scaley properties, , original position when square goes little size. need couple of little changes on fenetre
class:
first, store in class variables original position of square:
public class fenetre extends movieclip { private var mc:movieclip; private var bol:boolean; private var x0:number; private var y0:number; public function fenetre(px:number,py:number,largeur:uint) { x0 = px; y0 = py; //rest of code same... }
then, on mouse.click
listener, tween center position , back. think going need alter kid index before starting tweening, rather oncomplete
:
private function onclique(e:mouseevent):void { bol=!bol; if(bol){ plein_ecran(); tweenlite.to(mc,1,{scalex:1,scaley:1,x: mc.width/2, y: mc.height/2}); } else { tweenlite.to(mc,1,{scalex:.166,scaley:.166, x:x0, y:y0 }); } }
flash flash-cs5 flash-cs4 flashdevelop
No comments:
Post a Comment