Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Flash

Posted on 2011-02-28
3
Medium Priority
?
298 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

609 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