PDA

View Full Version : Flash 6 A.S to Flash 8 A.S Help



Cloakendagger
December 28th, 2006, 03:31 PM
Hello,
It's been a while since I posted on this forum but I have run into a bit of a problem. I purchased a simple photo gallery online but didn’t notice that it was coded for flash player 6. My current project is going to be published in Flash player 8 due to some heavy alpha channel flash video effects. I would greatly appreciate it if some one could glance at this code below and let me know if they see anything that would not function correctly in Flash Player 8. When it is published in flash 8 the images don’t load.

Thanks Alot!!
Cloakendagger



screen.swapDepths(1000);
numOfPhoto = 20;
current = 0;
temp = 5;
for (i = 1; i <= numOfPhoto; i++)
{
this.attachMovie("btn", i, i);
this[i]._x = 35 + (i - 1) % temp * 20;
this[i]._y = 45 + Math.floor((i - 1) / temp) * 20;
this[i].defaultX = this[i]._x;
this[i].defaultY = this[i]._y;
this[i].onRollOver = function ()
{
this.onEnterFrame = function ()
{
this._xscale = this._xscale + (140 - this._xscale) / 2;
this._yscale = this._xscale;
};
};
this[i].onRollOut = this[i].onDragOut = function ()
{
this.onEnterFrame = function ()
{
this._xscale = this._xscale + (100 - this._xscale) / 2;
this._yscale = this._xscale;
};
};
this[i].onRelease = function ()
{
description.targetAlpha = -100;
if (!active)
{
screen.unloadMovie();
if (current != this._name)
{
old = current;
current = this._name;
} // end if
active = 1;
this._parent.onEnterFrame = function ()
{
this[current]._x = this[current]._x + (200 - this[current]._x) / 2;
this[current]._y = this[current]._y + (200 - this[current]._y) / 2;
this[old]._x = this[old]._x + (this[old].defaultX - this[old]._x) / 2;
this[old]._y = this[old]._y + (this[old].defaultY - this[old]._y) / 2;
this[old].gotoAndStop(2);
if (Math.abs(200 - this[current]._x) < 0.100000 && Math.abs(this[old].defaultX - this[old]._x) < 0.100000)
{
active = 0;
this.screen.loadMovie("http://www.ohmyflash.com/gallery/image7/image" + current + ".jpg");
this[current].onEnterFrame = function ()
{
temp1 = this._parent.screen.getBytesLoaded();
temp2 = this._parent.screen.getBytesTotal();
this.percent._yscale = temp1 / temp2 * 100;
};
delete this["onEnterFrame"];
} // end if
};
} // end if
};
} // end of for
description.onEnterFrame = function ()
{
this._alpha = this._alpha + (this.targetAlpha - this._alpha) / 20;
if (this._alpha < 0)
{
this.targetAlpha = 100;
this.gotoAndStop(Number(current) + 1);
} // end if
};


/////////////////////////////////////////////////////////////////////



onClipEvent (data)
{
this._alpha = 10;
}
onClipEvent (enterFrame)
{
if (this._alpha < 100)
{
this._alpha = this._alpha + 10;
} // end if
}

Kraken
December 28th, 2006, 04:26 PM
Have you tried it on the server? Sometimes it won't work when using "test movie" due to security restrictions.

Secondly, please throw some trace actions in there or use the debugger to see where it is breaking. Are the variables correct? Are you getting any error messages? Are all the movieClips correctly named and referred to? Is it taking too long for the server to respond and the code is tripping up? These are things you will have to do to figure out what's going on.

Cloakendagger
December 28th, 2006, 05:19 PM
Have you tried it on the server? Sometimes it won't work when using "test movie" due to security restrictions.

Secondly, please throw some trace actions in there or use the debugger to see where it is breaking. Are the variables correct? Are you getting any error messages? Are all the movieClips correctly named and referred to? Is it taking too long for the server to respond and the code is tripping up? These are things you will have to do to figure out what's going on.


