Create a Flash Mini Site Part I

Thu, Nov 19, 2009

ActionScript

Create a Flash Mini Site Part I

This movie requires Flash Player 9



Click here for the second part of this tutorial.


Avraham! What a great effect! How did you do it?

Well. It is a large movie clip that gets moved to specific coordinates every time a navigation bar button is pressed. Watch the tutorial and you will see!


DOWNLOAD THE SOURCE FILE
DynamicMapNavigationFinal

CLICK HERE FOR A COMPLETE ACTIONSCRIPT 3.0 CARTOON SMART TUTORIAL

HERE IS THE SOURCE CODE!

//The ActionScript 3.0 Flash Mini Site
// Avraham Saltoun
// solutions at say-web dot com
// FREE to USE, COPY and DISTRIBUTE

// Let’s import the libraries we plan to use

import fl.transitions.Tween;
import fl.transitions.easing.*;

// the star states we will import
// all eases

// Now we will create a batch of variables
// that will store the coordinates for each
// area of our large movie clip
// each pair represents a “page”

var homeX:Number= 103; // We will check on stage
// the coordinate for x and y when button home is clicked
var homeY:Number= 47;

// Now the same for prices

var pricesX:Number= 694;
var pricesY:Number=-365;

// Now the same for Contact
var contactX:Number= -489;
var contactY:Number=-379;

//These variables will hold the Tween
// to be executed

var xTween:Tween; // holds the horizontal tween
var yTween:Tween; // holds the vertical tween

xTween = new Tween (main_mc,”x”,Strong.easeInOut,main_mc.x,homeX,2,true);
yTween = new Tween (main_mc,”y”,Strong.easeInOut,main_mc.y,homeY,2,true);

// Event Listeners
home_btn.addEventListener(MouseEvent.CLICK, navigate);
prices_btn.addEventListener(MouseEvent.CLICK, navigate);
contact_btn.addEventListener(MouseEvent.CLICK, navigate);

//Note that all buttons will lead to the same function
//The only difference is the values they will pass

//Functions

function navigate (event:MouseEvent):void {

if (event.target == home_btn)
{
setTween (homeX, homeY);
}
else
if (event.target == prices_btn)
{
setTween (pricesX, pricesY);
}
else
if (event.target == contact_btn)
{
setTween (contactX, contactY);
}

}

function setTween ( tweenX:Number, tweenY:Number) :void
{

//This retrieves the location of our large movie clip
//To be used as starting point of our desired tween
xTween.begin = main_mc.x;
yTween.begin = main_mc.y;

//This assigns the values passed from
// the navigate function as the end location
// of the tween
xTween.finish = tweenX;
yTween.finish = tweenY;

//After assigning values, this fires the tween
xTween.start();
yTween.start();

}

xTween.stop();
yTween.stop();

// Subscribe from the website!

Related Articles:

, , , , , , , , , , , , , , ,

Leave a Reply

You must be logged in to post a comment.

My name is Avraham Saltoun, and I live in Jerusalem, Middle East. I am currently on my mid  40's and I am a computer programming technician. Here you will find over one hundred quality video tutorials on Actionscript, and yes, I give online support for aspiring programmers, and pros as well, sharing screen on skype and delivering source code by email, click the button for live flash actionscript support now!

 
oDesk Certified Action Script Programmer
oDesk Certified Adobe Flash CS3 Designer
oDesk Certified Adobe Photoshop 6.0 Designer
Skype Me™!

$7.49 .Com! Score Savings Cartoon Smart Tutorials


1,260
Unique Visitors
Previous 30 Days
Powered By Google Analytics