Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsHow can I use the same variables more than once in AS3?
For example I want to use the var 'number1' in multiple frames but I keep getting this error.
var number1:int = x
1151: A conflict exists with definition number1 in namespace internal.
At 3/19/13 10:13 AM, IMACAT wrote: How can I use the same variables more than once in AS3?
For example I want to use the var 'number1' in multiple frames but I keep getting this error.
var number1:int = x
1151: A conflict exists with definition number1 in namespace internal.
number1 = x
you cant declare same variable more then one time
RangeError: Error #1125: The index 4 is out of range 4.
At 3/19/13 10:14 AM, nitokov wrote:At 3/19/13 10:13 AM, IMACAT wrote: How can I use the same variables more than once in AS3?number1 = x
For example I want to use the var 'number1' in multiple frames but I keep getting this error.
var number1:int = x
1151: A conflict exists with definition number1 in namespace internal.
you cant declare same variable more then one time
Yes, but how do I use it more than once?
It's unnecessary to rewrite new variables that do the same thing on another frame.
At 3/19/13 12:20 PM, IMACAT wrote: Yes, but how do I use it more than once?
It's unnecessary to rewrite new variables that do the same thing on another frame.
He just told you how.
Just use it. You don't have to redeclare.
At 3/19/13 12:24 PM, 4urentertainment wrote:At 3/19/13 12:20 PM, IMACAT wrote: Yes, but how do I use it more than once?He just told you how.
It's unnecessary to rewrite new variables that do the same thing on another frame.
Just use it. You don't have to redeclare.
How would I go about using it? Do I just type number1, var number1:int ?
Every variable needs to be declared in any frame, this is why I'm asking the question.
1. Do you write code on timeline or in as class?
2. Is that AS2 or AS3?
RangeError: Error #1125: The index 4 is out of range 4.
At 3/19/13 01:13 PM, nitokov wrote: 1. Do you write code on timeline or in as class?
2. Is that AS2 or AS3?
AS3 on timeline.
At 3/19/13 12:38 PM, IMACAT wrote: Every variable needs to be declared in any frame, this is why I'm asking the question.
Where do you get this fact from?
You're refusing to try it. Just do it!
Frame 1:
var myVar:int = 0;
Frame 2:
myVar = 2;
trace(myVar); At 3/19/13 01:13 PM, nitokov wrote: 1. Do you write code on timeline or in as class?
2. Is that AS2 or AS3?
None of that matters.
var x:int = 5
x = 10
x = 15
Although you should be using AS3 in classes.
At 3/19/13 02:30 PM, 4urentertainment wrote:At 3/19/13 12:38 PM, IMACAT wrote: Every variable needs to be declared in any frame, this is why I'm asking the question.Where do you get this fact from?
You're refusing to try it. Just do it!
Frame 1:
var myVar:int = 0;
Frame 2:
myVar = 2;
trace(myVar);
That's not exactly what I'm asking for. I'll try to rephrase it by using dynamic text.
First frame contains
var number:int = 1
hello_txt.text = number.toString()
Second frame contains
hello_txt.text = number.toString()
I want both txts on both frames to express the variable. But I need to state the variable every-time for this to work?
Does the variable not exist on the second frame? I honestly wouldn't be surprised, no one will condone you using AS3 on the timeline, stick with classes.
I dont whant to demotivate you or something, but your way of doing this is very bad way. You cant cheat coding, there is no easier way, you can either do it good way or bad way, and this is school example of bad way. If you really whant to do something with AS3, please learn how to use classes when you start to learn it everything will become lot easier, and you will laugh at this problem, cheers
RangeError: Error #1125: The index 4 is out of range 4.