Skip to main content
Known Participant
April 23, 2013
Question

string to object bitmap conversion

  • April 23, 2013
  • 3 replies
  • 754 views

Hello:

How can I convert a string to an object bitmap?

Thank you.

With this I get error:

var f1:String ="photo1";

var img:Object=f1;

var foto1:BitmapData = new img(0,0); 

var foto1_stage:Bitmap = new Bitmap(foto1);

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

kglad
Community Expert
Community Expert
April 23, 2013

what is "photo1"?

is that the class name of a bitmapdata object?

anjemalo1Author
Known Participant
April 23, 2013

I mistake an error.

I have in the library:

Photo1

Photo2

Photo3

etc,

linked to actionscript

I need to convert string "Photo"+ 1 to an object

I need to convert string "Photo"+2 to an object

kglad
Community Expert
Community Expert
April 23, 2013

use:

var c:Class=Class(getDefinitionByName("Photo1"));

var c:*=new c();

// and, if those are bitmapdata class objects, possibly:

var bmp:Bitmap=new Bitmap(c);

addChild(bmp)