Pages: [1]
  Print  
Author Topic: Navigation Doesn't Work  (Read 192 times)
Steve Jenkins
Gaia User
**
Posts: 17


« on: August 04, 2011, 11:08:13 AM »

Hi;
Still trying to kill all the bugs in my first Gaia project Wink

The nav doesn't work on the server. The context menu (right click) does, but that's not what I want. I'm sure the problem has to do with how I'm creating text links, as per my old Flash style. I don't write in the timeline and I don't build assets in the library if I can avoid it. I do everything inside classes like this:

package pages
{
   import flash.text.TextFieldAutoSize;
   import flash.text.TextField;
   import flash.text.TextFormat;
   import com.gaiaframework.templates.AbstractPage;
   import com.gaiaframework.events.*;
   import com.gaiaframework.debug.*;
   import com.gaiaframework.api.*;
   import flash.display.*;
   import flash.events.*;
   import com.greensock.TweenMax;
   
   public class NavPage extends AbstractPage
   {
      public var homeButton:MovieClip = new MovieClip();
      public var speakersButton:MovieClip = new MovieClip();
      public var itineraryButton:MovieClip = new MovieClip();
      public var optional_ToursButton:MovieClip = new MovieClip();
      public var testimonialsButton:MovieClip = new MovieClip();
      public var about_UsButton:MovieClip = new MovieClip();
      public var contact_UsButton:MovieClip = new MovieClip();
      public var articlesButton:MovieClip = new MovieClip();
      private var releaseGaia:Function = Gaia.api.afterGoto(OnAfterGoto);
      private var navArray:Array = new Array(homeButton, speakersButton, itineraryButton, optional_ToursButton, testimonialsButton, about_UsButton, contact_UsButton, articlesButton);
      
      public function NavPage()
      {
         super();
         alpha = 0;
      }
      
      function OnAfterGoto(e:GaiaEvent):void
      {
         for each (var button:MovieClip in navArray)
         {
            if (button.branch = Gaia.api.getCurrentBranch())
            {
               TweenMax.to(button, .5, {tint:0x0000ff});
               button.buttonMode = false;
            } else {
               TweenMax.to(button, .5, {removeTint:true});
               button.buttonMode = true;
            }
         }
      }

      function Navigation(navName:String, navURL:String, myX:int, myTextColor:uint):void
      {
         var navMovieClip:MovieClip = new MovieClip();
         addChild(navMovieClip);
         var myNavigation:TextField = new TextField();
         var format:TextFormat = new TextFormat();
         format.font = 'Century Schoolbook';
         format.size = 15;
         myNavigation.text = navName;
         myNavigation.textColor = myTextColor;
         myNavigation.autoSize = TextFieldAutoSize.LEFT;
         myNavigation.setTextFormat(format);
         switch (navName)
         {
            case "Home":
               homeButton.branch = Pages.HOME;
               navMovieClip.addChild(homeButton);
               break;
            case "Speakers":
               speakersButton.branch = Pages.SPEAKERS;
               navMovieClip.addChild(speakersButton);
               break;
            case "Itinerary":
               itineraryButton.branch = Pages.ITINERARY;
               navMovieClip.addChild(itineraryButton);
               break;
            case "Opt. Extensions":
               optional_ToursButton.branch = Pages.OPTIONALTOURS;
               navMovieClip.addChild(optional_ToursButton);
               break;
            case "Testimonials":
               testimonialsButton.branch = Pages.TESTIMONIALS;
               navMovieClip.addChild(testimonialsButton);
               break;
            case "About Us":
               about_UsButton.branch = Pages.ABOUTUS;
               navMovieClip.addChild(about_UsButton);
               break;
            case "Contact Us":
               contact_UsButton.branch = Pages.CONTACTUS;
               navMovieClip.addChild(contact_UsButton);
               break;
            case "Articles":
               articlesButton.branch = Pages.ARTICLES;
               navMovieClip.addChild(articlesButton);
               break;
         }
         navMovieClip.addChild(myNavigation);
         navMovieClip.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
         navMovieClip.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
         navMovieClip.addEventListener(MouseEvent.MOUSE_UP, onPressHandler);
         navMovieClip.mouseChildren = false;
         navMovieClip.buttonMode = true;
         navMovieClip.x = myX;
         navMovieClip.y = 74;
      }

      private function onMouseOverHandler(e:MouseEvent):void
      {
//         Mouse.cursor="button";
      }

      private function onMouseOutHandler(e:MouseEvent):void
      {
//         Mouse.cursor="arrow";
      }

      private function onPressHandler(e:MouseEvent):void
      {
         Gaia.api.goto(e.target.branch);
      }

      override public function transitionIn():void
      {
         super.transitionIn();
         TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
         Navigation(' Home ','home.py',266,0xffffff);
         Navigation(' Speakers ','Speakers.py',328,0xffffff);
         Navigation(' Itinerary ','Itinerary.py',414,0xffffff);
         Navigation(' Opt. Extensions ','Optional_Tours.py',491,0xffffff);
         Navigation(' Testimonials ','Testimonials.py',625,0xffffff);
         Navigation(' About Us ','About_Us.py',735,0xffffff);
         Navigation(' Contact Us ','Contact_Us.py',818,0xffffff);
         Navigation(' Articles ','Articles.py',915,0x999999);
         /*
         var navMovieClip:Sprite = new Sprite();
         addChild(navMovieClip);
         var myNavigation:TextField = new TextField();
         var format:TextFormat = new TextFormat();
         format.font = 'Century Schoolbook';
         format.size = 15;
         myNavigation.text = "Mary had a little lamb.";
         myNavigation.textColor = 0xffffff;
         myNavigation.autoSize = TextFieldAutoSize.LEFT;
         myNavigation.setTextFormat(format);
         navMovieClip.addChild(myNavigation);
         navMovieClip.x = 200;
         navMovieClip.y = 200;
         */
      }
      
      override public function transitionOut():void
      {
         super.transitionOut();
         TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
         Gaia.api.removeAfterGoto(OnAfterGoto);
      }
   }
}

TIA,
Steve
Logged
Steve Jenkins
Gaia User
**
Posts: 17


« Reply #1 on: August 04, 2011, 01:59:22 PM »

By way of clarification, specifically the nav widgets show up and act like nav widgets in that the cursor turns to a hand onMouseOver; however, nothing happens when clicked. I assume the problem is in this code:

case "Testimonials":
               testimonialsButton.branch = Pages.TESTIMONIALS;
               navMovieClip.addChild(testimonialsButton);
               break;

which I got from an online tutorial. (navMovieClip is poorly named since it's actually a Sprite.)
TIA,
Steve
Logged
Steve Jenkins
Gaia User
**
Posts: 17


« Reply #2 on: August 04, 2011, 04:26:11 PM »

Never mind. I found the mistake.
Steve
Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc