I am making my first site in AS3 and am working on the onResize event. My problem is, my preloader frame has an onResize event and my main frame has an onResize event.
preload:
stage.addEventListener(Event.RESIZE, arrangeStage);
function arrangeStage(e:Event):void
{
lbar.x = 0;
var middleY = stage.stageHeight/2;
TweenLite.to(lpc,1.5,{y:middleY,ease:Exponential.easeOut});
TweenLite.to(lbar,1.5,{y:middleY,ease:Exponential.easeOut});
}
main frame:
it has nothing right now, but when it gets to this frame I get this error when I resize:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at sitetemplate_fla::MainTimeline/arrangeStage()
I read one of senoculars post (#352) on this page http://www.kirupa.com/forum/showthread.php?p=2112820
and it says to define a function like so:
ActionScript Code:
[LEFT][COLOR=#808080]// Frame 1[/COLOR]
[COLOR=#808080]// declare class variable[/COLOR]
[COLOR=#000000]var[/COLOR] myFunction:[COLOR=#000000]Function[/COLOR];
[COLOR=#808080]// first definiton[/COLOR]
myFunction = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000FF]void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#808080]// code…[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]// Frame 2[/COLOR]
[COLOR=#808080]// second definition[/COLOR]
myFunction = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000FF]void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#808080]// different code…[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
well I tried it exactly how it says there and I get these errors:
TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at flash.display::Stage/addEventListener()
at sitetemplate_fla::MainTimeline/sitetemplate_fla::frame1()
and it looks like this:
ActionScript Code:
[LEFT][COLOR=#000000]var[/COLOR] arrangeStage:[COLOR=#000000]Function[/COLOR];
arrangeStage = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000FF]void[/COLOR]
[COLOR=#000000]{[/COLOR]
lbar.[COLOR=#000080]x[/COLOR] = [COLOR=#000080]0[/COLOR];
[COLOR=#000000]var[/COLOR] middleY = [COLOR=#0000FF]stage[/COLOR].[COLOR=#000080]stageHeight[/COLOR]/[COLOR=#000080]2[/COLOR];
TweenLite.[COLOR=#000080]to[/COLOR]COLOR=#000000[/COLOR];
TweenLite.[COLOR=#000080]to[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
any idea??