Thursday, March 22, 2012

Blitting Research


//Blitting Research.
//Used on a file with 3 objects on stage
//that are exported for actionscript:
//They Are:
//[1]:
//Instance S1 on stage:
//Exported as class: "SYM01"
//[2]:
//Instance "S1_copy" on stage:
//Is the SAME symbol in library
//as "S1". Thus should have the
//same .constructor result.
//[3]:
//Instance "S2" on stage:
//Exported as class: "SYM02"

//Theory behind research:
//I want to take movieClips embedded
//on stage or actual classes and pass
//them to my blit constructor.
//The blit constructor will look
//at if the object's class is already
//in the master static vector
//for the class. If it already exists,
//the blitter class will make the
//new bitmap an instance of a bitmap
//data object already in memory.

import flash.utils.Dictionary;
import flash.display.Bitmap;
import flash.display.BitmapData;

var kDict:Dictionary = new Dictionary();

//get class:
var c:Class = S1.constructor;
kDict[c] = 1;

//see if it exists:
if( kDict[c] != null ){
 trace("Test Pass");
}else{
 trace("FAIL");
}

//get another class that does NOT
//exist in dictionary:
var d:Class = S2.constructor;
if( kDict[d] != null ){
 trace("FAIL");
}else{
 trace("Test Pass");
}

//get another instance on the screen
//that has also been exported for actionscript,
//but this one is of the SAME
//class as variable "c".
var c2:Class = S1_Copy.constructor;
if( kDict[c2] != null ){
 trace("Test Pass");
}else{
 trace("FAIL");
}

trace("end of script");

No comments:

Post a Comment