Fejlspotning i AS3: altid det sidste kode i mit if-statement der ikke virker, hvis jeg bytter om på noget er det igen det sidste.
Okay, Siden min kode er ret lang vil jeg prøve at forklare mit mål kort: Jeg laver et hallery på min flash side. En frame indeholder portfoliogalleriet og i den ramme er der thumbnails. Når man klikker på en thumbnail popper et gallerimovieclip op alt efter hvilken thumbnail det er. Når man klikker på en exit button inde i dette movieclip forsvider galleriet, og det samme sker når man skifter til en anden frame vha. menupunkterne. Exit button starter en dispatchevent funktion inde i gallerimovieclippet.Fejlen er i "if (currentLabel == "portfolio")" delen - eller det tror jeg. Jeg har mine variabler og funktioner linet op inde i if-statementet i par, men det er altid det sidste par i if-statementet som ikke kan exite vha exitbutton. Hvis jeg bytter om på koden så et andet par kommer til sidst, så er det DET par som ikke kan exite med exitbutton. Jeg kan simpelthen ikke spotte fejlen selvom den nok er simpel, men alle gallerimovieclip bruger den samme kode.
Jeg har inkluderet koden på min maintimeline da jeg er ret sikker på det er her problemet befinder sig.
Håber nogle kan spotte den fejl jeg ikke kan
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
var rewind=false;
stop();
/menu item 1 rewind and play/ about_mc.addEventListener(MouseEvent.MOUSE_OVER, manageMouseOver); about_mc.addEventListener(MouseEvent.MOUSE_OUT, manageMouseOut); about_mc.addEventListener(Event.ENTER_FRAME, manageEnterFrame); about_mc.addEventListener(MouseEvent.CLICK, gotoabout); function gotoabout (e:MouseEvent):void{
if(arch.parent ){
MovieClip(root).removeChild(arch);
}
if (fauna.parent ){
MovieClip(root).removeChild(fauna);
}
if (flora.parent ){
MovieClip(root).removeChild(flora);
}
if (street.parent ){
MovieClip(root).removeChild(street);
}
if(people.parent ){
MovieClip(root).removeChild(people);
}
if(misc.parent ){
MovieClip(root).removeChild(misc);
}
if(identity.parent ){
MovieClip(root).removeChild(identity);
}
if(web.parent ){
MovieClip(root).removeChild(web);
}
if(gfx.parent ){
MovieClip(root).removeChild(gfx);
}
else {
//do nothing
}
gotoAndStop('about');
}
/menu item 2 rewind and play/ contact_mc.addEventListener(MouseEvent.MOUSE_OVER, manageMouseOver); contact_mc.addEventListener(MouseEvent.MOUSE_OUT, manageMouseOut); contact_mc.addEventListener(Event.ENTER_FRAME, manageEnterFrame); contact_mc.addEventListener(MouseEvent.CLICK, gotocontact); function gotocontact (e:MouseEvent):void{
if(arch.parent ){
MovieClip(root).removeChild(arch);
}
if(fauna.parent ){
MovieClip(root).removeChild(fauna);
}
if(flora.parent ){
MovieClip(root).removeChild(flora);
}
if(street.parent ){
MovieClip(root).removeChild(street);
}
if(people.parent ){
MovieClip(root).removeChild(people);
}
if(misc.parent ){
MovieClip(root).removeChild(misc);
}
if(identity.parent ){
MovieClip(root).removeChild(identity);
}
if(web.parent ){
MovieClip(root).removeChild(web);
}
if(gfx.parent ){
MovieClip(root).removeChild(gfx);
}
else {
//do nothing
}
gotoAndStop('contact');
}
/menu item 3's function/ function gotoportfolio (e:MouseEvent):void{
gotoAndStop('portfolio');
}
/menu item 4 rewind and play/ paraselene_mc.addEventListener(MouseEvent.MOUSE_OVER, manageMouseOver); paraselene_mc.addEventListener(MouseEvent.MOUSE_OUT, manageMouseOut); paraselene_mc.addEventListener(Event.ENTER_FRAME, manageEnterFrame); paraselene_mc.addEventListener(MouseEvent.CLICK, gotoparaselene); function gotoparaselene (e:MouseEvent):void{
if(arch.parent ){
MovieClip(root).removeChild(arch);
}
if(fauna.parent ){
MovieClip(root).removeChild(fauna);
}
if(flora.parent ){
MovieClip(root).removeChild(flora);
}
if(street.parent ){
MovieClip(root).removeChild(street);
}
if(people.parent ){
MovieClip(root).removeChild(people);
}
if(misc.parent ){
MovieClip(root).removeChild(misc);
}
if(identity.parent ){
MovieClip(root).removeChild(identity);
}
if(web.parent ){
MovieClip(root).removeChild(web);
}
if(gfx.parent ){
MovieClip(root).removeChild(gfx);
}
else {
//do nothing
}
gotoAndStop('paraselene');
}
function manageEnterFrame(e:Event):void{
if(e.currentTarget.rewind == true){
e.currentTarget.prevFrame();
}
else {
//do nothing
}
}
function manageMouseOver(e:MouseEvent):void {
e.currentTarget.rewind=false;
e.currentTarget.play();
e.currentTarget.buttonMode = true;
e.currentTarget.useHandCursor = true;
}
function manageMouseOut(e:MouseEvent):void {
e.currentTarget.rewind=true;
}
//thumbnail effects
arch_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); arch_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); arch_mc.addEventListener(MouseEvent.CLICK, archgallery);
flora_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); flora_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); flora_mc.addEventListener(MouseEvent.CLICK, floragallery);
fauna_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); fauna_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); fauna_mc.addEventListener(MouseEvent.CLICK, faunagallery);
street_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); street_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); street_mc.addEventListener(MouseEvent.CLICK, streetgallery);
people_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); people_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); people_mc.addEventListener(MouseEvent.CLICK, peoplegallery);
misc_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); misc_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); misc_mc.addEventListener(MouseEvent.CLICK, miscgallery);
identity_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); identity_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); identity_mc.addEventListener(MouseEvent.CLICK, identitygallery);
web_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); web_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); web_mc.addEventListener(MouseEvent.CLICK, webgallery);
gfx_mc.addEventListener(MouseEvent.MOUSE_OVER, doeffect); gfx_mc.addEventListener(MouseEvent.MOUSE_OUT, endeffect); gfx_mc.addEventListener(MouseEvent.CLICK, gfxgallery);
function doeffect(e:MouseEvent):void {
e.currentTarget.gotoAndPlay('playeffect');
e.currentTarget.buttonMode = true;
e.currentTarget.useHandCursor = true;
}
function endeffect(e:MouseEvent):void {
e.currentTarget.gotoAndPlay('endeffect');
}
//add galleries
if (currentLabel == "portfolio") {
var flora:galleryflora = new galleryflora();
function floragallery (e:MouseEvent):void {
addChild(flora);
with(flora) {
x= 535,30;
y= 82;
}
}
var fauna:galleryfauna = new galleryfauna();
function faunagallery (e:MouseEvent):void {
addChild(fauna);
with(fauna) {
x= 535,30;
y= 82;
}
}
var arch:galleryarch = new galleryarch();
function archgallery (e:MouseEvent):void {
addChild(arch);
with(arch) {
x= 535,30;
y= 82;
}
}
var misc:gallerymisc = new gallerymisc();
function miscgallery (e:MouseEvent):void {
addChild(misc);
with(misc) {
x= 535,30;
y= 82;
}
}
var people:gallerypeople = new gallerypeople();
function peoplegallery (e:MouseEvent):void {
addChild(people);
with(people) {
x= 535,30;
y= 82;
}
}
var street:gallerystreet = new gallerystreet();
function streetgallery (e:MouseEvent):void {
addChild(street);
with(street) {
x= 535,30;
y= 82;
}
}
var identity:galleryidentity = new galleryidentity();
function identitygallery (e:MouseEvent):void {
addChild(identity);
with(identity) {
x= 535,30;
y= 82;
}
}
var gfx:gallerygfx = new gallerygfx();
function gfxgallery (e:MouseEvent):void {
addChild(gfx);
with(gfx) {
x= 535,30;
y= 82;
}
}
var web:galleryweb = new galleryweb();
function webgallery (e:MouseEvent):void {
addChild(web);
with(web) {
x= 535,30;
y= 82;
}
}
} //end if portfolio-label
else{
//do nothing
}
//exitbutton gallery flora.addEventListener("closeEvent", onClose); fauna.addEventListener("closeEvent", onClose); arch.addEventListener("closeEvent", onClose); street.addEventListener("closeEvent", onClose); people.addEventListener("closeEvent", onClose); misc.addEventListener("closeEvent", onClose); identity.addEventListener("closeEvent", onClose); web.addEventListener("closeEvent", onClose); gfx.addEventListener("closeEvent", onClose);
function onClose(me:Event):void { me.currentTarget.parent.removeChild(me.currentTarget); }