Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    1,037

    [as 2] Skew Con Reflection Class

    Ciao,
    volevo chiedervi una mano, riguardando questa classe, che riflette in sfumatura, il mio mc.
    Vorrei fare lo SKEW o a destra o a sinistra, spareste dirmi come posso fare?

    Grazie in anticipo


    codice:
    import flash.display.BitmapData;
    import flash.geom.Matrix;
    class com.pixelfumes.Reflect
    {
    	private var version:String = "3.0";
    	private var mcBMP:BitmapData;
    	private var reflectionBMP:BitmapData;
    	private var updateInt:Number;
    	private var bounds:Object;
    	private var clip:MovieClip;
    	private var distance:Number = 0;
    
    	
    	
    	var myMatrix:Matrix 
    	
    	
    	
    	function Reflect (args:Object)
    	{
    		myMatrix = new Matrix ();
    
    		var mc:MovieClip = args.mc;
    		var alpha:Number = args.alpha;
    		var ratio:Number = args.ratio;
    		var updateTime:Number = args.updateTime;
    		var reflectionAlpha:Number = args.reflectionAlpha;
    		var reflectionDropoff:Number = args.reflectionDropoff;
    		var distance:Number = args.distance;
    
    		//class reference to reflected clip
    		clip = mc;
    		var mcHeight = (mc._height / mc._yscale) * 100;
    		var mcWidth = (mc._width / mc._xscale) * 100;
    		//
    		bounds = new Object ();
    		bounds.width = mcWidth;
    		bounds.height = mcHeight;
    		//
    		var matrixHeight:Number;
    		if (reflectionDropoff <= 0) {
    			matrixHeight = bounds.height;
    		} else {
    			matrixHeight = bounds.height / reflectionDropoff;
    		}
    		//
    		mcBMP = new BitmapData (bounds.width, bounds.height, true, 0xFFFFFF);
    		mcBMP.draw (mc);
    		//
    		reflectionBMP = new BitmapData (bounds.width, bounds.height, true, 0xFFFFFF);
    		reflectionBMP.draw (mc);
    		//
    		mc.createEmptyMovieClip ("reflection_mc",mc.getNextHighestDepth ());
    		mc.reflection_mc.attachBitmap (mcBMP,1);
    		mc.reflection_mc._yscale = -100;
    		mc.reflection_mc._y = (bounds.height * 2) + distance;
    		mc.reflection_mc._alpha = reflectionAlpha;
    		//create the gradient mask
    		mc.createEmptyMovieClip ("gradientMask_mc",mc.getNextHighestDepth ());
    		var fillType:String = "linear";
    		var colors:Array = [0xFFFFFF, 0xFFFFFF];
    		var alphas:Array = [alpha, 0];
    		var ratios:Array = [0, ratio];
    		var matrix = {matrixType:"box", x:0, y:0, w:bounds.width, h:matrixHeight, r:(90 / 180) * Math.PI};
    
    		var spreadMethod:String = "pad";
    		mc.gradientMask_mc.beginGradientFill (fillType,colors,alphas,ratios,matrix,spreadMethod);
    		mc.gradientMask_mc.moveTo (0,0);
    		mc.gradientMask_mc.lineTo (0,bounds.height);
    		mc.gradientMask_mc.lineTo (bounds.width,bounds.height);
    		mc.gradientMask_mc.lineTo (bounds.width,0);
    		mc.gradientMask_mc.lineTo (0,0);
    		mc.gradientMask_mc.endFill ();
    		mc.gradientMask_mc._y = bounds.height + distance;
    		mc.reflection_mc.cacheAsBitmap = true;
    		mc.gradientMask_mc.cacheAsBitmap = true;
    		mc.reflection_mc.setMask (mc.gradientMask_mc);
    		//
    		if (updateTime != null) {
    			updateInt = setInterval (this, "update", updateTime, mc);
    		}
    	}
    	private function redrawBMP (mc:MovieClip):Void
    	{
    		// redraws bitmap - Mim Gamiet [2006]
    		mcBMP.dispose ();
    		mcBMP = new BitmapData (bounds.width, bounds.height, true, 0xFFFFFF);
    		mcBMP.draw (mc);
    	}
    	private function update (mc):Void
    	{
    		mcBMP = new BitmapData (bounds.width, bounds.height, true, 0xFFFFFF);
    		mcBMP.draw (mc);
    		reflectionBMP.draw (mc);
    		mc.reflection_mc.attachBitmap (mcBMP,1);
    	}
    	private function setBounds (w:Number, h:Number):Void
    	{
    		bounds.width = w;
    		bounds.height = h;
    		reflectionBMP = new BitmapData (bounds.width, bounds.height, true, 0xFFFFFF);
    		clip.gradientMask_mc._width = bounds.width;
    		redrawBMP (clip);
    	}
    	private function destroy ():Void
    	{
    		reflectionBMP.dispose ();
    		mcBMP.dispose ();
    		clearInterval (updateInt);
    		removeMovieClip (clip.reflection_mc);
    		removeMovieClip (clip.gradientMask_mc);
    	}
    }

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    lo si può fare utilizzando una matrice e manipolando una o entrambe le sue proprietà "b" e "c"
    la matrice così impostata va utilizzata come secondo parametro nel disegno del riflesso, che nella tua classe dovrebbe essere in questa riga: reflectionBMP.draw (mc);

    perciò ad esempio aggiungi questo prima della riga:

    var skew:Matrix = new Matrix();
    skew.b = .1;
    reflectionBMP.draw (mc, skew);

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    1,037
    Grazie per la risposta ma nonva..
    Ma la cosa peggiore che pubblicando, non fa nenche la rilessione!
    La classe reflection viene applicata solo se l'immagine e o video nella stessa cartella, è assurdo ma è cosi.
    Ho provato anche senza classe solo codice timeline, ma la classe BitmapData no nfa una grinza, per coppiare le immagini.
    Ho impostato System.security.allowDomain ("*");.
    Ho fatto una prova per caricare le immagini da internet, ma a quanto pare inserendo l 'http va apalla.

    Consigli idee?
    grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.