When I run the debuger it gets into trouble at this block of code.


active = 1;
this._parent.onEnterFrame = function() {
this[current]._x = this[current]._x+(200-this[current]._x)/2;
this[current]._y = this[current]._y+(200-this[current]._y)/2;
this[old]._x = this[old]._x+(this[old].defaultX-this[old]._x)/2;
this[old]._y = this[old]._y+(this[old].defaultY-this[old]._y)/2;
this[old].gotoAndStop(2);
if (Math.abs(200-this[current]._x)<0.100000 && Math.abs(this[old].defaultX-this[old]._x)<0.100000) {
active = 0;
this.screen.loadMovie("http://www.ohmyflash.com/gallery/image7/image"+current+".jpg");
this[current].onEnterFrame = function() {
temp1 = this._parent.screen.getBytesLoaded();
temp2 = this._parent.screen.getBytesTotal();
this.percent._yscale = temp1/temp2*100;
};
delete this["onEnterFrame"];
}
// end if
};
}
// end if
};
}
// end of for



specificly this line of code

if (Math.abs(200-this[current]._x)<0.100000 && Math.abs(this[old].defaultX-this[old]._x)<0.100000) {


From there it just loops and does nothing.

Cloakendagger
December 28th, 2006, 05:40 PM
Here is a link to the test file on my server. It simply wont load the images.LINK (http://www.sporecreative.com/test.html)

Kraken
December 28th, 2006, 05:42 PM
Hmm...looks like it's tweening something and it's probably choking on the scope of the variables, specifically "current", "old" and "defaultX". If you throw a trace action in there, what are the values of those variables just before the if statment is run?

Cloakendagger
December 28th, 2006, 05:55 PM
If I trace it it just says undefinded when it hits that math if statment.

Cloakendagger
December 28th, 2006, 06:00 PM
here is a link to the source file LINK IT (http://www.sporecreative.com/41.zip)

Kraken
December 28th, 2006, 10:47 PM
Man! I went a little off the rails tonight and decided to re-work this whole thing! Take a look at this:
http://www.richpaul.com/flash/flash6_to_flash8/41_kraken2.html

I stripped out all of his inline functions. I made the variables strictly typed. I used Zeh's MCTween prototype for all the animation. I used a MovieClipLoader class to load the images. And added a couple of effects for good measure.

Sorry, I know this probably won't help you much, but go ahead and grab the FLA:
http://www.richpaul.com/flash/flash6_to_flash8/41_kraken2.fla

Learn what you can from it. It's more how I would go about something like this than what you had before with more updated code. It's still not dynamic which would be the next step. You could have all the image locations and text in an XML file that would load first, then build the buttons. But, I already got too carried away for my own good.

Hope it helps :)

Cloakendagger
December 29th, 2006, 02:33 PM
WOW!!! Great work!! I like the load effect you added. Could you please provide the mc_tween2.as file? It keeps giving me an error trying to find it.

Private message me with your contact info. I have some more quick projects in the working. (will pay for future work)

Thanks!!

Kraken
December 29th, 2006, 02:43 PM
What you need to do is grab the latest MXP installer from here:
http://hosted.zeh.com.br/mctween/downloads.html

Just install that via the extension manager and you will be good to go. MC Tween is a good way to jump into tweening with actionscript. Easy to use and pretty powerful.

Cloakendagger
December 29th, 2006, 03:13 PM
I must be missing something here because even with the exention loaded the version I download still doesnt load the images. It gives me a trace error at OldMC:

Cloakendagger
December 29th, 2006, 09:38 PM
I had one of my awsome programmers take a look at it and this is what he said to fix it. (Credits go to Yeldarb...The best and greatest A.S programmer in the world!!)

replace line 47 with this:

if (Math.abs(200 - this[current]._x) < 0.100000 || Math.abs(this[old].defaultX - this[old]._x) < 0.100000)

Then publish it in flash 8.

Thanks for all your help!!

Cloak