PDA

Volledige versie bekijken : foutmelding na muisklik


JPKO
%Europe/Berlin %715 %2010, 17:10
Na een mouse event CLICK krijg ik de volgende melding
.......
knop doet t
TypeError: Error #1009: Kan geen eigenschap of methode benaderen via een verwijzing naar een object dat null is.
at 2010nr2_fla::MainTimeline/loop()
.......

Zo je ziet doet de trace functie het maar de melding dat er verwezen wordt naar een NULL object begrijp ik niet want het commando is dat er in dezelfde scene naar frame 1 met label "frame1" moet worden teruggegaan.

Wat kan ik doen om de foutmelding weg te krijgen.

Alvast dank voor de respons
JPKO

De code:
trg.addEventListener(MouseEvent.CLICK, trg_CLICK);

function trg_CLICK(e:MouseEvent):void
{
trace("knop doet t");
this.gotoAndPlay("frame1");
}

reapertjuh
%Europe/Berlin %761 %2010, 18:16
ik zie niets wat fout is, Heb je nog meer actionscript in dat project staan? bijvoorbeeld in frame1

JPKO
%Europe/Berlin %767 %2010, 18:25
ja om afbeelding zichtbaar te maken bij mouse over

BTW het werkt wel maar na de actie verschijnt bovengenoemde melding in het uitvoer-veld en dat blijft maar doorgaan (repeterend zeg maar) totdat de SWF-player is afgesloten.


import fl.motion.MotionEvent;
/* import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
*/

this.stop();




strt.addEventListener(MouseEvent.CLICK, strt_CLICK);

function strt_CLICK(e:MouseEvent):void
{
this.gotoAndPlay("starten");
}


hier.addEventListener(MouseEvent.ROLL_OVER, hier_ROLLOVER);
hier.addEventListener(MouseEvent.ROLL_OUT, hier_ROLLOUT);
format.alpha=0;

function hier_ROLLOVER(e:MouseEvent):void
{
format.alpha = 1;
}
function hier_ROLLOUT(e:MouseEvent):void
{
format.alpha = 0;
}

hier2.addEventListener(MouseEvent.ROLL_OVER, hier2_ROLLOVER);
hier2.addEventListener(MouseEvent.ROLL_OUT, hier2_ROLLOUT);
resolutie.alpha=0;

function hier2_ROLLOVER(e:MouseEvent):void
{
resolutie.alpha = 1;
}
function hier2_ROLLOUT(e:MouseEvent):void
{
resolutie.alpha = 0;
}

PageMaker
%Europe/Berlin %859 %2010, 20:37
Heb je dat label "starten" gedefinieerd?

JPKO
%Europe/Berlin %884 %2010, 21:13
jazeker maar deze knop doet het gewoon. deze geeft een commando om vooruit te gaan in de tijdlijn.
Maar het probleem is de knop die aan het eind van de tijdlijn staat en het commando geeft om terug te gaan naar het begin van de tijdlijn. Als die gebruikt wordt dan krijg je foutmelding.

Aanvulling......

Vele mogelijkheden geprobeerd zoals trace / getURL enz. Deze werken allemaal maar als ik de functies gotoAndPlay of gotoAndStop laat uitvoeren dan komt de foutmelding.

Nog een aanvulling.......

Heb geconstateerd dat alles het doet totdat er een ander stuk script wordt aangeroepen. Dit ziet er als volgt uit:


addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void {

if (about.scaleX>=1) {
about.addChild(about.theInfo);
} else {

about.addChild(about.theImage);
}



}

}

Als dit stuk script wordt "geblokd" dan doet alles het goed. Maar dan mis ik een stuk noodzakelijke interactie in de movie

e.l.dam
%Europe/Berlin %992 %2010, 23:49
Hrrm... je doet about.addChild(about.theInfo)... ?

je wil dus een child van about, namelijk theInfo, toevoegen aan about?

Ik weet niet wat theInfo is, maar:

als het een class is, doe dan eerst:

var info = new theInfo();
about.addChild(info);

als het een mc is binnen about, die je wilt laten zien, doe (als die mc dus een instance naam 'theInfo' heeft)

about.theInfo.visible = true;
about.theImage.visible = false;

JPKO
%Europe/Berlin %000 %2010, 00:00
Er staan 4 mc's op de tijdlijn. Elk bevat een image(theImage) en een FLVplayback (theInfo)

In eerste instantie zie je alleen het plaatje. Deze hebben een button functie en als je erop klikt dan vervaagd de image en komt de player naar voren.

Kijk anders even op
http://www.jpkdesign.nl/animatie.html

