View Full Version : Variables and Instance names?
NaQuer
08-19-2003, 10:05 AM
Hi
I have read the variable and the instance name tutorials throw twice, but i still can't see why and where to use them. In which connections should i give a variable a value, and why should i use instance names to define my instances?
-Mikkel
Mr.Moo
08-19-2003, 10:20 AM
Originally posted by NaQuer
why should i use instance names to define my instances?
To answer that ^, when you use Instance Names then any actionscript you use has a direct link (if you choose to make one) to the symbol, for example if you have an MC with an instance name 'pop' and you want to tell a button that when it is pressed, flash should go into 'pop' and play frame 2, so this would be your actionscript:
on (release) {
tellTarget ("/pop") {
gotoAndPlay(2);
}
}
without that instace name you would not be able to go inside the MC.
Hope that answers that question
MoOoOoOoOoOoOoOoO:D
farafiro
08-19-2003, 10:28 AM
lemme try to help
let's say we have a movieclip (mc for shortening) called ball
this mc (ball) coordinates are _x = 100 and _y = 100
we also have a button on the screen called move
we want the ball coordinates to be _x = 300, _y = 300 when we click the button
so, what we wanna do basicly is to call the button (by its INSTANCE NAME) and to tell it that when we release it, there is a MC on the stage that has an instance name of BALL, we want to change its coordinates
so, we put that script on the stagemove.onRelease = function(){
ball._x = 300
ball._y = 300
}
this is cool
but also there another cooler way to do that
we car store the coordinates we have into variables so we don't make any typo mistakes and for ease to remember
so, we may do it asvar xPosition = 300
var yPositio = 300
move.onRelease = function(){
ball._x = xPosition
ball._y = yPosition
}
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.