Wednesday, April 20, 2011

Coding and Programming

Coding is hardest part as for me because I am not so good in Action Scripts. I Google, asked around and got help from various places and people to complete my application. My tutor, Mr.Shahnaz, helped alot in coding and programming. He even suggested me few other solutions and ideas for my problems and animations in my application. He also guided me on how to play around with Action Scripts instead of having too many objects in one file. So, my application mouse event load with alot of Action Script 2.0. It actually makes my works lots easier.


Here are some of the SCRIPTS..
Script for Main Menu on Frame 11
stop();

//var numOfBalls:Number = 10;
var radiusX:Number = 280;
var radiusY:Number = 125;
var centerX:Number = 500; //Stage.width / 2;
var centerY:Number = 350; //Stage.height / 2;
var speed:Number = 0.05;
var vol:Number = 0;
var music = new Sound;
music.attachSound("soundtrack");
music.setVolume(0);
music.start(0, 99999);

this.onEnterFrame = function(){

             if (isSound) {
                                vol += 5;
                                music.setVolume(vol);
                                if (vol >= 100) {
                                                music.setVolume(100);
                                                this.onEnterFrame = null;
                                }
                }
                else {
                                this.onEnterFrame = null;
                }
}

/*
for(var i=0;i<numOfBalls;i++)
{
                var t = this.attachMovie("square","b"+i,i+1);
                t.angle = i * ((Math.PI*2)/numOfBalls);
                t._alpha = 0;
                t.onEnterFrame = mover;
}
*/
var ta = this.attachMovie("movieVideo", "movVideo", 10);
ta.angle = 0;
ta._alpha = 0;
ta.onEnterFrame = mover;

var tb = this.attachMovie("movieFacts", "movFacts", 11);
tb.angle = 0.333 * Math.PI * 2;
tb._alpha = 0;
tb.onEnterFrame = mover;

var tc = this.attachMovie("movieGallery", "movGallery", 12);
tc.angle = 0.666 * Math.PI * 2;
tc._alpha = 0;
tc.onEnterFrame = mover;

function mover()
{
                if (this._alpha < 100) {
                                this._alpha += 5;
                }
                this._x = Math.cos(this.angle) * radiusX + centerX;
                this._y = Math.sin(this.angle) * radiusY + centerY;
                var s = this._y /(centerY+radiusY);
                this._xscale = this._yscale = s*100;
                this.angle += this._parent.speed;
                this.swapDepths(Math.round(this._xscale) + 100);
}
this.onMouseMove = function()
{
                speed = (this._xmouse-centerX)/3000;
}

stop();


Script for Main Menu on Frame 17
this.onEnterFrame = function(){

               
                if (_root.idxMovie == 1) {
                                // only fadeout for video link
                                vol -= 5;
                                music.setVolume(vol);
                                if (vol <= 0) {
                                                music.stop();
                                                music.setVolume(100);
                                                this.onEnterFrame = null;
                                }
                }
}

movVideo.onEnterFrame = function() {
                movVideo._alpha -= 5;
                if (movVideo._alpha <= 0) {
                                movVideo.onEnterFrame = null;
                                movVideo.removeMovieClip();
                }
}

movFacts.onEnterFrame = function() {
                movFacts._alpha -= 5;
                if (movFacts._alpha <= 0) {
                                movFacts.onEnterFrame = null;
                                movFacts.removeMovieClip();
                }
}

movGallery.onEnterFrame = function() {
                movGallery._alpha -= 5;
                if (movGallery._alpha <= 0) {
                                movGallery.onEnterFrame = null;
                                movGallery.removeMovieClip();
                }
}

trace("idxMovie = " + idxMovie);

if (idxMovie == 1) {
                trace("video");
                gotoAndPlay("Video");
}
else if (idxMovie == 2) {
                trace("facts");
                gotoAndPlay("Facts");
}
else if (idxMovie == 3) {
                trace("gallery");
                gotoAndPlay("Gallery");
}
               

Script for Fact & Rituals Menu on Frame 110

stop();

//var numOfBalls:Number = 6;
var radiusX:Number = 150;
var radiusY:Number = 25;
var centerX:Number = 500; //Stage.width / 2;
var centerY:Number = 620; //Stage.height / 2;
var speed:Number = 0.05;

