SwishMax Image Explorer
The Flash
Usage
The image to load is designated in the Onload if the "holder" sprite
img.loadMovie("your file here");
The Download
Download swish fileScribbles III
The Flash
The Script
function DrawBox(sName,fc,bc,w,h,x,y,dpth,opc,speed){
ref = _root.createEmptyMovieClip(sName,dpth);
ref.lineStyle(0,0xFFFFFF,100);
ref.moveTo(x,y);
ref.lineStyle(0,bc,opc);
ref.beginFill(fc,opc);
ref.lineTo(x+w,y);
ref.lineTo(x+w,y+h);
ref.lineTo(x,y+h);
ref.lineTo(x,y);
ref.endfill();
ref.onEnterFrame = function(){
this._X -= _root.randomX;
this._X *= speed;
this._X += _root.randomX;
this._Y -= _root.randomY;
this._Y *= speed;
this._Y += _root.randomY;
if(xxx>24){setStage()}
};
}
function setStage(){
xxx=1;
randomX = random(stage.width);
randomY = random(stage.height);
}
onLoad(){
DrawBox("box",0x666666,0x000000,5,5,0,0,25,50,0.9) ;
}
onEnterFrame(){
xxx++;
if(xxx>48){setStage()}
_root.lineStyle(0,0x333333,25);
_root.lineTo(box._X+2.5,box._Y+2.5);
}
The Download
Download swish fileScripted Motion w/ easing
The Flash
The Script
function DrawBox(sName,fc,bc,w,h,x,y,dpth,opc,speed){
ref = _root.createEmptyMovieClip(sName,dpth);
ref.lineStyle(0,0xFFFFFF,100);
ref.moveTo(x,y);
ref.lineStyle(0,bc,opc);
ref.beginFill(fc,opc);
ref.lineTo(x+w,y);
ref.lineTo(x+w,y+h);
ref.lineTo(x,y+h);
ref.lineTo(x,y);
ref.endfill();
ref.xxx=24;
ref.randomX = random(600);
ref.randomY = random(300);
ref.onEnterFrame = function(){
this.xxx+=(random(2));
this._X -= this.randomX;
this._X *= 0.9;
this._X += this.randomX;
this._Y -= this.randomY;
this._Y *= 0.9;
this._Y += this.randomY;
if(this.xxx>50){
this.xxx=1;
this.randomX = random(600);
this.randomY = random(300);}
};
ref.OnFrame(2) = function(){gotoandplay(1)}
}
onLoad(){
i=30;
for (t=0; t<=i; t++) {
DrawBox("box" + t,0x666666,0x000000,5,5,0,0,t,100,0.9) ;
}
}
The Download
Download swish fileSimple Swish Tooltips
Fully scripted tooltips that can easily be applied to just about any object within your Swish movie.
The Script
function tooltip(str){
showtt = (!_root.showtt);
showtext=str;
}
OnLoad(){
_root.createEmptyMovieClip("holder",0);
holder.createTextField("xxx",0, 0,0, 500, 18);
ref=_root.holder.xxx;
ref.Text = "tooltip";
ref.border = false;
}
OnEnterFrame(){
holder._visible = _root.showtt;
holder.xxx.Text=_root.showtext;
holder._X = _xmouse+15;
holder._Y = _ymouse;
}
Usage
Plug the code above into the root of your movie, then lay down any objects.. buttons, sprites and add the following to the Rollover and Rollout events
onSelfEvent (rollOver) {
_root.tooltip("TOOLTIP TEXT HERE")
}
onSelfEvent (rollOut) {
_root.tooltip()
}
The Download
Download swish fileEKG
Building on the Drawing API again and constantly moving the root movie we create a nice and clean EKG effect in Swishmax
The Script
function ekg(){
myX=400;
_root._X=0;
ref=_root.createEmptyMovieClip("line",1);
ref.lineStyle(1,0x000000,0);
ref.moveTo(250,150);
boolStarted = false
}
OnLoad() {
ekg()
}
onEnterFrame(){
if (boolStarted){ref.lineStyle(0,0x3300FF,100);}
myX+=2;_root._X-=2;
if((random(10)+1)>7){line.lineTo(myX,random(300));}else{line.lineTo(myX,150);}
if(_root._X<-2000){line.clear();ekg()}
}
onFrame(2){boolStarted=true}
}
The Download
Swish Resizer
The Flash
The Script
While this could most definitely be trimmed down, as a far as the amount of code, I was very tired of looking at it
function DrawBox(sName,s,fc,bc,w,h,x,y,dpth,opc){
ref= this.createEmptyMovieClip(sName,dpth);
ref.lineStyle(0,0xFFFFFF,0);
ref.moveTo(x,y);
ref.lineStyle(0,bc,10);
ref.beginFill(fc,opc);
ref.lineTo(x+w,y);
ref.lineTo(x+w,y+h);
ref.lineTo(x,y+h);
ref.lineTo(x,y);
ref.endfill();
ref.onEnterFrame = function(){
this._X -= 250-(this._width/2);
this._X *= 0.4;
this._X += 250-(this._width/2);
this._Y -= 250-(this._height/2);
this._Y *= 0.4;
this._Y += 250-(this._height/2);
}
}
function setStage(){
DrawBox("shadowBox",0,0x000000,0x000000,boxW,boxH,0.5,0.5,1,50);
DrawBox("whiteBox",1,0xffffff,0x000000,boxW-2,boxH-2,0,0,2,100);
DrawBox("contentBox",1,0xA24B30,0x000000,boxW-8,boxH-8,0,0,3,100);
}
onLoad(){
movieH = 500;
movieW = 500;
movieXC = movieW/2;
movieYC = movieH/2;
boxH = 100;
boxW = 300;
boxX = movieXC-(boxW/2);
boxY = movieYC-(boxH/2);
setStage();
nWidth = 300;
nHeight = 100;
steps=10;
}
onEnterFrame() {
if (shadowBox._height < nHeight){
shadowBox._height+=(nHeight/steps);
contentBox._height+=(nHeight/steps);
whiteBox._height+=(nHeight/steps);
}
if (shadowBox._height > nHeight){
shadowBox._height-=(nHeight/steps);
contentBox._height-=(nHeight/steps);
whiteBox._height-=(nHeight/steps);
}
if (shadowBox._width < nWidth){
shadowBox._width+=(nWidth/steps);
contentBox._width+=(nWidth/steps);
whiteBox._width+=(nWidth/steps);
}
if (shadowBox._width > nWidth){
shadowBox._width-=(nWidth/steps);
contentBox._width-=(nWidth/steps);
whiteBox._width-=(nWidth/steps);
}
_root.ONE._X = shadowBox._X;
_root.ONE._Y = shadowBox._Y-15;
_root.TWO._X = shadowBox._X+50;
_root.TWO._Y = shadowBox._Y-15;
_root.THREE._X = shadowBox._X+100;
_root.THREE._Y = shadowBox._Y-15;
}
OnLoad(){
n=5;
ref = this.createEmptyMovieClip("ONE",n++);
ref.createTextField("ONE",n++, 0,0,40,18);
ref.ONE.text = this.ONE._name;
ref.onRelease = function(){
_root.nWidth = 300;
_root.nHeight = 100;
};
ref = this.createEmptyMovieClip("TWO",n++);
ref.createTextField("TWO",n++, 0,0,40,18);
ref.TWO.text = this.TWO._name;
ref.onRelease = function(){
_root.nWidth = 150;
_root.nHeight = 100; ;
};
ref = this.createEmptyMovieClip("THREE",n++);
ref.createTextField("THREE",n++, 0,0,50,18);
ref.THREE.text = this.THREE._name;
ref.onRelease = function(){
_root.nWidth = 400;
_root.nHeight = 250; ;
}
}
onFrame(1){stop();}
The Download
Line Following
Swishcripted line leading to the left and always following the cursor. SLightly on the experimental Swishscript side of thing, could be useful somewhere.
The Script
OnLoad() {
ref=_root.createEmptyMovieClip("line",1);
ref.lineStyle(0,0xFFFFFF,0);
ref.lineStyle(5,0x000000,100);
}
OnEnterFrame(){
line.lineTo(_root._xmouse,_root._ymouse);
_root._X----;
}
}
The Download
ActionScript Form Fields
A handy function for faster form input fields development in Swishmax and Swishscript
The Script
function makeField(fname,label,x,y,typ){
n++;
typSTR = New String;
typSTR = typ;
fieldTXT = new TextFormat();
fieldTXT.bold = true;
fieldTXT.size = 10;
fieldTXT.font = "Verdana";
_root.createTextField(label,n, x,y-18, 100, 18);
ref=this[label];
ref.Text = label;
ref.border = false;
ref.setTextFormat(fieldTXT);
n++;
_root.createTextField(fname,n, x, y, 100, 18);
ref=this[fname];
ref.type = "input";
ref.border = true;
ref.setTextFormat(fieldTXT);
if (typSTR == "pass"){ref.password = true;}
}
OnLoad(){
//makefield(field name, label, x, y, pass?)
makeField("input_fname","First Name",10,50);
makeField("input_lname","Last Name",150,50);
makeField("input_email","Email Address",10,100);
makeField("input_URL","URL",150,100);
makeField("input_username","Username",10,150);
makeField("input_password","Enter Password",150,150,"pass");
}
}
The Download
Heat Seeking Cursor
An interesting and original cursor effect, again, the cursor and the effect are fully swishscripted.
REQUIRES MOUSE OVER
The Script
function DrawBox(sName,s,fc,bc,w,h,x,y,dpth,opc){
ref=_root.createEmptyMovieClip(sName,dpth);
ref.lineStyle(0,0xFFFFFF,0);
ref.moveTo(x,y);
ref.lineStyle(0,bc,opc);
ref.beginFill(fc,opc);
ref.lineTo(x+w,y);
ref.lineTo(x+w,y+h);
ref.lineTo(x,y+h);
ref.lineTo(x,y);
ref.endfill();
}
OnLoad() {
Mouse.hide();
i=100;
nSize=50;
nChange=nSize/i;
boxNames.length=i;
for (t=0;t<=i;t++) {
DrawBox("box"+[t],1,0xffffff,0x000000,nSize,nSize,0,0,t,10);
boxNames[t]="box"+[t];
nSize-=nChange;
}
}
OnEnterFrame(){
nSpeed=0.1;
for(t=0;t<=i;t++){
ref=this["box" + t];
ref._x -= _root._xmouse-(ref._width/2);
ref._x *= nSpeed;
ref._x += _root._xmouse-(ref._width/2);
ref._y -= _root._ymouse-(ref._height/2);
ref._y *= nSpeed;
ref._y += _root._ymouse+-(ref._height/2);
nSpeed+=((0.9/i)-0.001)
}
}
The Download
Fun with spirals
A tutorial and swish scource code for generating a spiral gives our first inkling into pseudo-physics in Swishmax
The Script
function settings(){
angle=45;
x=150;
r=1;
y=150;
_root.createEmptyMovieClip("holder",0);
holder.lineStyle(0, 0x000000, 100);
holder.moveTo(x+r, y);
a = Math.tan(22.5 * Math.PI/180);
}
onLoad() {
settings();
}
onframe(1){
var endx = r*Math.cos(angle*Math.PI/180);
var endy = r*Math.sin(angle*Math.PI/180);
var cx =endx + r*a*Math.cos((angle-90)*Math.PI/180);
var cy =endy + r*a*Math.sin((angle-90)*Math.PI/180);
holder.curveTo(cx+x, cy+y, endx+x, endy+y);
}
onframe(2){
angle+=45;
r++;
if(r>200){holder.clear();settings();}
gotoandplayPrev();
}
Fun with this script
This is one of those scripts you can play with endlessly, like spirograph. Here's a minor modification made simply by changing the r(radius) value to -200 and. I change the "if(r>200)" bit to "if(r>225)" just to hold the look of the finished spiral al ittle longer.
The Download(s)
Download swish file #2Color Grid
Generating a grid of randomly colored sqaures with Swishscript. This really ends up being a tutorial about positioning and size control with swishscript.
The Script
onLoad()
{
nLevel=0;x=0;y=0;nsize=20;nColor=0xFFFFFF;
}
onFrame(1)
{
_root.createEmptyMovieClip("holder",nLevel);
holder.moveTo(x,y);
holder.lineStyle(0,nColor,100);
holder.beginFill(Math.round(Math.random()*0xFFFFFF), 100);
holder.lineTo(x+nsize,y);
holder.lineTo(x+nsize,y+nsize);
holder.lineTo(x,y+nsize);
holder.lineTo(x,y);
endfill()
}
onFrame(2)
{
nLevel++;
x+=nsize;
if(x>300-nsize){x=0;y+=nsize;}
if(y>300-nsize){y=0;nLevel=0}
gotoandPlay(1);
}
The Download
Download swish fileScribbles
Overview
Using the drawing API in the Flash Player we have a simple bit of script that generates lines in random directions, or random color and thickness and occasionally a curve as well.
A usual the actionscript I implement in this script will not play in the internaly Swishmax player, as it is built on the Flash Player 4. The latest Flash Player 5+ should play this without any of the actionscript issues you will see in the internal Swishmax player.
The Flash
The Script
function makeHolder() {
nColor=Math.round(Math.random()*0xFFFFFF);
x=0;
holder.clear();
_root.createEmptyMovieClip("holder",0);
MaxLines=Random(30)+1;
nSize=Random(10);
holder.moveTo(a,d);
}
onFrame (1) {
if (x>MaxLines) {
makeHolder();
}
}
onFrame (2) {
x++;
a=Random(300)+1;
b=Random(300)+1;
c=Random(300)+1;
d=Random(300)+1;
holder.lineStyle(nSize,nColor,100);
if (x==Random(10)+1) {
holder.lineTo(c,b);
}
holder.curveTo(a,b,c,d);
prevFrameAndPlay();
}