PDA

View Full Version : Linking to Library Symbol w/XML var



SmoothDime
June 8th, 2008, 05:01 PM
hi,

i know how to go:

var mySym:MyLibrarySymbol = new MyLibrarySymbol();

how can i do that if i just have a string with the linkage name, ie:

var symName:String = 'MyLibrarySymbol';
var mySym:(symName!!) = new (symName!!)();

thanks

littlespex
June 8th, 2008, 06:35 PM
I think you would need to use getDefinitionByName:

import flash.utils.getDefinitionByName;

var symName:String = 'MyLibrarySymbol';
var symClass:Class = getDefinitionByName(symName) as Class;
var mySym:* = new symClass();

amarghosh
June 9th, 2008, 05:30 AM
for getDefinitionByName to work, there should be at least one instance or reference to the Symbol in your published swf.