To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 05-25-2004, 06:16 PM   #1
FDR
Junior Member
 
Join Date: May 2004
Location: calgary canada
Posts: 1
looking for a tutorial for THIS type of transition

Im just starting to learn actionscript and I was hoping someone would have a little feedback on how to do something similar to the transitions on this site.

http://www.jiolahy.it/

Im thinking its just a mask with script repeating a pattern which gradually changes, but i need some input from the experts....

thanks

FDR
FDR is offline   Reply With Quote
Old 05-25-2004, 07:05 PM   #2
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
Your assumption is right. I wrote this bit of code to mimic the effect - it creates a mask movieclip that can be used to mask an image. In this example, it's just masking a big red box.

To view the effect, attach this code to the timeline of a new blank movie. It looks better with a higher framerate (24 fps or better).

The basis of the effect is a cosine wave that is used to oscillate the little boxes a random number of times.

Some of the troublesome math in the script below is based on the property of the cosine wave - it has a cycle which 'ends' every 2*PI. In this code, the little boxes do a complete cycle every second. They are randomized so they are out of phase with each other. They oscillate for a few cycles and than stop.

The duration of oscillation is chosen so that the position of the waveform at the end of the oscillation will be at it's maximum value (so the box will be 'maxed out'.

code:


MovieClip.prototype.drawRect = function(x,y,r)
{
this.moveTo(x-r,y-r);
this.lineTo(x+r,y-r);
this.lineTo(x+r,y+r);
this.lineTo(x-r,y+r);
this.lineTo(x-r,y-r);
}

// code to oscillate an individual cell in the mask
oscillateBox = function()
{
var t = getTimer() - this.startTime;
this.clear();
this.beginFill(0x00FF00,100);
if (t > this.durMS) {
this.onEnterFrame = undefined;
this.drawRect(0,0,tw/2);
}
else {
w = Math.cos(this.phase + t*(2*Math.PI)/1000);
this.drawRect(0,0,tw/4+tw*w/2);
}
this.endFill();
}

// base represents the picture - replace this code with the code
// that loads the image - in this example, base is just a big red box.
this.createEmptyMovieClip("base",1);
base.beginFill(0xFF0000,100);
base.drawRect(Stage.height/2,Stage.height/2, Stage.height/2);

// Cell dimensions based on dividing the large image into 8x8
tw = Stage.height/8;

// code to setup the mask into a grid of cells
this.createEmptyMovieClip("mask",2);

n = 1;
for (var y = 0; y < 8; ++y) {
for (var x = 0; x < 8; ++x) {
var nam = 'tile_'+x+'_'+y;
var mc = mask.createEmptyMovieClip(nam, n++);
mc._x = x*tw+tw/2;
mc._y = y*tw+tw/2;
mc.phase = Math.random()*2*Math.PI;
mc.durMS = (1-mc.phase/(2*Math.PI)) + 1 + random(5);
mc.durMS *= 1000; // milliseconds
mc.startTime = getTimer();
mc.onEnterFrame = oscillateBox;
}
}

// mask the base image
base.setMask(mask);



__________________
jbum is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:44 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.