/*
for(var i=0;i<numOfBalls;i++)
{
                var t = this.attachMovie("square","b"+i,i+1);
                t.angle = i * ((Math.PI*2)/numOfBalls);
                t._alpha = 0;
                t.onEnterFrame = mover;
}
*/

var t1 = this.attachMovie("movieFactsArt","t1",101);
t1.angle = 0;
t1._alpha = 0;
t1.onEnterFrame = mover;

var t2 = this.attachMovie("movieFactsBlooms","t2",102);
t2.angle = 1 * ((Math.PI*2)/6);
t2._alpha = 0;
t2.onEnterFrame = mover;

var t3 = this.attachMovie("movieFactsBrides","t3",103);
t3.angle = 2 * ((Math.PI*2)/6);
t3._alpha = 0;
t3.onEnterFrame = mover;

var t4 = this.attachMovie("movieFactsColours","t4",104);
t4.angle = 3 * ((Math.PI*2)/6);
t4._alpha = 0;
t4.onEnterFrame = mover;

var t5 = this.attachMovie("movieFactsThali","t5",105);
t5.angle = 4 * ((Math.PI*2)/6);
t5._alpha = 0;
t5.onEnterFrame = mover;

var t6 = this.attachMovie("movieFactsWedding","t6",106);
t6.angle = 5 * ((Math.PI*2)/6);
t6._alpha = 0;
t6.onEnterFrame = mover;

/*
var ta = this.attachMovie("movieVideo", "movVideo", 10);
ta.angle = 0;
ta._alpha = 0;
ta.onEnterFrame = mover;

var tb = this.attachMovie("movieFacts", "movFacts", 11);
tb.angle = 0.333 * Math.PI * 2;
tb._alpha = 0;
tb.onEnterFrame = mover;

var tc = this.attachMovie("movieGallery", "movGallery", 12);
tc.angle = 0.666 * Math.PI * 2;
tc._alpha = 0;
tc.onEnterFrame = mover;
*/

trace("oops");

function mover()
{
                if (this._alpha < 100) {
                                this._alpha += 5;
                }
                this._x = Math.cos(this.angle) * radiusX + centerX;
                this._y = Math.sin(this.angle) * radiusY + centerY;
                var s = this._y /(centerY+radiusY);
                this._xscale = this._yscale = s*100;
                this.angle += this._parent.speed;
                this.swapDepths(Math.round(this._xscale) + 100);
}

this.onMouseMove = function()
{
                speed = (this._xmouse-centerX)/3000;
}

stop();
               

Script for Fact & Rituals Menu on Frame 134
titleFacts.onEnterFrame = function() {

               
                titleFacts._alpha -= 5;
                if (titleFacts._alpha <= 0) {
                                titleFacts.onEnterFrame = null;
                                titleFacts.removeMovieClip();
                }
               
}

t1.onEnterFrame = function() {
                t1._alpha -= 5;
                if (t1._alpha <= 0) {
                                t1.onEnterFrame = null;
                                t1.removeMovieClip();
                }
}

t2.onEnterFrame = function() {
                t2._alpha -= 5;
                if (t2._alpha <= 0) {
                                t2.onEnterFrame = null;
                                t2.removeMovieClip();
                }
}

t3.onEnterFrame = function() {
                t3._alpha -= 5;
                if (t3._alpha <= 0) {
                                t3.onEnterFrame = null;
                                t3.removeMovieClip();
                }
}

t4.onEnterFrame = function() {
                t4._alpha -= 5;
                if (t4._alpha <= 0) {
                                t4.onEnterFrame = null;
                                t4.removeMovieClip();
                }
}

t5.onEnterFrame = function() {
                t5._alpha -= 5;
                if (t5._alpha <= 0) {
                                t5.onEnterFrame = null;
                                t5.removeMovieClip();
                }
}

t6.onEnterFrame = function() {
                t6._alpha -= 5;
                if (t6._alpha <= 0) {
                                t6.onEnterFrame = null;
                                t6.removeMovieClip();
                }
}

mcFacts.onEnterFrame = function() {
                mcFacts._alpha -= 5;
                if (mcFacts._alpha <= 0) {
                                mcFacts.onEnterFrame = null;
                                clearInterval(_root.mcFacts.intervalPic);
                                _root.mcFacts.removeMovieClip();                        
                                mcFacts.removeMovieClip();
                }
}

_root.mcFactsSub._visible = false;
_root.mcFactsSub2._visible = false;

No comments:

Post a Comment