Jump to content
Search Community

null objekt with timeline now in cs5

spica2 test
Moderator Tag

Recommended Posts

have a problem with a script that was running in cs4, but now in cs5 I get errors.

 

I am fading in objekts by timelines after framejumps

 

eg. frame 0

stop();
mybtnLeiste1.mybtnPT1.addEventListener(MouseEvent.CLICK , function (event: MouseEvent): void {timeline.reverse()});

var timeline:TimelineMax = new TimelineMax({onComplete:function ():void {timeline.pause();}, onReverseComplete:function ():void {gotoAndStop(10)}});
timeline.appendMultiple(TweenMax.allFrom([
										  mybtnLeiste1,
										  myBild1, 
										  myAktualisieren, 
										  myteaser1, 
										  myteaser2, 
										  myteaser3
										  ], 0.8, {autoAlpha:0}, 0.1));

 

and frame 10

mybtnLeiste2.mybtnPT1_2.addEventListener(MouseEvent.CLICK , function (event: MouseEvent): void { timeline2.reverse()}); 

var timeline2:TimelineMax = new TimelineMax({onComplete:function ():void {timeline2.pause();}, onReverseComplete:function ():void {gotoAndStop(0)}});
timeline2.appendMultiple(TweenMax.allFrom([
										  mybtnLeiste2,
										  myUhr1, 
										  myUhr2, 
										  myUhr3, 
										  myUhr4, 
										  myUhr5
										  ], 0.8, {autoAlpha:0}, 0.1));

 

Jumping by the button on frame 0 to frame 10 works. But jumping back from frame 10 to frame 0 gives an error

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at code::pr/frame1()[code.pr::frame1:2]

at flash.display::MovieClip/gotoAndStop()

at Function/()[code.pr::frame10:5]

at Function/http://adobe.com/AS3/2006/builtin::apply()

at com.greensock.core::TweenCore/complete()[/users/Test/v2/com/greensock/core/TweenCore.as]

at com.greensock::TimelineMax/complete()[/users/Test/v2/com/greensock/TimelineMax.as]

at com.greensock::TimelineMax/renderTime()[/users/Test/v2/com/greensock/TimelineMax.as]

at com.greensock.core::SimpleTimeline/renderTime()[/users/Test/v2/com/greensock/core/SimpleTimeline.as]

at com.greensock::TweenLite$/updateAll()[/users/Test/v2/com/greensock/TweenLite.as]

 

cant figure out a solution. Any help? (Still wondering why its was working in cs4)

Link to comment
Share on other sites

i built a similar yet simplified file that works in cs5 with no errors:

 

frame 1


import com.greensock.*;

mc1.addEventListener(MouseEvent.CLICK, function(e:Event):void{trace("hello"); timeline.reverse()})
stop();

var timeline:TimelineMax = new TimelineMax({onComplete:function ():void {timeline.pause();}, onReverseComplete:function ():void {gotoAndStop(10)}});
  timeline.append(TweenMax.to(mc1, 1, {scaleX:1.5}));

 

 

frame 10


mc2.addEventListener(MouseEvent.CLICK, function(e:Event):void{trace("goodbye"); timeline2.reverse()})
stop();

var timeline2:TimelineMax = new TimelineMax({onComplete:function ():void {timeline2.pause();}, onReverseComplete:function ():void {gotoAndStop(1)}});
timeline2.append(TweenMax.to(mc2, 1.5, {scaleX:1.5}));

 

 

i thought maybe the gotoAndStop(0) or all the anonymous functions could have been the problem, but it works.

see attached and test.

 

if you want to provide your file i'll take a look at it

Link to comment
Share on other sites

thanx carl, for your test. enclosed you will finde my fla.

 

the strange thing about it is, when I export it for player 10 it works fine. But I need it as air. CS5 exports air 2, cs4 air 1.5. as an air project the error is the same. have no explantion for it.

Link to comment
Share on other sites

wow, this was a real head scratcher.

 

i figured out the problem, but I don't have a full solution. nor do I know why air2 handles it different than FP10.

 

Here's the deal.

 

notice how in your timeline in the Startseite layer, the frames for that layer end at frame 3?

I understand you don't want that stuff showing up on frame 10, but once the playhead jumps past frame 3, all the stuff in frame1 gets removed.

when you gotoAndStop(1) after timeline2 plays... none of that stuff is "there" thus the null object errors.

 

if you extend the frames in layer StartSeite out to frame 10 (click on frame 10 in startseite layer and press f5) and test, the app will jump back to frame1 when you press the button after the second timeline runs.

There will not be any errors.

 

BUT the animation doesn't appear to play because your timeline has tweens with allFrom alpha of 0 and the movieclips have already had their alphas set to 0 the first time the timeline played. make sense?

 

--------

 

if is necessary to get this working in air2 I think the only solution is to

-keep all your assets and code on frame 1

-adjust your script so that all the timeline2 assets are invisible until timeline2 is told to play

-timeline2 starts out with {paused:true}

 

instead of having gotoAndStop(1) or gotoAndStop(10) as you onReverseComplete functions. you will have

 

var timeline:TimelineMax = new TimelineMax({onComplete:function ():void {timeline.pause();}, onReverseComplete:timeline2.restart}});

var timeline2:TimelineMax = new TimelineMax({paused:true, onComplete:function ():void {timeline.pause();}, onReverseComplete:timeline.restart}});

 

-------

 

hope this helps

 

carl

Link to comment
Share on other sites

hi carl,

 

thanx for your help.

I will test your suggestion, I first have to review the whole file whichs timeline is much more komplex, so I am not shure, if your suggestion will fit.

 

Meanwhile I found similar results. As far as I can see, only the btn instance is removed from stage after the second run. You can see this in this file eclosed. But I have no explanation, why its taken from the display list.

 

What realy irritates me is, that building the file new from scratch, its working. The file, that I am working with was a CS4 file now opened in CS5. Can there be unvisible code somewhere caused by the import? e.g. Copy pasting the timeline in a new file ist working (but as I mentioned I cant do it with the whole project, that is more complex). I also would like to test to export it as Air 1.5, but cs5 does not offer this. Any ideas on that are welcome. I will give feedback on my further tries.

Link to comment
Share on other sites

bingo

 

to display tlf a additional recource (textLayout_X.X.X.XXX.swz, I alwayse wondered where this came from in the file directory after previewing) is loaded from the adobe webserver each time you start the file. This causes the crossover warning and the crash because compiled for air this is prohibited. You must compile the recource directly in the airfile.

 

See this (german):

http://help.adobe.com/de_DE/flash/cs/us ... 5aa72-8000

 

well, this was an annoying puzzle – in the end it is just a few clicks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...