-
[F8] Possible to Use Variable Identifiers inside Objects?
Is it possible to specify a variable identifier inside a movieClip object?
code:
var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
// I know that the following won't work, but I'd like to specify a variable identifier, so, I would have written it like so:
var myClip.myNewVar:String = "Why must it be so hard!?";
-
Senior Member
did you think to try
Code:
myClip.onEnterFrame = function():Void
{
var myNewVar:String = "maybe this will work";
delete myClip.onEnterFrame;
}
//I have programmed in Flash in a while, but there may be a myClip.onLoad = function...
//but I'm not sure if that would work.
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
Senior Member
Originally Posted by Beaudoin
Is it possible to specify a variable identifier inside a movieClip object?
code:
var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
// I know that the following won't work, but I'd like to specify a variable identifier, so, I would have written it like so:
var myClip.myNewVar:String = "Why must it be so hard!?";
You're the web designer for the Canadian Army? That's cool.
Yes, you can create dynamic variable references to movie clips, the problem is that you can't type them.
So you could do:
Code:
var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
myClip.myNewVar = "Hey! It works!";
//and check it;
trace(myClip.myNewVar);
If you really needed/wanted to do so, you could type the variable this way:
Code:
var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
var temp:String = "Hey! It works!";
myClip.myNewVar = temp;
//and check it;
trace(myClip.myNewVar);
Hope this helps.
d.
-
That's great! Thanks guys!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|