De code die voor dit deel gebruikt wordt is als volgt:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import fl.motion.MotionEvent;

var aboutX=about.x;
var aboutY=about.y;
var aboutScaleX=about.scaleX;
var aboutScaleY=about.scaleY;
var aboutRotation=about.rotation;

about.theImage.buttonMode=true;

about.theImage.addEventListener(MouseEvent.CLICK, aboutOver);
function aboutOver(e:Event):void {
addChild(about);

new Tween(about,"scaleX",Regular.easeInOut,aboutScaleX,1,1,true);
new Tween(about,"scaleY",Regular.easeInOut,aboutScaleY,1,1,true);

new Tween(about,"rotation",Regular.easeInOut,aboutRotation,0,1,true);

new Tween(about,"x",Regular.easeInOut,aboutX,stage.stageWidth/2,1,true);
new Tween(about,"y",Regular.easeInOut,aboutY,stage.stageHeight/2,1,true);

new Tween(about,"rotationY",Regular.easeInOut,about.rotationY,180,0,true);
new Tween(about,"rotationX",Regular.easeInOut,about.rotationX,180,0,true);
new Tween(about.theImage,"alpha",Regular.easeOut,about.theImage.alpha,0,1,true);
}

about.theInfo.spin.addEventListener(MouseEvent.CLI CK, aboutBack);
function aboutBack(e:Event):void {

new Tween(about,"scaleX",Regular.easeInOut,about.scaleX,aboutScaleX,1,true );
new Tween(about,"scaleY",Regular.easeInOut,about.scaleY,aboutScaleY,1,true );

new Tween(about,"rotation",Regular.easeInOut,about.rotation,aboutRotation,0, true);

new Tween(about,"x",Regular.easeInOut,about.x,aboutX,1,true);
new Tween(about,"y",Regular.easeInOut,about.y,aboutY,1,true);

new Tween(about,"rotationY",Regular.easeInOut,about.rotationY,360,0,true);
new Tween(about,"rotationX",Regular.easeInOut,about.rotationX,360,0,true);
new Tween(about.theImage,"alpha",Regular.easeIn,about.theImage.alpha,1,1,true);
}



addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void {

if (about.scaleX>=1) {
about.addChild(about.theInfo);
} else {

about.addChild(about.theImage);
}


if (port.scaleX>=1) {
port.addChild(port.theInfo);
} else {

port.addChild(port.theImage);
}

if (logo.scaleX>=1) {
logo.addChild(logo.theInfo);
} else {

logo.addChild(logo.theImage);
}


if (valentijn.scaleX>=1) {
valentijn.addChild(valentijn.theInfo);
} else {

valentijn.addChild(valentijn.theImage);
}

}


var portX=port.x;
var portY=port.y;
var portScaleX=port.scaleX;
var portScaleY=port.scaleY;
var portRotation=port.rotation;


port.theImage.buttonMode=true;

port.theImage.addEventListener(MouseEvent.CLICK, portOver);
function portOver(e:Event):void {
addChild(port);

new Tween(port,"scaleX",Regular.easeInOut,portScaleX,1,1,true);
new Tween(port,"scaleY",Regular.easeInOut,portScaleY,1,1,true);

new Tween(port,"rotation",Regular.easeInOut,portRotation,0,1,true);

new Tween(port,"x",Regular.easeInOut,portX,stage.stageWidth/2,1,true);
new Tween(port,"y",Regular.easeInOut,portY,stage.stageHeight/2,1,true);

new Tween(port,"rotationY",Regular.easeInOut,port.rotationY,180,0,true);
new Tween(port,"rotationX",Regular.easeInOut,port.rotationX,180,0,true);
new Tween(port.theImage,"alpha",Regular.easeOut,port.theImage.alpha,0,1,true);
}

port.theInfo.spin.addEventListener(MouseEvent.CLIC K, portBack);
function portBack(e:Event):void {

new Tween(port,"scaleX",Regular.easeInOut,port.scaleX,portScaleX,1,true);
new Tween(port,"scaleY",Regular.easeInOut,port.scaleY,portScaleY,1,true);
//rotate back
new Tween(port,"rotation",Regular.easeInOut,port.rotation,portRotation,1,tr ue);
//move back
new Tween(port,"x",Regular.easeInOut,port.x,portX,1,true);
new Tween(port,"y",Regular.easeInOut,port.y,portY,1,true);
//3D back
new Tween(port,"rotationY",Regular.easeInOut,port.rotationY,360,0,true);
new Tween(port,"rotationX",Regular.easeInOut,port.rotationX,360,0,true);
new Tween(port.theImage,"alpha",Regular.easeIn,port.theImage.alpha,1,1,true);
}


