Solved

Flash CS4 - AS3 Questoin about Scenes

Posted on 2010-11-14
2
619 Views
Last Modified: 2013-11-11
Greetings, all!

I have quite a bit of background in programming, but am very new to Flash.  I've been taking a flash course for about two months now, and we just started on AS3.  So for my latest project, I wanted to incorporate some AS3 into my Flash movie, but I think that I'm still not understanding exactly how it works, so if someone can explain what I'm doing wrong, I would appreciate it greatly.

Basically, what I have is a movie clip that contains two layers - one is a colored circle, the other is a rectangular image of mars.  The colored circle layer is above the layer containing the image of mars, and the colored circle layer is set as a mask layer.  I have it rotating over a specific number of frames, so when I drag this onto my stage in Scene 1 and play it, I get the illusion of Mars spinning.  Pretty nifty.

At any rate, I found and modified some AS3 on the internet to mimic "typewriter text" (where it types one letter at a time on the screen, rather than the entire contents of a textbox).  This effect is EXACTLY what I want....

But when I create a new scene, it get an error that states: "Cannot access a property or method of a null object reference."  So I'm very curious if I need to somehow revamp the AS3 to specify which scene it works in?

I've attached the ActionScript into a code snippet.

Also, I am attaching my .fla file as well, in case anyone feels the need to take a look at it.  It is not large at all.

My primary point that I'm trying to achieve, is to play Scene 1, which has Mars spinning in space with some green typewriter text, and after that is done I want to transition to Scene 2, which will be an animation of an astronaut inside of a space shuttle (still working on the art in photoshop for that one...).

However, as soon as I add a second scene to the project, that error shows up!  

Please help?


var str1:String = 'In the year 2009, the Mars Rover Discovered something that shattered humanity\'s view on their place in the cosmos forever...';

var i:uint = 0;

var timer:Timer = new Timer(100);

timer.start();

timer.addEventListener(TimerEvent.TIMER,gotime);

function gotime(e:TimerEvent) {
	
	textbox_txt.appendText(str1.charAt(i));
	i++;
	
	if(i>=str1.length) {
		timer.stop();
	}
}

Open in new window

Introduction.fla
0
Comment
Question by:ThatSharepointGuy
2 Comments
 
LVL 12

Accepted Solution

by:
scooby_56 earned 250 total points
ID: 34130643
Just add

stop()

At the top of your code in scene1 - this will prevent if jumping between scene1 and scene2 continuously.

In your code, to go to the next scene (add a click event or something) use something like;

gotoAndStop (1, "Scene 2" );
0
 
LVL 30

Assisted Solution

by:renazonse
renazonse earned 250 total points
ID: 34130656
The timer isn't stopping before it moves to the next scene. So, to make sure it stops add a "stop();" to the 1st keyframe in the main scene and add a "gotoAndPlay(1, "Scene 2"); to the code to make sure the timer is stopped before moving.

      if(i>=str1.length) {
            timer.stop();
            gotoAndPlay(1,"Scene 2");
      }
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now