Tuesday, April 12, 2011

FYP2 - Critique 2 - Coding

The software i use is Adobe Flash while here some action script2 that I found and tested many time until it successful.

To write on the text, stroke will be written :

_root.createEmptyMovieClip("line", _root.getNextHighestDepth());
line.lineStyle(25, 0x000000, 100);

var drawing = false;

this.onMouseDown = function(){
    drawing = true;
}
this.onMouseUp = function(){
    drawing = false;
}

this.onEnterFrame= function(){
    if(drawing == false){
        this.line.moveTo(_xmouse,_ymouse)
    }
    if(drawing){
        this.line.lineTo(_xmouse,_ymouse)
    }
}

When user write on the text, sound will be play :

on (press) {
if (playing!=true) {
  _root.sixSound.stop();
  _root.fifthSound.start(0.1,999);
 
  _root.line.lineStyle(25, 0x000000, 100);
  playing=true;
}
}

on (release, rollOut, dragOut) {
if (playing==true) {
    _root.fifthSound.stop();
     _root.sixSound.start(0.1,999);
    playing=false;

}
}
on(dragOut){
    _root.sixSound.start(0.1,999);
}
on(release, releaseOutside){
    _root.sixSound.stop();
}

When user write out off the text, noise will out:

on (press) {
if (playing!=true) {
  _root.secondSound.start(0.1,999);
  playing=true;
}
}
on (release, rollOut, dragOut) {
if (playing==true) {
    _root.secondSound.stop();
    playing=false;

}
}

To define the sound :

firstSound = new Sound();
firstSound.attachSound("water_sound.mp3");
secondSound = new Sound();
secondSound.attachSound("water_noise.mp3");
thirdSound = new Sound();
thirdSound.attachSound("bird_sound.mp3");
forthSound = new Sound();
forthSound.attachSound("bird_noise.mp3");
fifthSound = new Sound();
fifthSound.attachSound("wind_sound.mp3");
sixSound = new Sound();
sixSound.attachSound("wind_noise.mp3");

To clean the writing :

line.clear();
line.lineStyle(25, 0x000000, 100);

No comments:

Post a Comment