Hi all,
I have a question about AS3. I’m new to coding/scripting/AS3/Flash, so I’m sure that I am making some rookie mistakes. I really need some guidance. Thanks, I really appreciate the help!
Ok,
I keep getting the following error (I only get the error when I use the if() conditional. If I remove it the code runs fine. But I need the functions to run only under certain conditions) :
TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at Buttons_mc1test()
at level_rizon_fla::Page1_1/frame1()
This is my code:
package {
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.events.MouseEvent;
import fl.containers.UILoader;
import flash.events.Event;
import flash.net.URLRequest;
public class Buttons_mc1test extends MovieClip {
public function Buttons_mc1test(buttonUp:MovieClip, buttonDown:MovieClip, photo_btns:MovieClip, band_bg:MovieClip, pageLoad:UILoader, pageLocation:String) {
/////////////----------------Variables---------------------------------///////////////
var headBtnDown:Tween=new Tween(buttonUp,"alpha",None.easeOut,1,1,5,false);
var buttonsOutx:Tween=new Tween(photo_btns,"scaleX",None.easeNone,1,1,20,false);
var buttonsOuty:Tween=new Tween(photo_btns,"scaleY",None.easeNone,1,1,20,false);
var buttonsOuta:Tween=new Tween(photo_btns,"alpha",None.easeNone,1,1,20,false);
var pageBackGround:Tween=new Tween(band_bg,"height",None.easeNone,188,188,30,false);
var pageBackGroundy:Tween=new Tween(band_bg,"y",None.easeNone,528,528,30,false);
var loadPageTween:Tween=new Tween(pageLoad,"alpha",None.easeOut,0,0,20,false);
var headBtnOver:Tween=new Tween(buttonDown,"alpha",None.easeOut,0,0,15,false);
var isPageLoaded:Boolean=false;
/////////////----------------Global Event Listenters--------------------------///////////////
buttonUp.addEventListener(MouseEvent.MOUSE_OVER, headerOver);
buttonUp.addEventListener(MouseEvent.MOUSE_OUT, headerOut);
pageLoad.addEventListener(Event.COMPLETE, exitPages);
/////////////----------------Functions---------------------------------///////////////
function exitPages(event:Event):void {
isPageLoaded=true;
}
////////////-------------if no page is not loaded--------------------///////////////////
if (isPageLoaded==false) {
function headerOut(e:MouseEvent):void {
headBtnOver.stop();
headBtnOver.continueTo(0,10);
}
function headerOver(e:MouseEvent):void {
headBtnOver.stop();
headBtnOver.continueTo(1, 15);
buttonUp.addEventListener(MouseEvent.CLICK, headerDown);
}
function headerDown(e:MouseEvent):void {
buttonUp.removeEventListener(MouseEvent.MOUSE_OUT, headerOut);
buttonUp.removeEventListener(MouseEvent.MOUSE_OVER, headerOver);
headBtnDown.stop();
buttonsOutx.stop();
buttonsOuty.stop();
buttonsOuta.stop();
pageBackGround.stop();
pageBackGroundy.stop();
headBtnDown.continueTo(0,5);
buttonsOutx.continueTo(3,20);
buttonsOuty.continueTo(3,20);
buttonsOuta.continueTo(0,20);
pageBackGround.continueTo(300,30);
pageBackGroundy.continueTo(102,30);
loadPageTween.stop();
loadPageTween.continueTo(1,30);
pageLoad.load(new URLRequest(pageLocation));
buttonUp.removeEventListener(MouseEvent.CLICK, headerDown);
buttonUp.addEventListener(MouseEvent.CLICK, pageExit);
}
function pageExit(e:MouseEvent) {
loadPageTween.stop();
loadPageTween.continueTo(0,30);
loadPageTween.addEventListener(TweenEvent.MOTION_FINISH, unloadPage);
buttonUp.addEventListener(MouseEvent.CLICK, headerDown);
buttonUp.addEventListener(MouseEvent.MOUSE_OUT, headerOut);
buttonUp.addEventListener(MouseEvent.MOUSE_OVER, headerOver);
headBtnDown.stop();
headBtnDown.continueTo(1,5);
buttonsOutx.stop();
buttonsOuty.stop();
buttonsOuta.stop();
pageBackGround.stop();
pageBackGroundy.stop();
buttonsOutx.continueTo(1,20);
buttonsOuty.continueTo(1,20);
buttonsOuta.continueTo(1,20);
pageBackGround.continueTo(188,30);
pageBackGroundy.continueTo(528,30);
buttonUp.removeEventListener(MouseEvent.CLICK, pageExit);
}
function unloadPage(e:TweenEvent) {
pageLoad.unload();
loadPageTween.removeEventListener(TweenEvent.MOTION_FINISH,unloadPage);
}
} else {
}
}
}
}