var logoX=logo.x;
var logoY=logo.y;
var logoScaleX=logo.scaleX;
var logoScaleY=logo.scaleY;
var logoRotation=logo.rotation;

logo.theImage.buttonMode=true;

logo.theImage.addEventListener(MouseEvent.CLICK, logoOver);
function logoOver(e:Event):void {
addChild(logo);

new Tween(logo,"scaleX",Regular.easeInOut,logoScaleX,1,1,true);
new Tween(logo,"scaleY",Regular.easeInOut,logoScaleY,1,1,true);

new Tween(logo,"rotation",Regular.easeInOut,logoRotation,0,1,true);

new Tween(logo,"x",Regular.easeInOut,logoX,stage.stageWidth/2,1,true);
new Tween(logo,"y",Regular.easeInOut,logoY,stage.stageHeight/2,1,true);
//3D around
new Tween(logo,"rotationY",Regular.easeInOut,logo.rotationY,180,0,true);
new Tween(logo,"rotationX",Regular.easeInOut,logo.rotationX,180,0,true);
new Tween(logo.theImage,"alpha",Regular.easeOut,logo.theImage.alpha,0,1,true);
}

logo.theInfo.spin.addEventListener(MouseEvent.CLIC K, logoBack);
function logoBack(e:Event):void {

new Tween(logo,"scaleX",Regular.easeInOut,logo.scaleX,logoScaleX,1,true);
new Tween(logo,"scaleY",Regular.easeInOut,logo.scaleY,logoScaleY,1,true);

new Tween(logo,"rotation",Regular.easeInOut,logo.rotation,logoRotation,1,tr ue);

new Tween(logo,"x",Regular.easeInOut,logo.x,logoX,1,true);
new Tween(logo,"y",Regular.easeInOut,logo.y,logoY,1,true);

new Tween(logo,"rotationY",Regular.easeInOut,logo.rotationY,360,0,true);
new Tween(logo,"rotationX",Regular.easeInOut,logo.rotationX,360,0,true);
new Tween(logo.theImage,"alpha",Regular.easeIn,logo.theImage.alpha,1,1,true);
}



var valentijnX=valentijn.x;
var valentijnY=valentijn.y;
var valentijnScaleX=valentijn.scaleX;
var valentijnScaleY=valentijn.scaleY;
var valentijnRotation=valentijn.rotation;


valentijn.theImage.buttonMode=true;

valentijn.theImage.addEventListener(MouseEvent.CLI CK, valentijnOver);
function valentijnOver(e:Event):void {
addChild(valentijn);

new Tween(valentijn,"scaleX",Regular.easeInOut,valentijnScaleX,1,1,true);
new Tween(valentijn,"scaleY",Regular.easeInOut,valentijnScaleY,1,1,true);

new Tween(valentijn,"rotation",Regular.easeInOut,valentijnRotation,0,1,true);

new Tween(valentijn,"x",Regular.easeInOut,valentijnX,stage.stageWidth/2,1,true);
new Tween(valentijn,"y",Regular.easeInOut,valentijnY,stage.stageHeight/2,1,true);

new Tween(valentijn,"rotationY",Regular.easeInOut,valentijn.rotationY,180,0,true) ;
new Tween(valentijn,"rotationX",Regular.easeInOut,valentijn.rotationX,180,0,true) ;
new Tween(valentijn.theImage,"alpha",Regular.easeOut,valentijn.theImage.alpha,0,1,true );
}

valentijn.theInfo.spin.addEventListener(MouseEvent .CLICK, valentijnBack);
function valentijnBack(e:Event):void {

new Tween(valentijn,"scaleX",Regular.easeInOut,valentijn.scaleX,valentijnScale X,1,true);
new Tween(valentijn,"scaleY",Regular.easeInOut,valentijn.scaleY,valentijnScale Y,1,true);

new Tween(valentijn,"rotation",Regular.easeInOut,valentijn.rotation,valentijnRot ation,1,true);

new Tween(valentijn,"x",Regular.easeInOut,valentijn.x,valentijnX,1,true);
new Tween(valentijn,"y",Regular.easeInOut,valentijn.y,valentijnY,1,true);

new Tween(valentijn,"rotationY",Regular.easeInOut,valentijn.rotationY,360,0,true) ;
new Tween(valentijn,"rotationX",Regular.easeInOut,valentijn.rotationX,360,0,true) ;
new Tween(valentijn.theImage,"alpha",Regular.easeIn,valentijn.theImage.alpha,1,1,true) ;
}