Hello Everyone,
This is my first post here, but I’ve been lurking quite a bit and these forums have been a great help to me. However, I need some help with my current application.
In an attempt to teach myself hiragana, I’ve been developing flash applications to randomly show me characters. Now, I want the application to show 3 pictures to increase my speed at reading multiple characters at once.
I was hoping to adapt my current code to do this, however I fear it is beyond my abilities.
Below is the code I’m using:
this.pathToPics = "learned/";
// array with pictures (left blank here for ease)
this.pArray = [""];
function shuffle() {
return Math.floor(Math.random()*3)-1;
}
pArray.sort(shuffle);
this.fadeSpeed = 20;
this.pIndex = 0;
// MovieClip methods ----------------------------------
// d=direction; should 1 or -1 but can be any number
//loads an image automatically when you run animation
loadMovie(this.pathToPics+this.pArray[0], _root.photo);
MovieClip.prototype.changePhoto = function(d) {
// make sure pIndex falls within pArray.length
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.photo;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
// Actions -----------------------------------------
// these aren't necessary, just an example implementation
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
}
};
Key.addListener(this);
I’ll also attach the fla which has the layout of what I’m trying to accomplish. Idealy, the forward and backward button would change all 3 pictures randomly at the same time.
Here is the single character application if that would help as well.
http://www.auburn.edu/~shoemal/hiragana.html
Any help would be greatly appeciated! =)