Marta H.

Marta H. Fotograf/Grafik
komputerowy/Webmaste
r

Temat: Problem z kodem flash ( AS3). Proszę o pomoc.

Witam. Czy ktoś może mi pomóc i powiedzieć dlaczego menu działa
mi w pustym pliku fla.,a w pliku ze stroną już nie, i wyskakuje
błąd, że nie można uzyskać dostępu do właściwości lub
metody dla odniesienia do obiektu null.
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

import caurina.transitions.*;
import caurina.transitions.properties.ColorShortcuts;
ColorShortcuts.init();

var off:Object;

addButtons();

function addButtons():void
{

var names:Array = new Array("O MNIE","PORTFOLIO","KONTAKT");

for (var i:int = 0; i < 4; i++)
{

var myButton:MyButton = new MyButton();
myButton.txt.tf.text = names[i];
myButton.name = "b" + i;
myButton.buttonMode = true;

myButton.mouseChildren = false;

myButton.addEventListener(MouseEvent.ROLL_OUT, bOut);
myButton.addEventListener(MouseEvent.ROLL_OVER, bOver);
myButton.addEventListener(MouseEvent.CLICK, bClick);

myButton.x = 730.55 + (myButton.width * i);
myButton.y = 374.35;

this.addChild(myButton);
}
}

function bOver(e:MouseEvent):void
{

Tweener.addTween(e.target.bg, { y:0, _color:0x99A0A8, alpha:1,
time:1, transition:"easeOutExpo" } );

Tweener.addTween(e.target.txt, { y:32.2, _color:0x000000, alpha:1,
time:0.0, transition:"linear" } );
}
function bOut(e:MouseEvent):void
{

Tweener.addTween(e.target.bg, { y:-90, _color:0x0000000,
alpha:0.75, time:1, transition:"easeOutExpo" } );

Tweener.addTween(e.target.txt, { y:32.2, _color:0xFFFFFF, alpha:1,
time:0.0, transition:"linear" } );
}
function bClick(e:MouseEvent):void
{
for (var i:int = 0; i < this.numChildren; i++)
{
(this.getChildAt(i) as MyButton).x = 730.55 + (132 * i);
(this.getChildAt(i) as MyButton).y = 5.35;
}

if (off != null)
{

off.buttonMode = true;
off.addEventListener(MouseEvent.ROLL_OUT, bOut);
off.addEventListener(MouseEvent.ROLL_OVER, bOver);
off.addEventListener(MouseEvent.CLICK, bClick);
off.dispatchEvent(new MouseEvent(MouseEvent.ROLL_OUT));
}

e.target.buttonMode = false;
e.target.removeEventListener(MouseEvent.ROLL_OUT, bOut);
e.target.removeEventListener(MouseEvent.ROLL_OVER, bOver);
e.target.removeEventListener(MouseEvent.CLICK, bClick);
off = e.target;

switch (e.target.name)
{
case "b1" :
trace;
break;
case "b2" :
trace;
break;
default :
trace;
break;
}

}