i am using electron(nodejs framework ) and i want to render crispy text for convert it into bitmap and show it on led brick.
like led show software please help.
my code is working but it's system dependent it working fine in some computer but to blurry in some computer.
calling parameter in main.js.
let height = 96;
let width = 288;
let letterSpacing = 1;
var font = "Arial";
var fontSize = 11;
let text_x = 1;
let text_y = 1;
const canvas = new Canvas(height, width, letterSpacing, font, fontSize, text_x, text_y);
here is my canvas.js file.
class Canvas {
constructor(height, width, latterSpacing = 1, font, fontSize, text_x, text_y) {
this.width = width;
this.height = height;
this.letterSpacing = latterSpacing;
this.font = font;
this.fontSize = fontSize;
this.text_x = text_x;
this.text_y = text_y;
this.maxWidth = 32;
this.offset = 0.5;
this.canvas = document.getElementById("myCanvas");
this.ctx = this.canvas.getContext("2d");
}
PIXEL_RATIO = (function () {
// var ctx = document.createElement("canvas").getContext("2d"),
var ctx = document.getElementById("myCanvas").getContext("2d"),
// var ctx = this.ctx,
dpr = window.devicePixelRatio || 1,
bsr = ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || 1;
return dpr / bsr;
})();
setwidth(maxwidth) {
this.maxWidth = maxwidth;
// this.offset = ofset;
}
setoffset(ofset) {
// this.maxWidth = maxwidth;
this.offset = ofset;
}
createHiDPICanvas = function (w, h, ratio) {
if (!ratio) { ratio = this.PIXEL_RATIO; }
// var can = document.createElement("canvas");
var can = this.canvas;
can.width = w * ratio;
can.height = h * ratio;
can.style.width = w + "px";
can.style.height = h + "px";
can.getContext("2d").setTransform(ratio, 0, 0, ratio, 0, 0);
return can;
}
createCanvas() {
try {
const canvas = document.getElementById("myCanvas");
this.canvas.retinaResolutionEnabled = false;
// this.canvas.style.letterSpacing = "1px";
this.canvas.height = this.height;
this.canvas.width = this.width;
this.canvas.style.letterSpacing = `${this.letterSpacing}px`
/*word spacing*/
// var can = this.createHiDPICanvas(this.width, this.height, 4)
// this.ctx = can.getContext("2d")
this.ctx.beginPath();
// this.ctx = this.canvas.getContext("2d");
this.ctx.fillStyle = "#FF0000";
this.ctx.font = `${this.fontSize}px ` + this.font;
/*Font style and size*/
this.ctx.strokeStyle = "#FF0000";
this.ctx.textBaseline = "top";
this.ctx.textAlign = 'start';
this.ctx.shadowOffsetX = 0;
this.canvas.retinaResolutionEnabled = false;
// this.ctx.fillText("WELCOME TO TICO", 10, 20);
return true;
} catch (error) {
return false;
}
}
clrCanvas(ix = 0, iy = 0, ex = this.canvas.width, ey = this.canvas.height) {
this.ctx.clearRect(ix, iy, ex, ey);
}
fillTextCanvas(str, row = 0, col = 0, vac = 0, hac = 1, _fontSize = this.fontSize, _font = this.font)
{
this.ctx.font = `${_fontSize}px ` + _font;
if (vac) {
col = ((this.canvas.height - (str.length * _fontSize)) / 2) + 1;
}
if (hac) {
this.ctx.textAlign = "center";
row = this.width / 2;
}
for (let index = 0; index < str.length; index++) {
// const element = array[index];
let y = (_fontSize * index) + col;
// this.ctx.fillText(str[index], width / 2, y);
/*text,x,y*/
this.ctx.fillText(str[index], row - 0.8, y - 0.8);
/*text,x,y*/
// this.ctx.fillText("hello", width/2, y);
/*text,x,y*/
}
// display_hex["Screen2"] = jsonArr;
// fillMatrix(jsonArr);
}
async getBitmap() {
var jsonArr = {};
var bin = '';
for (var j = 0; j < this.canvas.width; j++) {
bin = ""
for (var i = 0; i <= this.canvas.height; i++) {
var data = this.ctx.getImageData(j, i, 1, 1); /*getPixel,x,y*/
if (!(i % 32) && i) {
// jsonArr[j + (width * (Math.floor(i / 32) - 1))] = ("0x" + (("00000000" +
ConvertBase.bin2hex(bin)).substr(-8)));
jsonArr[j + (this.width * (Math.floor(i / 32) - 1))] =
parseInt(ConvertBase.bin2dec(bin));
bin = "";
}
if (data['data'][0] >= 200 && data['data'][3] >= 90) {
bin += "1";
} else {
bin += "0";
}
}
}
return jsonArr;
}
fillCanvas(_char, row, col, _fontSize = 11, _font = "Arial") {
this.clrCanvas();
this.ctx.font = `${_fontSize}px ` + _font;
this.ctx.textAlign = "start";
this.ctx.imageSmoothingEnabled = false;
// let linesPos = [[0, 45, 80, 119, 157, 196, 235], [1, 24, 36, 48, 60, 72, 84]]
// let linesPos = [[0, 49, 81, 119, 157, 196, 235], [1, 22, 33, 44, 55, 66, 77]]
let linesPos = [[0, 60, 98, 135, 174, 213, 252], [1, 23, 34, 45, 56, 67, 78]]
this.findColPos(_char);
// console.log(_char)
for (let _row = row; _row < _char.length; _row++) {
// let y = parseInt(text_y) + ((parseInt(fontSize) + 2) * _row);
let y = parseInt(this.text_y + 1) + ((parseInt(_fontSize)) * _row);
for (let index = col; index < _char[_row].length; index++) {
let x = parseInt(this.text_x) + linesPos[0][index];
console.log(this.ctx.measureText(_char[_row][index]).width)
// this.ctx.fillText(_char[_row][index], x + 1.8, y + 0.8,32);
/*text,x,y*/
this.ctx.fillText(_char[_row][index], x + this.offset, y + this.offset, this.maxWidth);
/*text,x,y*/
this.ctx.moveTo(0, linesPos[1][index + 1] + 0.5);
this.ctx.lineTo(this.canvas.width, linesPos[1][index + 1] + 0.5);
this.ctx.moveTo(linesPos[0][index] + 0.5, 0);
this.ctx.lineTo(linesPos[0][index] + 0.5, this.canvas.height);
}
}
this.ctx.stroke();
this.ctx.strokeRect(0, 0, this.canvas.width, this.canvas.height);
// display_hex["Screen1"] = jsonArr;
// canvasImg["Screen1"] = ($('#myCanvas')[0]).toDataURL("image/png");
// fillMatrix(jsonArr);
// return jsonArr;
}
findColPos(__char) {
let maxRow = []
maxRow[0] = 0;
let splitData = [];
maxRow[0] = [];
maxRow[1] = [];
for (let pos = 0; pos < __char[0].length; pos++) {
if (__char[0][pos].split(" ")[1]) {
splitData.push(__char[0][pos].split(" ")[1]);
} else {
// __char[0][pos] = "";
splitData[pos] = " "
}
__char[0][pos] = __char[0][pos].trim().split(" ")[0]; //_char[0][pos] _char[0].splice[];
// _char[0][pos] = splitData[0];
// _char[0].splice
// console.log(_char[0][pos].split(" ")[0]); //_char[0][pos] _char[0].splice[];
}
console.log(__char)
__char.splice(1, 0, splitData)
console.log(__char)
for (let row = 0; row < __char.length; row++) {
for (let col = 0; col < __char[row].length; col++) {
let width = this.ctx.measureText(__char[row][col]).width + 3;
if (!maxRow[0][col + 1]) {
maxRow[0][col + 1] = 0;
}
maxRow[0][col + 1] = maxRow[0][col + 1] < width ? width : maxRow[0][col + 1];
}
}
// console.log(maxRow)
for (let i = 1; i < maxRow.length; i++) {
maxRow[0][i] = maxRow[0][i] + maxRow[0][i - 1];
}
/* for (let index = 0; index < _char.length; index++) {
// const element = array[index];
maxRow[index] = ctx.measureText(_char[index]).width;
} */
// _char = __char
return maxRow;
}
createFonts(start, end) {
let arr = [];
// clearEvents();
for (let index = "/".charCodeAt(0); index <= ":".charCodeAt(0); index++) {
// const element = array[index];
// fillCanvas(index);
let txt = String.fromCharCode(index);
fillTextCanvas(txt, 0, 0, 1, 0, 32);
createCanvas(32, this.ctx.measureText(txt).width, 32);
this.ctx.textBaseline = "middle";
// fillTextCanvas(txt, text_x, text_y);
this.clrCanvas();
fillTextCanvas(txt, 0, 0, 1, 0, 32);
arr.push(display_hex);
// fillMatrix();
}
console.log(JSON.stringify(arr));
// startEvents();
}
findFirstPositive(b, a, i, c) {
c = (d, e) => e >= d ? (a = d + (e - d) / 2, 0 < b(a) && (a == d || 0 >= b(a - 1)) ? a : 0 >=
b(a) ? c(a + 1, e) : c(d, a - 1)) : -1
for (i = 1; 0 >= b(i);) i *= 2
return c(i / 2, i) | 0
}
getDPI() {
var dpi = findFirstPositive(x => matchMedia(`(max-resolution: ${x}dpi)`).matches);
return dpi
}
getImage() {
return this.canvas.toDataURL('image/png', 1.0);
}
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = Canvas;
}
The canvas does not respect your devices pixel ratio, this is not a specific electron issue.
The code you have copy and pasted from another StackOverflow won't work because you change the size/height again without respecting the ratio. If you uncomment it and adjust it correctly, it will work.
Trying to get series values in the selected area after mouseup.
Need to calculate width and height of the selected are in the chart with respect to axis.
[`https://jsbin.com/wapovohiwe/edit?html,output`][1]
I modified your example to draw the rectangle and to output the coordinates of the
Chart1 = new Tee.Chart("canvas");
Chart1.legend.visible = false;
Chart1.panel.format.gradient.visible = false;
Chart1.panel.format.fill = "white";
Chart1.walls.back.format.fill = "white";
Chart1.addSeries(new Tee.Line([1, 3, 0, 2, 7, 5, 6]));
Chart1.zoom.enabled = false;
var myFormat = new Tee.Format(Chart1);
myFormat.transparency = 0.9;
var rect = {},
drag = false;
Chart1.mousedown = function(e) {
rect.startX = e.x - canvas.offsetLeft - canvas.parentElement.offsetLeft - canvas.parentElement.parentElement.offsetLeft;
rect.startY = e.y - canvas.offsetTop - canvas.parentElement.offsetTop - canvas.parentElement.parentElement.offsetTop;
drag = true;
}
Chart1.mouseup = function(p) {
var i, tmpP = {};
points = [];
var s = Chart1.series.items[0];
for (i = 0; i < s.count(); i++) {
s.calc(i, tmpP);
if ((tmpP.x >= rect.startX) && (tmpP.x <= rect.startX + rect.w) && (tmpP.y >= rect.startY) && (tmpP.y <= rect.startY + rect.h))
console.log("index: " + i + ", value: " + s.data.values[i]);
}
drag = false;
}
Chart1.mousemove = function(e) {
if (drag) {
rect.w = e.x - rect.startX;
rect.h = e.y - rect.startY;
drawChart();
}
}
function drawChart() {
Chart1.draw();
myFormat.rectangle(rect.startX, rect.startY, rect.w, rect.h);
}
Chart1.draw();
<script src="https://www.steema.com/files/public/teechart/html5/latest/src/teechart.js"></script>
<canvas id="canvas" height="400" width="700"></canvas>
Now, I do Flash Actionscript 3.0 development, I have a Base64bitEncoder class with the encodeByteArray(...) and decodeToByteArray(...) function.
but when I write the below testing code, but the byteArray.length at before Encoding and after decoding are different, could you help to see see where I wrong?
Test Sample Code as below:
var _loc_2:XML = new XML("<formXML>aaaaa</formXML>");;
var _loc_3:ByteArray;
_loc_3 = new ByteArray();
//_loc_3.endian = Endian.LITTLE_ENDIAN;
_loc_3.writeUTFBytes(_loc_2);
trace("Before Encoding Length:" + _loc_3.length);
var baseString:String = Base64bitEncoder.encodeByteArray(_loc_3);
trace(baseString);
var strArray:ByteArray = Base64bitEncoder.decodeToByteArray(baseString);
trace("After Decoding length:" + strArray.length);
The Output log as below:
Before Encoding Length:5
GFhAGFhA
After Decoding length:**6**
Why the after is 6, where I do wrong?
Base64bitEncoder source code as below:
package
{
import flash.utils.*;
public class Base64bitEncoder extends Object
{
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
private static const BASE64_URL_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_!";
public function Base64bitEncoder()
{
return;
}// end function
public static function encode(param1:String, param2:Boolean = false) : String
{
var _loc_3:ByteArray;
_loc_3 = new ByteArray();
_loc_3.writeUTFBytes(param1);
return encodeByteArray(_loc_3, param2);
}// end function
public static function decodeToByteArray(param1:String, param2:Boolean = false) : ByteArray
{
var _loc_3:ByteArray;
var _loc_4:Array;
var _loc_5:Array;
var _loc_6:uint;
var _loc_7:uint;
var _loc_8:uint;
_loc_3 = new ByteArray();
_loc_4 = new Array(4);
_loc_5 = new Array(3);
_loc_6 = 0;
while (_loc_6 < param1.length)
{
// label
_loc_7 = 0;
while (_loc_7++ < 4 && _loc_6 + _loc_7 < param1.length)
{
// label
_loc_4[_loc_7] = param2 == true ? (BASE64_URL_CHARS.indexOf(param1.charAt(_loc_6 + _loc_7))) : (BASE64_CHARS.indexOf(param1.charAt(_loc_6 + _loc_7)));
}// end while
_loc_5[0] = (_loc_4[0] << 2) + ((_loc_4[1] & 48) >> 4);
_loc_5[1] = ((_loc_4[1] & 15) << 4) + ((_loc_4[2] & 60) >> 2);
_loc_5[2] = ((_loc_4[2] & 3) << 6) + _loc_4[3];
_loc_8 = 0;
while (_loc_8++ < _loc_5.length)
{
// label
if (_loc_4[_loc_8 + 1] == 64)
{
break;
}// end if
_loc_3.writeByte(_loc_5[_loc_8]);
}// end while
_loc_6 = _loc_6 + 4;
}// end while
_loc_3.position = 0;
return _loc_3;
}// end function
public static function encodeByteArray(param1:ByteArray, param2:Boolean = false) : String
{
var _loc_3:String;
var _loc_4:Array;
var _loc_5:Array;
var _loc_6:uint;
var _loc_7:uint;
var _loc_8:uint;
_loc_3 = "";
_loc_5 = new Array(4);
param1.position = 0;
while (param1.bytesAvailable > 0)
{
// label
_loc_4 = [];
_loc_6 = 0;
while (_loc_6++ < 3 && param1.bytesAvailable > 0)
{
// label
_loc_4[_loc_6] = param1.readUnsignedByte();
}// end while
_loc_5[0] = (_loc_4[0] & 252) >> 2;
_loc_5[1] = (_loc_4[0] & 3) << 4 | _loc_4[1] >> 4;
_loc_5[2] = (_loc_4[1] & 15) << 2 | _loc_4[2] >> 6;
_loc_5[3] = _loc_4[2] & 63;
_loc_7 = _loc_4.length;
while (_loc_7++ < 3)
{
// label
_loc_5[_loc_7 + 1] = 64;
}// end while
_loc_8 = 0;
while (_loc_8++ < _loc_5.length)
{
// label
_loc_3 = _loc_3 + (param2 == true ? (BASE64_URL_CHARS.charAt(_loc_5[_loc_8])) : (BASE64_CHARS.charAt(_loc_5[_loc_8])));
}// end while
}// end while
return _loc_3;
}// end function
public static function decode(param1:String, param2:Boolean = false) : String
{
var _loc_3:ByteArray;
_loc_3 = decodeToByteArray(param1, param2);
return _loc_3.readUTFBytes(_loc_3.length);
}// end function
}
}
#akmozo, today, I spend some time to study the base64 theory, I fix the issue, thanks.
update code:
public static function encodeByteArray(param1:ByteArray, param2:Boolean = false) : String
{
var _loc_3:String;
var _loc_4:Array;
var _loc_5:Array;
var _loc_6:uint;
var _loc_7:uint;
var _loc_8:uint;
_loc_3 = "";
_loc_5 = new Array(4);
param1.position = 0;
while (param1.bytesAvailable > 0)
{
// label
_loc_4 = [];
_loc_6 = 0;
while (_loc_6 < 3 && param1.bytesAvailable > 0)
{
// label
_loc_4[_loc_6] = param1.readUnsignedByte();
_loc_6 = _loc_6 + 1;
}// end while
_loc_5[0] = (_loc_4[0] & 252) >> 2;
_loc_5[1] = (_loc_4[0] & 3) << 4 | _loc_4[1] >> 4;
_loc_5[2] = (_loc_4[1] & 15) << 2 | _loc_4[2] >> 6;
_loc_5[3] = _loc_4[2] & 63;
/*
trace("--------------------------------");
trace("0:" + _loc_4[0]);
trace("1:" + _loc_4[1]);
trace("3:" + _loc_4[2]);
trace("len:"+_loc_4.length);
trace("++++++++++++++++++++++++++++++++");
*/
_loc_7 = _loc_4.length;
while (_loc_7 < 3)
{
// label
_loc_5[_loc_7 + 1] = 64;
_loc_7 = _loc_7 + 1;
}// end while
_loc_8 = 0;
while (_loc_8 < _loc_5.length)
{
// label
_loc_3 = _loc_3 + (param2 == true ? (BASE64_URL_CHARS.charAt(_loc_5[_loc_8])) : (BASE64_CHARS.charAt(_loc_5[_loc_8])));
_loc_8 = _loc_8 + 1;
}// end while
}// end while
return _loc_3;
}// end function
public static function decodeToByteArray(param1:String, param2:Boolean = false) : ByteArray
{
var _loc_3:ByteArray;
var _loc_4:Array;
var _loc_5:Array;
var _loc_6:uint;
var _loc_7:uint;
var _loc_8:uint;
_loc_3 = new ByteArray();
_loc_4 = new Array(4);
_loc_5 = new Array(3);
_loc_6 = 0;
while (_loc_6 < param1.length)
{
// label
_loc_7 = 0;
while (_loc_7 < 4 && _loc_6 + _loc_7 < param1.length)
{
// label
_loc_4[_loc_7] = param2 == true ? (BASE64_URL_CHARS.indexOf(param1.charAt(_loc_6 + _loc_7))) : (BASE64_CHARS.indexOf(param1.charAt(_loc_6 + _loc_7)));
_loc_7 = _loc_7 + 1;
}// end while
_loc_5[0] = (_loc_4[0] << 2) + ((_loc_4[1] & 48) >> 4);
_loc_5[1] = ((_loc_4[1] & 15) << 4) + ((_loc_4[2] & 60) >> 2);
_loc_5[2] = ((_loc_4[2] & 3) << 6) + _loc_4[3];
_loc_8 = 0;
while (_loc_8 < _loc_5.length)
{
// label
if (_loc_4[_loc_8 + 1] == 64)
{
break;
}// end if
_loc_3.writeByte(_loc_5[_loc_8]);
_loc_8 = _loc_8 + 1;
}// end while
_loc_6 = _loc_6 + 4;
}// end while
_loc_3.position = 0;
return _loc_3;
}// end function
I have a flash project that loads an image and applies a grey saturation over it. There is a button beneath the image that when highlighted or the mouse hovers over it removes the saturation and restores the original color to the image. This works fine in demo mode and in the stand-alone flash player, but when I try to use it online (HTML) page the hover of feature no longer restores the color to the image. My code is below, I hope someone smarter than me know's what the problem is.
Thanks.
function parsXML()
{
mainGalleryNode = gallery_xml.childNodes[0].childNodes;
path = mainGalleryNode[_root.gallerySel - 1].attributes.path;
lenGall = mainGalleryNode[_root.gallerySel - 1].childNodes.length;
lenCat = mainGalleryNode.length;
for (var _loc2 = 0; _loc2 < lenGall; ++_loc2)
{
arrayImage[_loc2] = path + mainGalleryNode[_root.gallerySel - 1].childNodes[_loc2].attributes.pic;
arrayThumb[_loc2] = path + mainGalleryNode[_root.gallerySel - 1].childNodes[_loc2].attributes.thumbnail;
arrayTitle[_loc2] = mainGalleryNode[_root.gallerySel - 1].childNodes[_loc2].attributes.name;
arrayDescription[_loc2] = mainGalleryNode[_root.gallerySel - 1].childNodes[_loc2].attributes.description;
} // end of for
} // End of the function
function arrayThumbs()
{
for (var _loc3 = 1; _loc3 <= lenGall; ++_loc3)
{
_thumbs._thumbs.attachMovie("thumb", "thumb" + _loc3, _loc3);
var _loc2 = _thumbs._thumbs["thumb" + _loc3];
_loc2.index = _loc3;
_loc2._y = Math.floor(_loc2._height + 1) * (_loc3 - 1);
_loc2._mc._txt.text = _loc2.index;
_loc2.onRollOver = function ()
{
this.gotoAndPlay("over");
};
_loc2.onRollOut = _loc2.onReleaseOutside = function ()
{
this.gotoAndPlay("out");
};
_loc2.onRelease = function ()
{
caurina.transitions.Tweener.addTween(_mc1._mc, {_saturation: 1, time: 5.000000E-001});
mcLoader.loadClip(arrayImage[this.index - 1], _mc1._mc);
currentIndex = this.index - 1;
getDes();
};
} // end of for
counter = 1;
} // End of the function
function menuCat()
{
for (var _loc4 = 1; _loc4 <= lenCat; ++_loc4)
{
_category.attachMovie("btnCat", "btnCat" + _loc4, _loc4);
var _loc3 = _category["btnCat" + _loc4];
var _loc6 = _category["btnCat" + (_loc4 - 1)];
_loc3.index = _loc4;
arrayNameGall[_loc4 - 1] = mainGalleryNode[_loc4 - 1].attributes.name;
_loc3._mc._txt.autoSize = true;
_category["btnCat" + _loc4]._mc._txt.text = arrayNameGall[_loc4 - 1];
_loc3._red._width = _loc3._mc._txt.textWidth + 10;
_loc3._red._x = _loc3._mc._txt.textWidth / 2;
_loc3._mask._width = _loc3._mc._txt.textWidth + 10;
_loc3._mask._x = _loc3._mc._txt.textWidth / 2;
for (var _loc5 = 1; _loc5 <= 3; ++_loc5)
{
_loc3["_arr" + _loc5]._x = _loc3._mc._txt.textWidth / 2 - 5;
} // end of for
_loc3._mask_red._txt.text = arrayNameGall[_loc4 - 1];
_loc3._x = Math.floor(_loc6._x + _loc6._mc._txt.textWidth + intervalCat);
if (_loc4 < lenCat)
{
_category._breakers.attachMovie("breaker", "breaker" + _loc4, _loc4);
var _loc7 = _category._breakers["breaker" + _loc4];
_loc7._x = _loc3._x + _loc3._mc._txt.textWidth + intervalBr;
} // end if
_category._x = 881 - _category._width;
_loc3.onRollOver = function ()
{
if (this.index != _root.gallerySel)
{
btnCatOver(this._red, this._arr1);
} // end if
};
_loc3.onRollOut = _loc3.onReleaseOutside = function ()
{
if (this.index != _root.gallerySel)
{
btnCatOut(this._red, this._arr1);
} // end if
};
_loc3.onRelease = function ()
{
if (this.index != _root.gallerySel)
{
btnCatOut(_category["btnCat" + _root.gallerySel]._red, _category["btnCat" + _root.gallerySel]._arr1);
clearThumbs();
caurina.transitions.Tweener.addTween(_thumbs._thumbs, {_y: 0, time: 1, transition: "easeOutCubic"});
yPos = 0;
_root.gallerySel = this.index;
parsXML();
arrayThumbs();
getDes();
mcLoader.loadClip(arrayImage[0], _mc1._mc);
} // end if
};
} // end of for
btnCatOver(_category.btnCat1._red, _category.btnCat1._arr1);
} // End of the function
function btnCatOver(clip1, clip2)
{
caurina.transitions.Tweener.addTween(clip1, {_y: 17, time: 3, transition: "easeOutCubic"});
caurina.transitions.Tweener.addTween(clip2, {_y: -6, time: 5.000000E-001, transition: "easeOutCubic"});
var _loc1 = new Sound();
_loc1.attachSound("bt_snd");
_loc1.start();
} // End of the function
function btnCatOut(clip1, clip2)
{
caurina.transitions.Tweener.addTween(clip1, {_y: -27, time: 3, transition: "easeOutCubic"});
caurina.transitions.Tweener.addTween(clip2, {_y: -24, time: 5.000000E-001, transition: "easeOutCubic"});
} // End of the function
function clearThumbs()
{
for (var _loc1 = 1; _loc1 <= lenGall; ++_loc1)
{
_thumbs._thumbs["thumb" + _loc1].removeMovieClip();
} // end of for
} // End of the function
function getDes()
{
var _loc2 = new Object();
_loc2.onMouseMove = function ()
{
if (_mask_des.hitTest(_root._xmouse, _root._ymouse))
{
caurina.transitions.Tweener.addTween(_descr, {_y: 407, time: 5.000000E-001, transition: "easeOutCubic"});
}
else
{
caurina.transitions.Tweener.addTween(_descr, {_y: 467, time: 5.000000E-001, transition: "easeOutCubic"});
} // end else if
};
Mouse.addListener(_loc2);
_descr._txt.text = arrayTitle[currentIndex];
} // End of the function
_thumbs._thumbs.setMask(_thumbs._mask);
_root.gallerySel = 1;
var lenGall;
var lenCat;
var mainGalleryNode;
var path;
var arrayImage = new Array();
var arrayThumb = new Array();
var arrayTitle = new Array();
var arrayDescription = new Array();
var arrayNameGall = new Array();
var currentIndex = 0;
var descStr;
var titleStr;
var sel = false;
var counter;
var intervalCat = 54;
var intervalBr = intervalCat / 2;
var yPos = 0;
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function (ok)
{
if (ok)
{
parsXML();
arrayThumbs();
menuCat();
getDes(); //Shows the Colour view bar
_mc2._mc.unloadMovie();
mcLoader.loadClip(arrayImage[0], _mc1._mc);
} // end if
};
gallery_xml.load("cgal.xml");
btnTop.onRollOver = btnBottom.onRollOver = function ()
{
this.gotoAndPlay("over");
};
btnTop.onRollOut = btnBottom.onRollOut = function ()
{
this.gotoAndPlay("out");
};
btnBottom.onRelease = function ()
{
if (_thumbs._thumbs._height > _thumbs._mask._height)
{
if (Math.abs(_thumbs._thumbs._y) < _thumbs._thumbs._height - _thumbs._mask._height && caurina.transitions.Tweener.isTweening(_thumbs._thumbs) != true)
{
yPos = yPos - (_thumbs._thumbs.thumb1._height + 1);
caurina.transitions.Tweener.addTween(_thumbs._thumbs, {_y: yPos, time: 5.000000E-001, transition: "easeOutCubic"});
} // end if
} // end if
};
btnTop.onRelease = function ()
{
if (_thumbs._thumbs._height > _thumbs._mask._height)
{
if (Math.abs(_thumbs._thumbs._y) > 0 && caurina.transitions.Tweener.isTweening(_thumbs._thumbs) != true)
{
yPos = yPos + (_thumbs._thumbs.thumb1._height + 1);
caurina.transitions.Tweener.addTween(_thumbs._thumbs, {_y: yPos, time: 5.000000E-001, transition: "easeOutCubic"});
} // end if
} // end if
};
caurina.transitions.properties.ColorShortcuts.init();
_descr._btn_color.onRollOver = function ()
{
caurina.transitions.Tweener.addTween(_mc2._mc, {_saturation: 1, time: 2});
};
_descr._btn_color.onRollOut = function ()
{
caurina.transitions.Tweener.addTween(_mc2._mc, {_saturation: 0, time: 2});
};
var mcLoader = new MovieClipLoader();
var loadListener = new Object();
loadListener.onLoadStart = function (mcTarget)
{
_root.loadImBig = true;
_root._content.pages.page1.page1.attachMovie("mcPercents", "mcPercents", this.getNextHighestDepth());
_root._content.pages.page1.page1.mcPercents._x = _mask_des._width / 2 - 10;
_root._content.pages.page1.page1.mcPercents._y = _mask_des._height / 2 - 25;
};
loadListener.onLoadProgress = function (mcTarget, bytesLoaded, bytesTotal)
{
var _loc2 = Math.ceil(bytesLoaded / bytesTotal * 100);
_root._content.pages.page1.page1.mcPercents.txtPercents.text = _loc2 + "%";
};
loadListener.onLoadComplete = function (mcTarget)
{
_root._content.pages.page1.page1.mcPercents.mcLoading.removeMovieClip();
_root._content.pages.page1.page1.mcPercents.removeMovieClip();
};
loadListener.onLoadInit = function (mcTarget) //Controls the different tabs at the bottom
{
caurina.transitions.Tweener.addTween(_mc2._mc, {_saturation: 0, time: 5.000000E-001});
mask_mc.gotoAndPlay(2);
_white.gotoAndPlay(2);
};
mcLoader.addListener(loadListener);
Edit:
After taking a look at snapplex's project files, it appears the issue may be a difference in behaviour between Flash versions when a mask is completely empty.
The grey saturation has a mask which animates and finishes on a blank frame. This hides the masked object in the test environment (targeting Flash Player 8), but shows the whole object in browser (with the latest player version).
A quick workaround is to add a shape to the mask which is off stage, which leaves the masked object invisible in both player versions.
(My original answer suggested Flash didn't receive rollover events without focus, but this was incorrect.)