Hallo Forum,
ich habe gerade mit Flash angefangen und habe Probleme mit meiner
Flash-website und zwar mit AS3.
Ich habe ein horizontales Menü mit verschiedenen Schaltflächen. Wenn
man eine Schaltfläche auswählt sollte diese Schaltfläche kurz nach oben gehen und die entsprechende Seite aufrufen.
Leider werden nur das erste und das letzte MC aufgerufen.
Kann mir jemand behilflich sein?
Im Voraus vielen Dank.
Code:
Code:import fl.transitions.*; import fl.transitions.easing.*; stop(); current = menu.first_button; setMove = true; yMove = -10; //Assign CLICK listeners for each menu button menu.first_button.addEventListener (MouseEvent.CLICK, buttonClicked); menu.second_button.addEventListener (MouseEvent.CLICK, buttonClicked); menu.third_button.addEventListener (MouseEvent.CLICK, buttonClicked); menu.fourth_button.addEventListener (MouseEvent.CLICK, buttonClicked); menu.fifth_button.addEventListener (MouseEvent.CLICK, buttonClicked); //Make the buttons look like buttons (hand cursor appears on hover) menu.first_button.buttonMode = true; menu.second_button.buttonMode = true; menu.third_button.buttonMode = true; menu.fourth_button.buttonMode = true; menu.fifth_button.buttonMode = true; //You can dispatch an event as well. So you can actually fake that the user has clicked the first button. menu.first_button.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); //This loader is used to load the external swf files var loader:Loader; //URLRequest stores the path to the file to be loaded var urlRequest:URLRequest; //This array holds all the tweens, so they //don't get garbage collected var tweens:Array = new Array(); //Stores the current page we are displaying var currentPage:MovieClip = null; //Stores the next page that we are going to display var nextPage:MovieClip = null; //This function is called when a menu button is clicked function buttonClicked (e:Event):void { //Create a new loader instance loader = new Loader(); //If we clicked the first button, we load the page1 if (e.target == menu.first_button && this != current) { urlRequest = new URLRequest("page1.swf"); loader.load (urlRequest); current.y = 0; setMove = true; current = menu.first_button;; } //If we clicked the second button, we load the page2 else if (e.target == menu.second_button && this != current) { urlRequest = new URLRequest("page2.swf"); loader.load (urlRequest); current.y = 0; setMove = true; current = menu.second_button; } //If we clicked the third button, we load the page3 else if(e.target == menu.third_button && this != current) { urlRequest = new URLRequest("page3.swf"); loader.load (urlRequest); current.y = 0; setMove = true; current = menu.third_button; } //If we clicked the fourth button, we load the page4 else if(e.target == menu.fourth_button && this != current) { urlRequest = new URLRequest("page4.swf"); loader.load (urlRequest); current.y = 0; setMove = true; current = menu.fourth_button; } //We load page5 since we know that another pages //is not clicked else { urlRequest = new URLRequest("page5.swf"); loader.load (urlRequest); current.y = 0; setMove = true; current = menu.fifth_button; } //We want to know when the next page is finished loading loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded); } this.addEventListener(Event.ENTER_FRAME,onEnterFrame); function onEnterFrame(e:Event):void{ if(setMove){ if(yMove < current.y){ current.y -- } else { setMove = false } } } //This function is called, when we have finished loading a content page function fileLoaded(e:Event):void { //The loader contains the page we are going to display. nextPage = e.target.content; //Let's animate the current page away from the stage. //First, we need to make sure there is a current page on the stage. if(currentPage != null) { //Tween the current page from left to the right var tweenX:Tween = new Tween(currentPage, "x", Regular.easeOut, currentPage.x, 500, 1, true); //Decrease the alpha to zero var tweenAlpha:Tween = new Tween(currentPage, "alpha", Regular.easeOut, 1, 0, 1, true); //Push the tweens into an array tweens.push(tweenX); tweens.push(tweenAlpha); //currentPageGone will be called when the tween is finished tweenX.addEventListener(TweenEvent.MOTION_FINISH, currentPageGone); } //There is no current page, so we can animate the next //page to the stage. The animation is done in //the showNextPage function. else { showNextPage(); } } //This function animates and displayes the next page function showNextPage():void { //Tween the next page from left to the center var tweenX:Tween = new Tween(nextPage, "x", Regular.easeOut, 200, 0, 1, true); //Tween the alpha to from 0 to 1 var tweenAlpha:Tween = new Tween(nextPage, "alpha", Regular.easeOut, 0, 1, 1, true); //Push the tweens into an array tweens.push(tweenX); tweens.push(tweenAlpha); //Add the next page to the stage addChild(nextPage); //Next page is now our current page currentPage = nextPage; } //This function is called when the current page has been animated away function currentPageGone(e:Event):void { //Remove the current page completely removeChild(currentPage); //Let's show the next page showNextPage(); }
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)