Copy link to clipboard
Copied
Hi all,
Is it possible to use variables in place of object names? So i have a function that looks like this:
public static function xmlText(OBJECT,TEXT):void
{
some_mc.[OBJECT].some_mc.text = lodedXML.someNode.[TEXT].someNode;
}
I'm trying to create a function that changes the variables in the paths to the objects passed when the function is called.
This might be a daft question but i just cant seem to find an answer!
Many Thanks
Matt
Give me an example of what you want to do and explain it and I will try to give you an example beyond this...
var someMC:Movieclip = new MovieClip();
at this stage you only need to target someMC since you have a direct reference to it, even if you make it a child of some other object.
Copy link to clipboard
Copied
If you assign a variable as a reference to an object you can use that to target the object.
Copy link to clipboard
Copied
Thanks Ned i was sure it could be done. Could you show me a quick example of how i'd write it?
Cheers!
Matt
Copy link to clipboard
Copied
Give me an example of what you want to do and explain it and I will try to give you an example beyond this...
var someMC:Movieclip = new MovieClip();
at this stage you only need to target someMC since you have a direct reference to it, even if you make it a child of some other object.
Copy link to clipboard
Copied
Thanks Ned ; )
The example in my first post is what i'm trying to acheive:
public static function populatePlatforms(COURSE:Object,PLATFORM:Object):void
{
Diagram_mc.COURSE.xmlData_mc.platform_mc.platformDetails_mc.data_txt.text = LoadedXML.platformDetails.PLATFORM.text;
}
the function above has two parameters which are passed into the line of code within, so that i can target different items whenever i call it. However if i run this code i get an error "1119: Access of possibly undefined property COURSE through a reference with static type Class."
I'm just not sure what i'm doing wrong, perhaps i'm using the wrong type of variables?
Cheers!
Matt
Copy link to clipboard
Copied
The problem might lie in how you define these objects.
As I already indicated, if you have a variable assigned to the object already, then you do not need to target its parent to get to it, especially if its parent has no basis to know that it exists by that variable name.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now