PDA

View Full Version : Class name to string



Alber Kidd
March 11th, 2009, 10:57 AM
I have a loop which add my button to the stage. However I want to assign a name to the buttons which is the same as the class. I am trying to use the AS keyword with no luck.

Any ideas?

var movieList:Array = [AboutBut, WhatBut, OurWork, News, ContactUs];
var tempClip:MovieClip;
var tempClip:String;
var yPos:int = 0;
for (var i:uint=0;i<movieList.length;i++) {
yPos =yPos+ 55;
tempClip = new movieList[i]();
tempClip.name = movieList[i] as String;

tempClip.y = yPos;
menuHolder.addChild(tempClip);

GrndMasterFlash
March 11th, 2009, 11:02 AM
this...

String(movieList[i]).substring(6,String(movieList[i]).length-1);

Alber Kidd
March 11th, 2009, 11:07 AM
wow - thought there would be a much simpler solution.

Thanks.

be.adaptiv
March 11th, 2009, 01:16 PM
//Import
import flash.display.getQualifiedClassName;

//Place this inside your loop
var name:String = getQualifiedClassName(movieList(i));