Ultrashock Forums > Flash > Third Party Tools
Referencing a sprite using a variable? [SwishMax]

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Referencing a sprite using a variable? [SwishMax]
Old 2009-11-23

Hi there,

is there code that allows me to declare a variable and then use this variable as part of my sprite name?

E.g:

Code:
onFrame (1) {
    question = "q1";
}
and then:

Code:
on (keyPress("<a>")) {
    _root.questions."my variable".gotoAndStop("A");
}
I've tried a few things - but can't get the syntax correct - any help is greatly appreciated.

thanks,
Neil
postbit arrow 3 comments | 410 views postbit arrow Reply: with Quote   
Registered User
maillme is offline
seperator
Posts: 442
2001-12-17
maillme lives in United Kingdom
seperator

Ultrashock Member Comments:
peter-II- peter-II- is offline peter-II- lives in United Kingdom 2009-11-26 #2 Old  
try:
Code:
var my_mc_name:String = "asdf";

// do the action
this[my_mc_name].gotoAndStop("A");
// or
_root[my_mc_name].gotoAndStop("A");
Reply With Quote  
maillme maillme is offline maillme lives in United Kingdom 2009-11-26 #3 Old  
Hi peter,

thanks for your reply - were do i declare my variable - is it ok to do this from within the mc itself?

thanks,
neil
Reply With Quote  
peter-II- peter-II- is offline peter-II- lives in United Kingdom 2009-11-26 #4 Old  
on the main timeline preferably, if not, in the mc that will trigger the action will do too.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: