Pages: [1]
  Print  
Author Topic: Help with AS3 Nav!  (Read 204 times)
NPR721
Gaia Novice
*
Posts: 2


« on: August 29, 2011, 12:42:03 PM »

Hi guys, I'm new with Gaia and I have to say that it's really amazing. Smiley

I've been with this project for some time now and I got stuck making the Navigation Buttons work.

There are 6 buttons (Movie Clips) on the stage of my nav.fla and the code in the .as file works just fine.

Now, whenever I want to put another Movie Clip (for a sub-section of the site) in the "_over" state any of the buttons, I can't seem to make it work. I've assigned the sub-button an instance name and declared it in the .as too, but it just doesn't work (not even the _over state). Is it because the movieclip is inside another movieclip?
...It's kinda hard to explain if you are not currently working on the project... can I upload it here so you guys can see it better?

Here's my Nav page code. As it is now, it works fine:

Code:
package pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import gs.*;

public class NavPage extends AbstractPage
{
private var buttons:Array;
public var BTN_Contacto:MovieClip;
public var BTN_Obras:MovieClip;
public var BTN_Equipo:MovieClip;
public var BTN_Areas:MovieClip;
public var BTN_Enfermedades:MovieClip;
public var BTN_Institucional:MovieClip;

public function NavPage()
{
super();
alpha = 0;
new Scaffold(this);
initButtons();
}
public function initButtons():void
{
BTN_Contacto.branch = "index/nav/home";
BTN_Obras.branch = "index/nav/obras";
BTN_Equipo.branch = "index/nav/equipo/endocrinologia";
BTN_Areas.branch = "index/nav/areas/especialidades";
BTN_Enfermedades.branch = "index/nav/enfermedades/myn";
BTN_Institucional.branch = "index/nav/institucional/historia";
buttons = [BTN_Contacto,BTN_Obras,BTN_Equipo,BTN_Areas,BTN_Enfermedades,BTN_Institucional];
var i:int = buttons.length;
while (i--)
{
buttons[i].buttonMode = true;
buttons[i].mouseChildren = false;
buttons[i].addEventListener(MouseEvent.CLICK, onClick);
}
Gaia.api.afterGoto(onAfterGoto);
updateButtonStates(Gaia.api.getCurrentBranch());
}
private function onClick(event:MouseEvent):void
{
Gaia.api.goto(MovieClip(event.target).branch);
}
private function onAfterGoto(event:GaiaEvent):void
{
updateButtonStates(event.validBranch);
}
private function updateButtonStates(branch:String):void
{
var i:int = buttons.length;
while (i--)
{
var btn:MovieClip = buttons[i];
if (branch != btn.branch)
{
btn.gotoAndStop("_up");
btn.enabled = true;
}
else
{
btn.gotoAndStop("selected");
btn.enabled = false;
}
}
}
override public function transitionIn():void
{
super.transitionIn();
TweenLite.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}
override public function transitionOut():void
{
super.transitionOut();
TweenLite.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}

I left an attachment so you guys can see what I want to do.

Can't upload the whole thing in .zip here 'cause the max file size is 500KB... otherwise, could I upload it to mediafire and leave a link? Or is it against the rules of the forum?

Anyway, I really hope you guys can help me out!

Thank you all!
Logged
NPR721
Gaia Novice
*
Posts: 2


« Reply #1 on: August 29, 2011, 02:01:18 PM »

I've been reading the forum for similar problems for a while.

Perhaps I have to declare it in another way in the nav page? (I'm not quite a programmer)

Like

public var BTN_Historia:MovieClip.addChild(); or something like that?

I'm really stressed Undecided

Thanks guys
Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc