Look at this link (http://asawilliams.org/?p=35) and find the solution!
Archiv für die Kategorie „Code Snippets“
Skinning Scrollbars with Degrafa
Freitag, 5. Februar 2010Convert an Image to Black and White with AS3
Dienstag, 19. Januar 2010The Method:
import flash.filters.ColorMatrixFilter;
public static function blackAndWhiteFilter():Array
{
var matrix:Array = [0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0, 0, 0, 1, 0];
var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter(matrix);
return [colorMatrix];
}
Use it as follows:
private var image:Bitmap;
image.filters = blackAndWhiteFilter();
Flash AS3: Determine child display objects when dealing with mouse events
Montag, 7. September 2009You can easily determine child objects if a display object container contains any other display object and its childs using the contains method.
Example:
var buttonWithChilds:SimpleButton;
_buttonWithChilds.addEventListener( MouseEvent.MOUSE_OUT, buttonOutHandler);
public function buttonOutHandler( e:MouseEvent ):void
{
if(e.relatedObject != null)
{
if(buttonWithChilds.contains(e.relatedObject))
return;
}
}
trace("is Out");
}
Flex: How to disable the default open/close comboBox effect?
Sonntag, 17. Mai 2009Set ‘open-duration to:0′ by Style:
ComboBox
{
open-duration:0;
close-duration:0;
}
or direct:
AS3 ComboBox Component: change size of TextField with ActionScript
Donnerstag, 23. April 2009
package com.nativeinstruments.modules.mediastage.view.components
{
import fl.controls.ComboBox;
public class MyComboBox extends ComboBox
{
public function MyComboBox()
{
super();
}
/**
* override super class to change size of TextField by ActionScript
*
*/
override protected function drawTextField():void
{
super.drawTextField();
var rightSpace:Number = 18;
super.inputField.setSize(width - rightSpace, 50);
}
}
}
ActionScript 3: Clicking Through DisplayObjects
Donnerstag, 23. April 2009mouseEnabled = false;
mouseChildren = false;
Example:
var dispObj1:Sprite= new Sprite();
dispObj1.graphics.beginFill( 0x000000, 1 );
dispObj1.graphics.drawCircle( 50, 50, 25 );
dispObj1.graphics.endFill();
dispObj1.buttonMode = true;
dispObj1.addEventListener(MouseEvent.CLICK, clickHandler);
var dispObj2:Sprite= new Sprite();
dispObj2.graphics.beginFill( 0xff0000, .5);
dispObj2.graphics.drawRect( 0, 0, 100, 100 );
dispObj2.graphics.endFill();
//disable MouseEvent for dispObj2
dispObj2.mouseEnabled = false;
dispObj2.mouseChildren = false;
addChild(dispObj1);
//dispObj2 over dispObj1
addChild(dispObj2);
function clickHandler(event:MouseEvent):void
{
trace('Hello');
}
ActionScript 3 (AS3): removing all Child-Objects
Montag, 16. März 2009
/**
* REMOVING ALL CHILDS
* @param target
*
*/
public function removeAllChilds(target:Sprite):void
{
//removing Targets child
while(target.numChildren)
{
target.removeChildAt(0);
}
}