Oct 26

Here’s the code for a ‘zoom’ effect for a flash movie which zooms into any spot the viewer clicked, then back out once the mouse is released. You can see it in action in the flash movie ‘Disco Penguin‘.

The main core of the code is at Auto Zoom at FlashKik.com. It was submitted by T Norman at N T Designs. The Actionscript is as follows:

myZoom = function (myDepth) {
if (myDepth == "deep") {
myDepth = 4;
} else if (myDepth == "medium") {
myDepth = 8;
} else if (myDepth == "light") {
// default
myDepth = 12; }
trace(myDepth);
_root.onMouseDown = function()  {
if (k>0) { return; } zoom = true;
dir == 1 ? (dir=-1) : (dir=1);
if (dir == 1) {
pt = {x:_root._xmouse, y:_root._ymouse}; } };
this.onEnterFrame = function() {
if (!zoom) { return; }
_root._xscale += dir*k*50/myDepth;
_root._yscale += dir*k*50/myDepth;
var pt2 = {x:pt.x, y:pt.y};
_root.localToGlobal(pt2);
_root._x -= (pt2.x-pt.x);
_root._y -= (pt2.y-pt.y);
k++; if (k == 8) {
zoom = false; k = 0; } }; };
myZoom("medium");

It had the zoom effect but didn’t zoom out on mouse release. The actionscript in this movie required the user to click a second time to zoom back out. An onMouseUp event was needed to switch the direction of the zoom. The enterframe operation is never halted, it runs continuously. The variable “k” is used as an increment in the scale equation:

_root._xscale += dir*k*50/myDepth;

The if statement just resets the increment variable to 0 if it reaches 8. The variable itself just acts as a counter. The direction of the zoom determines whether the scale is in or out. If dir = -1… the scale would be the same as _root._xscale-=value. If dir=1 _root._xscale+=value.
In the end, to get a zoom in effect with zoom out on mouse release the actionscript needed to be as follows:

myZoom = function (myDepth) {
if (myDepth == "deep") {
myDepth = 4;
} else if (myDepth == "medium") {
myDepth = 8;
} else if (myDepth == "light") {
// default
myDepth = 12; }trace(myDepth);
_root.onMouseDown = function() {
if (k>0) {
return; }
zoom = true;
dir == 1 ? (dir=-1) : (dir=1);
if (dir == 1) {
pt = {x:_root._xmouse, y:_root._ymouse};
scale = true; }
if (dir == -1) {
scale = false;
} }
_root.onMouseUp = function() {
if (k>0) {
return;
zoom = false; }
dir == 1 ? (dir=-1) : (dir=1);
zoom = true; }
this.onEnterFrame = function() {
if (!zoom) {
return; }
_root._xscale += dir*k*50/myDepth;
_root._yscale += dir*k*50/myDepth;
var pt2 = {x:pt.x, y:pt.y};
_root.localToGlobal(pt2);
_root._x -= (pt2.x-pt.x);
_root._y -= (pt2.y-pt.y);
k++;
if (k == 8) {
zoom = false;
k = 0;
} } }
//Usage
myZoom("medium");
Oct 19

Here’s a half attempt at a CD / DVD textifier.

MP3 CDs and DVDs can hold so many albums / tracks it’s difficult to write all the tracks on the disc in a legible fashion. It would be nice to have something to create a label with the track listings printed on the physical disc so you can remember what’s on there without putting them in a device. The best way to use up the available room is to have the text curve around the disc in a spiral-like fashion.

This ActionScript code may be one way of creating It uses source code for a flash application that creates a swirl effect with text. Code by g.wygonik of cut.rate.box.

With a small amount of tinkering It now works in a very limited fashion to this end, but not very well, and only for about 100 characters.

So basically, that’s the concept. It needs limits to the trig so that the curvature regresses to align more accurately in relation to the length of the input. It also needs a image export script. A form for adding track names and assigning numbers would also be good.
Anyway, here it is:

This movie requires Flash Player 6 or above

The CD / DVD Textifier