?
Solved

Flash

Posted on 2011-02-28
3
Medium Priority
?
293 Views
Last Modified: 2012-08-14
Hi i have a problem i create a variable var countss:Number = 1; and when i open 2 more layer it do not work any more. How i can creare global variable so i can use it when i go 2 layer down.
0
Comment
Question by:umaxim
[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
3 Comments
 
LVL 12

Expert Comment

by:scooby_56
ID: 34999193
if countss is in the root then you could use this in your lower layers

var r = root;
trace(r.countss) //note that  trace(root.countss) will not work.

Otherwise you could access by doing:
trace(parent.parent.countss);
0
 
LVL 4

Accepted Solution

by:
ute_arbeit earned 2000 total points
ID: 34999698
That depends on your version of Actionscript:
1. In Actionscript 1 or 2 you can define global variables using the '_global' prefix like so:

_global.countss = 1;

Open in new window



The you can reference it from any script in any level using
_global.countss

Open in new window



2. In Acrionscript 3 the _global object was removed. You should organize your code and data in classes. But if you absolutely want you could create a class called e.g. GlobalData.as in the root of your class directory (normally the folder containing the fla) and add the variable as a public static variable.

package {
	public class GlobalData {
		public static var countss:Number = 1;
	}
}

Open in new window


As the variable is static you do not have to create an instance of your class and can just reference if from anywhere with
GlobalData.countss

Open in new window

0
 
LVL 1

Author Closing Comment

by:umaxim
ID: 34999929
thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
Suggested Courses

770 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