Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


I Find That Highly Logical, Captain

November 17, 2000

In the "dragger" MC, attached to the button, you will find the following:

on (press) {
    mouseClick=1;
}
on (release, releaseOutside) {
    mouseClick=0;
}

Nothing shocking here. This is just a lazy way of interacting with the control structure of the actual clip. They probably should be function calls, but, oh well.

The centerpiece of the actionscript is the movie - the actions attached to the "dragger" MC. The commenting is thorough, so I don't feel the need to expound. One thing that might not be obvious if you are coming from Flash 4: the onClipEvent handler with the argument enterFrame will execute its contents every time the layhead enters that frame. For a MC with one frame, that means that it will loop continuously, which is a HUGE relief from the Flash 4 2-frame Mickey Mouse construct.

The other thing that is different from Flash 4 is that this script applies to the movie clip as a whole. In other words, it is entered into the Actions window with the MC selected. In F4, you had to open up the movie clip and create a loop with at least 2 frames to get a script that repeatedly tested some conditions.

 

onClipEvent (load) {
//set the initial rotation of the dinosaur
	to a front view
compare=5;
}

onClipEvent (enterFrame) {
dinoFrame=_root.dino._currentframe;

//user is holding down mouse button
if(mouseClick==1){
	pos=this._x;

//the movie is 320px wide, with 15 sectors total,
//so each one is 16px wide
	sector=int(pos/16) + 1;

//user is moving mouse to the right
	if (sector > compare){
		bigger();

//user is moving mouse to the left
	}else if(sector < compare){
		smaller();
	}

_root.dino.gotoAndStop(dinoFrame);
compare=sector;

//user has let off button
}else{
	_root.dino.stop();
}

function bigger(){
//if the "dino" MC is at the end, start it over
//so it looks like a seamless cirle.
if (dinoFrame == 20){
	dinoFrame = 0;
	}
dinoFrame ++;
}

//and if the MC is at the beginning, skip to the end.
function smaller(){
if (dinoFrame == 1){
	dinoFrame = 21;
	}
dinoFrame --;

}
}
[Note: The 2nd and 3rd lines above are one line. They were split for formatting purposes]

Structuring the Flash Movie
3Dino - Another Approach to Flash 3D
Memoirs, Regrets


Up to => Home / Authoring / Flash / 3Dino




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers