Solved

Flash CS4 - AS3 Questoin about Scenes

Posted on 2010-11-14
2
629 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Britt Thompson
Britt Thompson 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

622 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