he
JesterXL here is my hack at it not
cleaned or optimised just you get the idea.. You can apply the same technique to
any display object (untested).
Change
the pics play around with this. Hopfully he will post his so we can see how his
works...
Remember not cleaned up or corrected. But works mostly
:)
<SNIP>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:Local="*" xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
<mx:Script>
<mx:Application xmlns:Local="*" xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
<mx:Script>
//import flash.display.*;
import flash.geom.*;
//import mx.controls.Loader;
import flash.display.*;
import mx.controls.Image;
import flash.events.*;
import flash.filters.*;
public var loaderx:Loader = new Loader();
//import flash.display.Loader;
[Bindable]
public var currImage:String= "RSS_news.png";
public var OriginalBMP:BitmapData;
public function ReflectObject() {
imageContainer.removeAllChildren();
var imgMain:Image = new Image();
imgMain.width=imageContainer.width-100;
imgMain.height=imageContainer.height-100;
imgMain.id="Main";
imageContainer.addChild(imgMain);
//Create the final bitmap to draw out
var finalBMP:Bitmap = new Bitmap(OriginalBMP,"auto",false);
finalBMP.bitmapData=OriginalBMP;
//Create the reflection
var finalBMP1:Bitmap = new Bitmap(finalBMP.bitmapData.clone(),"auto",false);
finalBMP1.bitmapData=finalBMP.bitmapData.clone();
var matr:Matrix = new Matrix();
matr.createBox(-1,1,(90/180)*Math.PI*2,0, finalBMP.height*2+ReflectionDistance.value)
finalBMP1.transform.matrix = matr;
//create the gradient mask
var fillType:String = GradientType.LINEAR;
var colors:Array = [0xFFFFFF, 0xFFFFFF];
var alphas:Array = [ReflectionAlpha.value,ReflectionAlpha2.value];
var ratios:Array = [ReflectionRation1.value,ReflectionRation2.value ];//ratio];
var matr:Matrix = new Matrix();
matr.createGradientBox(finalBMP1.bitmapData.width, finalBMP1.bitmapData.height, 0, Maskx.value, finalBMP1.bitmapData.height);
matr.rotate((90/180)*Math.PI)
var spreadMethod:String = SpreadMethod.PAD;
var child:Sprite = new Sprite();
child.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr,spreadMethod);
child.graphics.drawRect(finalBMP1.x,finalBMP1.bitmapData.height,finalBMP1.bitmapData.width,finalBMP1.bitmapData.height);
child.cacheAsBitmap=true;
finalBMP.cacheAsBitmap=true;
finalBMP1.cacheAsBitmap=true;
import flash.geom.*;
//import mx.controls.Loader;
import flash.display.*;
import mx.controls.Image;
import flash.events.*;
import flash.filters.*;
public var loaderx:Loader = new Loader();
//import flash.display.Loader;
[Bindable]
public var currImage:String= "RSS_news.png";
public var OriginalBMP:BitmapData;
public function ReflectObject() {
imageContainer.removeAllChildren();
var imgMain:Image = new Image();
imgMain.width=imageContainer.width-100;
imgMain.height=imageContainer.height-100;
imgMain.id="Main";
imageContainer.addChild(imgMain);
//Create the final bitmap to draw out
var finalBMP:Bitmap = new Bitmap(OriginalBMP,"auto",false);
finalBMP.bitmapData=OriginalBMP;
//Create the reflection
var finalBMP1:Bitmap = new Bitmap(finalBMP.bitmapData.clone(),"auto",false);
finalBMP1.bitmapData=finalBMP.bitmapData.clone();
var matr:Matrix = new Matrix();
matr.createBox(-1,1,(90/180)*Math.PI*2,0, finalBMP.height*2+ReflectionDistance.value)
finalBMP1.transform.matrix = matr;
//create the gradient mask
var fillType:String = GradientType.LINEAR;
var colors:Array = [0xFFFFFF, 0xFFFFFF];
var alphas:Array = [ReflectionAlpha.value,ReflectionAlpha2.value];
var ratios:Array = [ReflectionRation1.value,ReflectionRation2.value ];//ratio];
var matr:Matrix = new Matrix();
matr.createGradientBox(finalBMP1.bitmapData.width, finalBMP1.bitmapData.height, 0, Maskx.value, finalBMP1.bitmapData.height);
matr.rotate((90/180)*Math.PI)
var spreadMethod:String = SpreadMethod.PAD;
var child:Sprite = new Sprite();
child.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr,spreadMethod);
child.graphics.drawRect(finalBMP1.x,finalBMP1.bitmapData.height,finalBMP1.bitmapData.width,finalBMP1.bitmapData.height);
child.cacheAsBitmap=true;
finalBMP.cacheAsBitmap=true;
finalBMP1.cacheAsBitmap=true;
finalBMP1.mask=child
imgMain.addChild(finalBMP);
imgMain.addChild(finalBMP1);
imgMain.addChild(child);
}
imgMain.addChild(finalBMP);
imgMain.addChild(finalBMP1);
imgMain.addChild(child);
}
public function
Clear(){
//Main.graphics.clear();
}
public function DoLoad(){
//var loaderx:Loader = new Loader();
loaderx.addEventListener("complete", loadHandler);
//Main.graphics.clear();
}
public function DoLoad(){
//var loaderx:Loader = new Loader();
loaderx.addEventListener("complete", loadHandler);
var request:URLRequest = new
URLRequest(currImage);
loaderx.x = 0;
loaderx.load(request);
}
public function loadHandler(event:Event){
ReflectionAlpha.value=.5;
ReflectionAlpha2.value=0;
ReflectionRation1.value=0;
ReflectionRation2.value =255;
ReflectionDistance.value=0;
Maskx.value=100;
OriginalBMP=event.currentTarget.content.bitmapData
ReflectObject();
}
loaderx.x = 0;
loaderx.load(request);
}
public function loadHandler(event:Event){
ReflectionAlpha.value=.5;
ReflectionAlpha2.value=0;
ReflectionRation1.value=0;
ReflectionRation2.value =255;
ReflectionDistance.value=0;
Maskx.value=100;
OriginalBMP=event.currentTarget.content.bitmapData
ReflectObject();
}
</mx:Script>
<mx:HBox >
<mx:ComboBox id="ImageSelection" change="currImage=event.target.text" >
<mx:dataProvider>
<mx:ArrayCollection>
<mx:source>
<mx:Object label="DSC00775.jpg" data=""/>
<mx:Object label="DSC007752.jpg" data=""/>
<mx:Object label="DSC01139.jpg" data=""/>
<mx:Object label="DSC011392.jpg" data=""/>
<mx:Object label="leaves.jpg" data=""/>
<mx:Object label="RSS_news.png" data=""/>
<mx:Object label="DSC01149.JPG" data=""/>
</mx:source>
</mx:ArrayCollection>
</mx:dataProvider>
</mx:ComboBox>
<mx:Button click="DoLoad();" label="Load Selected" />
</mx:HBox>
<mx:HDividedBox backgroundColor="{BackColor.selectedColor}" width="100%" height="100%">
<mx:VBox verticalAlign="middle" horizontalAlign="center" width="100%" height="100%" id="imageContainer">
<!--<mx:Image width="50%" height="100%" id="Main" />-->
</mx:VBox>
<mx:VBox width="50%" height="100%">
<mx:Form backgroundColor="#808080">
<mx:FormItem label="Reflection Distance">
<mx:HSlider liveDragging="true" change="ReflectObject();" value="0" id="ReflectionDistance" maximum="20" minimum="0" allowTrackClick="true" tickInterval="1" />
<mx:Label text="{ReflectionDistance.value}"/>
</mx:FormItem>
<mx:FormItem label="Reflection Alpha (1)">
<mx:HSlider liveDragging="true" change="ReflectObject();" value=".5" id="ReflectionAlpha" maximum="1" minimum="0" allowTrackClick="true" tickInterval=".1" />
<mx:Label text="{ReflectionAlpha.value}"/>
</mx:FormItem>
<mx:FormItem label="Reflection Alpha (2)">
<mx:HSlider liveDragging="true" change="ReflectObject();" value="0" id="ReflectionAlpha2" maximum="1" minimum="0" allowTrackClick="true" tickInterval=".1" />
<mx:Label text="{ReflectionAlpha2.value}"/>
</mx:FormItem>
<mx:FormItem label="Reflection Ratio (1)">
<mx:HSlider liveDragging="true" change="ReflectObject();" value="0" id="ReflectionRation1" maximum="255" minimum="0" allowTrackClick="true" tickInterval="10" />
<mx:Label text="{ReflectionRation1.value}"/>
</mx:FormItem>
<mx:FormItem label="Reflection Ratio (2)">
<mx:HSlider liveDragging="true" change="ReflectObject();" value="255" id="ReflectionRation2" maximum="255" minimum="0" allowTrackClick="true" tickInterval="10" />
<mx:Label text="{ReflectionRation2.value}"/>
</mx:FormItem>
<mx:FormItem label="Mask Position x">
<mx:HSlider liveDragging="true" change="ReflectObject();" value="100" id="Maskx" maximum="500" minimum="0" allowTrackClick="true" tickInterval="20" />
<mx:Label text="{Maskx.value}"/>
</mx:FormItem>
<mx:FormItem label="Background Color">
<mx:ColorPicker id="BackColor" selectedColor="#C0C0C0"/>
<mx:Label text="{BackColor.selectedColor}"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
</mx:HDividedBox>
</mx:Application>
</mx:Form>
</mx:VBox>
</mx:HDividedBox>
</mx:Application>
</SNIP>
-----Message d'origine-----Hey Trey, I saw your effect posted on Drisgill, how did you get it to work?
De : [email protected] [mailto:[EMAIL PROTECTED]De la part de JesterXL
Envoyé : vendredi 10 février 2006 17:18
À : [email protected]
Objet : Re: [flexcoders] Filters, Contributing
She looks hot!
----- Original Message -----
From: "Trey Long" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, February 10, 2006 9:14 AM
Subject: Re: [flexcoders] Filters, Contributing
Yeah, that's the problem. I can't find an interface as a guide to
designing the class and even though I can extend from BitmapFilter there
isn't any information to be had.
I believe that the classes have a specific structure and the
DisplayObject calls certain functions in the same manner that methods
like createChildren() or updateDisplayList() is called, but I can't find
any info.
So I was hoping that someone with more knowledge about the internals of
those classes would step forward, should I even hope for a Flex engineer
to see this?
-Trey
JesterXL wrote:
> Ohhh, you want to actually have it be a filter vs. using another one.
> Sorry
> about that; I reckon if your class doesn't extend at least a class in the
> flash.filters.* package, it won't work.
>
> ----- Original Message -----
> From: "Trey Long" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Thursday, February 09, 2006 5:15 PM
> Subject: Re: [flexcoders] Filters, Contributing
>
>
> I read through that, from what I understand it didn't exactly cover what
> I wanted to do.
>
> I was hoping to do something like the following:
>
> MyNewFilter would extend from the BitMapFilter class:
>
> var f:MyNewFilter = new MyNewFilter();
> var filtsCopy:Array = DisplayObject.filters;
> filtsCopy.push(MyNewFilter);
> DisplayObject.filters = filtsCopy;
>
> If that was covered in there, please correct me. It's possible that I
> missed something.
>
> -Trey
>
> JesterXL wrote:
>> Here is the 1.5 way; 2 shouldn't be that different:
>>
>> http://www.jessewarden.com/archives/2006/01/how_to_use_the.html
>>
>>
>> ----- Original Message -----
>> From: "Trey Long" <[EMAIL PROTECTED]>
>> To: <[email protected]>
>> Sent: Thursday, February 09, 2006 1:54 PM
>> Subject: [flexcoders] Filters, Contributing
>>
>>
>> I created my own bitmap filter from scratch. I was hoping that I could
>> follow the MM framework on this one but there is no info in the API nor
>> is there an interface that I can follow.
>>
>> If any Adobe / MM guys have any advice on this one please let me know. I
>> would like to just use it in the same way that standard Flex filters are
>> used. I also wouldn't mind contributing the filter if it pleases anyone.
>>
>> -Trey
>>
>> Standard way filters are used to me is the following:
>> Copy filters array out of DisplayObject, push filter on array, set back
>> to filters array of display object.
>>
>>
>> --
>> Flexcoders Mailing List
>> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> Flexcoders Mailing List
>> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

