Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

La proporzioni matematiche

This is a discussion on La proporzioni matematiche within the Articoli e tutorials forums, part of the Flash CS3 e Actionscript 3.0 category; Augh! Sviluppando Flash e Actionscript spesso necessitiamo di alcuni 'trucchetti' per poter applicare al meglio le nostre animazioni o per ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 e Actionscript 3.0 > Articoli e tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  6 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 19-09-07, 13:37
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
La proporzioni matematiche

Augh!
Sviluppando Flash e Actionscript spesso necessitiamo di alcuni 'trucchetti' per poter applicare al meglio le nostre animazioni o per rendere l' interattivitā con l'utente al meglio possibile.
In questo mio esempio voglio attirare l' attenzione sulle proporzioni matematiche applicate ad Actionscript 3.0 .
Come sappiamo dalla matematica la legge delle proporzioni č la seguente:
x:10=2:20
ora tramite le formule inverse possiamo ricavare il valore di x.
Sostituendo i valori con le proprietā delle MovieClip che necessitiamo per la nostra applicazione, otteniamo questo risultato:










La Classe che ho scritto č la seguente:
Code:
package
{
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.geom.Rectangle;
	
	public class Balance extends MovieClip
	{
		private var offSet:Number;
		private var start_1:Number;
		private var start_2:Number;
		
		private var my_rect:Rectangle;
		
		public function Balance()
		{
			init();
		}
		
		public function init():void
		{
			stage.frameRate=31;
			
			//handler_mc.buttonMode=true;
			handler_mc.useHandCursor=true;
			bg_mc.x=handler_mc.x;
			bg_mc.y=handler_mc.y;
			handler2_mc.x=bg2_mc.x;
			handler2_mc.y=bg2_mc.y;
			handler3_mc.x=bg3_mc.x;
			handler3_mc.y=bg3_mc.y;
			
			offSet=bg_mc.height-handler_mc.height;
			start_1=handler2_mc.x;
			start_2=handler3_mc.x;
			my_rect=new Rectangle(bg_mc.x,bg_mc.y,0,offSet);
			
			initEvents();
		}
		
		public function initEvents():void
		{
			handler_mc.addEventListener(MouseEvent.MOUSE_DOWN,mouseIsDown);
			stage.addEventListener(MouseEvent.MOUSE_UP,mouseIsUp);
		}
		public function mouseIsDown(event:Event):void
		{
			handler_mc.startDrag(false,my_rect);
			handler_mc.addEventListener(Event.ENTER_FRAME,applyBalance);
		}
		public function mouseIsUp(event:Event):void
		{
			handler_mc.stopDrag();
			handler_mc.removeEventListener(Event.ENTER_FRAME,applyBalance);
		}
		public function applyBalance(event:Event):void
		{
			
			var p:Number=handler_mc.y-bg_mc.y;
			var percentage:Number=Math.ceil((p/offSet)*100);
			
			handler2_mc.x=start_1+(percentage/100)*(bg2_mc.width-handler2_mc.width);
			handler3_mc.x=start_2+(percentage/100)*(bg3_mc.width-handler3_mc.width);
			circle_mc.rotation=(percentage/100)*360;
		}
	}
}
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Mouse e proporzioni con Actionscript 3.0 Flep Articoli e tutorials 4 17-11-08 01:11
FLVPlayback full screen - mantenere le proporzioni Eugene Componenti 0 02-09-08 19:48


All times are GMT. The time now is 10:57.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406