Skip to main content
Participating Frequently
September 28, 2006
Answered

Conversion to Flash 8 from 6 - Movieclip.prototype Problem

  • September 28, 2006
  • 5 replies
  • 589 views
I built a flash site a client a few years back in Flash 6.

I have now begun a redesign for them and I want to upgrade to Flash 8, but some of my code that worked fine in Flash 6, is no longer functional when I change the publish settings to Flash 8 or even Flash 7.

The two functions in question are using the prototype property. It doesn't give me a error when I publish or even test in the actionscript code view, it just doesn't run. I have tried putting a trace within the function, but it won't even run that.

Here's the first one.

Movieclip.prototype.glide = function(x,y,inc){
this.onEnterFrame = function (){
var me = this;
me._x += (x-me._x)/inc;
me._y += (y-me._y)/inc;
if (Math.abs(x-me._x)<1){
me._x = x;
}
if (Math.abs(y-me._y)<1){
me._y = y;
}
if ((me._x == x) && (me._y == y)){
delete this.onEnterFrame;
trace("glide done!");
}
}
};
rightMenu.glide(609,91,4);


============================================

Here's the second one:

// display timer
count = 1;
MovieClip.prototype.playTimer = function(){
if (count == 1){
setPlayTimer = setInterval(playTimer, 1000);
count++;
}else if (count >= 10){
clearInterval(setPlayTimer);
count = 1;
if (currentContent == (bigContentTotal - 1)){
currentContent = 0;
contentLoader();
} else{
currentContent++;
contentLoader();
}
} else{
count++;
}
};


Can anyone pick out what needs to changed for compliance in flash 8. I'm sure it's something minor that I am missing.

Thanks in advance.
This topic has been closed for replies.
Correct answer kglad
the coding isn't going to work for several reasons. but the biggest problem is the logic of the entire function.

it appears to simply cycle the values of currentContent from 0 to (bigContentTotal - 1) and call contentLoader() every 10 seconds. that can be done much more easily with:

5 replies

kglad
Community Expert
Community Expert
September 29, 2006
you're welcome.

i don't see anything in your first message that would cause playTimer() to fail unless it was called while still executing a setInterval() loop.
kglad
Community Expert
Community Expert
September 28, 2006
then why define a prototype function? just use a regular function.
Participating Frequently
September 28, 2006
quote:

Originally posted by: kglad
then why define a prototype function? just use a regular function.


When I originally wrote it, I planned on using in more than one spot, but that never materlized.

I am leaning towards just writing a new function. I thought it would be easier to just figure why it wasn't working in Flash 8.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 28, 2006
the coding isn't going to work for several reasons. but the biggest problem is the logic of the entire function.

it appears to simply cycle the values of currentContent from 0 to (bigContentTotal - 1) and call contentLoader() every 10 seconds. that can be done much more easily with:

kglad
Community Expert
Community Expert
September 28, 2006
no, that's not going to work. where are you using playTimer()? do you ever apply it to more than one movieclip?
Participating Frequently
September 28, 2006
quote:

Originally posted by: kglad
no, that's not going to work. where are you using playTimer()? do you ever apply it to more than one movieclip?


No I only use it in the one spot.

Inspiring
September 28, 2006
bootyhunta schrieb:

> currentContent++;


Look here in debugger, currentContent isn't initialized. So the result
of ++ will be NaN (Not a number).
Participating Frequently
September 28, 2006
Sorry, I probably should have entered the all the code.

I actually am intializing the CurrentContent. Here's all of the code.

// list out content
bigContentTotal = _root.universal.main.bigContent.movie.length;
bigContent_arr = new Array(bigContentTotal);
for(i=0; i<bigContentTotal; i++){
bigContent_arr = _root.universal.main.bigContent.movie.contentPath;
}
//load the big content
currentContent = 0;
contentLoader = function(){
trace("bigContent = " + bigContent_arr[currentContent]);
loadMovie(bigContent_arr[currentContent], "loadHere");
}
// display timer
count = 1;
trace(currentContent);

MovieClip.prototype.playTimer = function(){
if (count == 1){
setPlayTimer = setInterval(playTimer, 1000);
count++;
}else if (count >= 10){
clearInterval(setPlayTimer);
count = 1;
if (currentContent == (bigContentTotal - 1)){
currentContent = 0;
contentLoader();
} else{
currentContent++;
contentLoader();
}
} else{
count++;
}
};
contentLoader();

------------------------------------------------------------

Your other solution worked! I knew it was something minor that I was missing. I guess I just needed a fresh set of eyes on it.



quote:

Originally posted by: Newsgroup User
bootyhunta schrieb:

> currentContent++;


Look here in debugger, currentContent isn't initialized. So the result
of ++ will be NaN (Not a number).



kglad
Community Expert
Community Expert
September 28, 2006
i'm not sure what problem you're having nor which prototype you still need help with, but your playTimer function is problematic because it loses its reference to the movieclip when called by setInterval(). in addition, you should prefix all your variables with "this." so more than one movieclip can simultaneously use your playTimer() method:



Inspiring
September 28, 2006
That was a hard one. I remember I had this one too.

Just take a look at the word:

MovieClip

It has to be case sensetive!