Using a function to name a MoveClip
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
I'm trying to name a MovieClip via a function:
public function name(nameS:MovieClip){
nameS = new mc();//MC being the movieclip
addChild(nameS);
}
I'd access it like this:
name(player1);
I can't figure out, however, what to use to get this to work properly. is there something I'm missing?
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
Is there any chance of help out there?
- ProfessorFlash
-
ProfessorFlash
- Member since: Oct. 6, 2007
- Offline.
-
- Forum Stats
- Member
- Level 32
- Programmer
There's a very low chance of getting help because you are not making any sense, lol.
You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
package
{
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.ui.*;
import flash.events.*;
import flash.utils.*;
public class chargen extends MovieClip
{
public function chargen(){
genit("tyler",1,4,2);
}
public function genit(nameS:String,headN:Number,shirtN:Number,pantsN:Number){
nameS = new player();
addChild(nameS);
nameS.head1.gotoAndStop(headN);
nameS.shirt1.gotoAndStop(shirtN);
nameS.pants1.gotoAndStop(pantsN);
nameS.x = 100
nameS.y = 100
trace("created");
}
Simply put, I want this function
genit("tyler",1,4,2);
to create a movieclip named tyler.
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
Is this still confusing? I understand it but i can't really communicate it that well.
- ProfessorFlash
-
ProfessorFlash
- Member since: Oct. 6, 2007
- Offline.
-
- Forum Stats
- Member
- Level 32
- Programmer
I get now what you are trying to do but I still don't get why you would want to do that. Bottom line is that you can't set a string to be a movieclip. If you want to identify your movieclip as "tyler" then use the 'name' property. What does it matter what name the variable is in the function? It disappears anyway after the function is run.
You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.
- Redshift
-
Redshift
- Member since: Feb. 12, 2005
- Offline.
-
- Forum Stats
- Member
- Level 15
- Programmer
You can use an Object (which you can use as a dictionary of sorts).
public var movieClips:Object = new Object();
public function nameThing(nameS:String){
movieClips[nameS] = new MovieClip();
}
// test code:
nameThing("blah");
trace(movieClips["blah"]);
//traces "[object MovieClip]"
I personally don't do things like this, better to use an Array or something.
#include <stdio.h>
char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";
main() {printf(p,10,34,p,34,10);}

