Pages: [1]
  Print  
Author Topic: Working with assets?  (Read 598 times)
naturewalker
Gaia User
**
Posts: 11



« on: March 03, 2010, 11:54:48 AM »

I'm using .swf files as assets on some of the pages of my site. I've added one to the Nav page and it is working fine.
Using the same methods, I've added a asset to my Calendar page and am having the following problem.

site.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<site title="Puttn' Around Site: %PAGE%" menu="true">
    <page id="index" src="index.swf">
        <page id="nav" src="nav.swf" depth="top">
<asset id="weather" src="weather2.swf"/>
            <page id="home" title="Home" src="home.swf" menu="true" />
<page id="location" title="Location | Directions" src="location.swf" menu="true" />
<page id="hours" title="Hours | Admission" src="hours.swf" menu="true" />
<page id="groups" title="Groups | Parties" src="groups.swf" menu="true" />
<page id="calendar" title="Calendar of Events" src="calendar.swf" menu="true" />
<asset id="events" src="EventsCalendar.swf"/>
<page id="daily" title="Daily Specials" src="daily.swf" menu="true" />
<page id="contact" title="Contact Us" src="contact.swf" menu="true" />
<page id="photo" title="Photo Gallery" src="photo.swf" menu="true" />
<page id="everglades" title="Everglades Course" src="everglades.swf" menu="true" />
<page id="ocean" title="Ocean Course" src="ocean.swf" menu="true" />
        </page>
    </page>
</site>

NavPage.as
Code:
package com.puttnaround.website.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 com.greensock.TweenMax;

public class NavPage extends AbstractPage
{
private var buttons:Array;
public var BTN_Home:MovieClip;
public var BTN_Location:MovieClip;
public var BTN_Hours:MovieClip;
public var BTN_Groups:MovieClip;
public var BTN_Calendar:MovieClip;
public var BTN_Daily:MovieClip;
public var BTN_Contact:MovieClip;
public var toggleButton:MovieClip;
public var bird_mc,BTN_Photo,BTN_Everglades,BTN_Ocean:MovieClip;

public function NavPage()
{
super();
alpha = 0;
initButtons();
toggleButton.addEventListener(MouseEvent.MOUSE_OVER, rolloverToggle);
toggleButton.addEventListener(MouseEvent.MOUSE_OUT, rolloutToggle);
toggleButton.addEventListener(MouseEvent.CLICK, toggleClick);
toggleButton.buttonState = "on";

}

// Weather Button

function rolloverToggle(event:MouseEvent) {
toggleButton.gotoAndStop(toggleButton.buttonState+" over");
}

function rolloutToggle(event:MouseEvent) {
toggleButton.gotoAndStop(toggleButton.buttonState);
}
function toggleClick(event:MouseEvent) {
if (toggleButton.buttonState == "on") {
toggleButton.buttonState = "off";
TweenMax.to(assets.weather, 1, {alpha:1});
} else {
toggleButton.buttonState = "on";
TweenMax.to(assets.weather, 0, {alpha:0});
}
toggleButton.gotoAndStop(toggleButton.buttonState+" over");
}

// end weather widget

public function initButtons():void
{
BTN_Home.branch = "index/nav/home";
BTN_Location.branch = "index/nav/location";
BTN_Hours.branch = "index/nav/hours";
BTN_Groups.branch = "index/nav/groups";
BTN_Calendar.branch = "index/nav/calendar";
BTN_Daily.branch = "index/nav/daily";
BTN_Contact.branch = "index/nav/contact";
bird_mc.BTN_Photo.branch = "index/nav/photo";
bird_mc.BTN_Everglades.branch = "index/nav/everglades";
bird_mc.BTN_Ocean.branch = "index/nav/ocean";
buttons = [BTN_Home, BTN_Location, BTN_Hours, BTN_Groups, BTN_Calendar, BTN_Daily, BTN_Contact, bird_mc.BTN_Photo, bird_mc.BTN_Everglades, bird_mc.BTN_Ocean];
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();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
TweenMax.to(bird_mc, 2, {x:739.55});
assets.weather.visible = true;
TweenMax.to(assets.weather, 0, {alpha:0});
assets.weather.x = 829.95;
assets.weather.y = 0;
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}

CalendarPage.as
Code:
package com.puttnaround.website.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 com.greensock.TweenMax;

public class CalendarPage extends AbstractPage
{
public var eventsCalendar:MovieClip;
public function CalendarPage()
{
super();
alpha = 0;
}
override public function transitionIn():void
{
super.transitionIn();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
assets.events.visible = true;
assets.events.x = 203;
assets.events.y = 0;
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}

When I test the project and navigate to calendar, I get the following error;
Code:
Gaia Framework (AS3) v3.2.0
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.puttnaround.website.pages::CalendarPage/transitionIn()
at com.gaiaframework.assets::PageAsset/transitionIn()
at com.gaiaframework.core::TransitionController/pageIn()
at com.gaiaframework.core::TransitionController/onTransitionInComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.gaiaframework.assets::PageAsset/onTransitionInComplete()
at com.gaiaframework.assets::PageAsset/transitionIn()
at com.gaiaframework.core::TransitionController/pageIn()
at com.gaiaframework.core::TransitionController/onTransitionInComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.gaiaframework.assets::PageAsset/onTransitionInComplete()
at com.gaiaframework.assets::PageAsset/transitionIn()
at com.gaiaframework.core::TransitionController/pageIn()
at com.gaiaframework.core::TransitionController/transitionIn()
at com.gaiaframework.core::SiteController/onTransitionIn()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.gaiaframework.core::GaiaHQ/beforeTransitionInDone()
at com.gaiaframework.core::GaiaHQ/onEvent()
at com.gaiaframework.core::GaiaHQ/beforeTransitionIn()
at com.gaiaframework.flow::FlowManager$/transitionIn()
at com.gaiaframework.flow::NormalFlow$/afterPreloadDone()
at com.gaiaframework.flow::FlowManager$/afterPreloadDone()
at com.gaiaframework.core::GaiaHQ/afterPreloadDone()
at com.gaiaframework.core::GaiaHQ/onEvent()
at com.gaiaframework.core::GaiaHQ/afterPreload()
at com.gaiaframework.flow::FlowManager$/preloadComplete()
at com.gaiaframework.core::SiteController/preloaderEnterFrame()
Logged

naturewalker
steven
Gaia Author
Administrator
Gaia Evangelist
*****
Posts: 3863


gaiaframework
WWW
« Reply #1 on: March 03, 2010, 11:59:12 AM »

A common oversight.  You closed the calendar page so the asset doesn't belong to it, it belongs to the parent of calendar.  Open your xml in Firefox and you will see what I mean.  Smiley
Logged

Steven Sacks | Gaia Author
Please support Gaia by donating to the project!  Smiley
naturewalker
Gaia User
**
Posts: 11



« Reply #2 on: March 03, 2010, 12:49:54 PM »

That took me a minute to compute, I see my mistake.
Thank you Steven.  Cheesy
Logged

naturewalker
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc