Solved

Flash CS4 - AS3 Questoin about Scenes

Posted on 2010-11-14
2
620 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

920 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

16 Experts available now in Live!

Get 1:1 Help Now