Skip to content

Instantly share code, notes, and snippets.

View RKAN's full-sized avatar

Serkan Camur RKAN

  • Bitberry GmbH
  • Vienna
View GitHub Profile
@RKAN
RKAN / xml_loader.as
Created July 21, 2013 07:04
Basic external XML loader / Published in: ActionScript 3
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
/**
* ...
@RKAN
RKAN / tweening
Created July 21, 2013 07:00
Tweening to a Relative Position using a Variable in TweenMax
// Your everyday absolute tween that moves movieclip_mc
// to 100 on the x axis, taking one second to do so
TweenMax.to(movieclip_mc, 1, {x:100});
// A relative tween that moves movieclip_mc to a
// position on the x axis 100 units/pixels greater
// than movieclip_mc's current position
TweenMax.to(movieclip_mc, 1, {x:"100"});
// An absolute tween like the first, but passing in
@RKAN
RKAN / fadetoggle.as
Created July 21, 2013 06:58
AS3 Fade Toggle
function fadeOff(b2:MovieClip):void {
Tweener.addTween( b2, { alpha: .1,time: .35, transition: "easeOutQuad", onComplete:clipOff, onCompleteParams:[b2]});
}
function clipOff(b3:MovieClip):void {
b3.visible=false;
}
function clipOn(c2:MovieClip):void {
Tweener.addTween( c2, { alpha: 1,time: .5, delay:.1, transition: "easeOutQuad"});
}
function fadeOn(c3:MovieClip):void {
@RKAN
RKAN / rows.as
Created July 21, 2013 06:46
Row Column Logic
var nSutun :uint = 5; //Kaç sütun olsun
var mKare :MovieClip;
var nXspace :uint = 5; //x eksenine göre boşluk
var nYspace :uint = 5; //y eksenine göre boşluk
function createThumb():void
{
for (var i:uint = 0; i < nTotal; i++)
{
@RKAN
RKAN / output_flashvars.as
Created July 21, 2013 06:44
Writing FlashVars to TextField
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = true;
addChild(tf);
tf.x = 200;
tf.y = 200;
tf.multiline = true;
tf.height = 200;
tf.appendText("params:" + "\n");
@RKAN
RKAN / embed_assets.as
Created July 21, 2013 06:41
Simple Asset Manager with Embed Style
//AssetManager.as
// usage: AssetManager.getInstance.getAssetByName("MonaLisa");
package
{
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
public class AssetManager
{
@RKAN
RKAN / tween_3d.as
Created July 21, 2013 06:38
Tween3D - 3D Deformation Resolver&Helper
package tr.com.gotoandrock.utils
{
import com.greensock.TweenLite;
import flash.display.DisplayObject;
import flash.geom.Matrix;
/**
* Helps 3d tranformation applied target back to normal 2D Matrix and look&feel :)
* Should only use tween ends with if z value equal 0;
@RKAN
RKAN / embeed_font.as
Created July 21, 2013 06:36
Font embedding Font embedding and prevention of anti aliasing which is good for bitmap fonts:
//Embedding the font:
[Embed(source="FONT.ttf", fontName = "myFont", mimeType = "application/x-font-truetype", advancedAntiAliasing="true", embedAsCFF="false")]
private var myEmbeddedFont:Class;
//Creating the textformat:
var defaultTextFormat : TextFormat = new TextFormat('myFont');
//Applying the font to a textfield:
myTextField.defaultTextFormat = Config.defaultTextFormat;
myTextField.embedFonts = true;
@RKAN
RKAN / preloader.as
Created July 21, 2013 06:35
Create a Preloader class in Actionscript 3
/*
* main.fla -> main.as
*/
package
{
import flash.display.MovieClip;
import flash.events.Event;
/**
* ...
@RKAN
RKAN / new_gist_file
Created July 21, 2013 06:31
View trace() output in JavaScript console
//import ExternalInterface class use this instead of trace() to view output in JavaScript console
public function log(_t:String):void{
if(ExternalInterface.available){
ExternalInterface.call("console.log", _t );
}
}