Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Flash CS4 - AS3 Questoin about Scenes

Posted on 2010-11-14
2
Medium Priority
?
634 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 1000 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
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.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

721 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