QuicksearchArchives |
Thursday, March 6. 2008Instantiating and displaying MovieClips from loaded SWF
So you want to dynamically load a .swf, instantiate it and add to to a SWFLoader control.
First, loading the .swf: var loader:Loader = new Loader(); Now, to get its classes, we need to listen for the loading completion: loader.addEventListener(Event.INIT, callbackFunction); Once done, the callbackFunction will get and instantiate a class: var mcClass:Class = Hurray! Now we can add it to some appropriate container: someSwfLoader.addChild(mc); Now we want to scale it to fit the available space: mc.scaleX = mc.scaleY = someSwfLoader.width / mc.width;(a more complex algorithm may be used) A problem may arise if your clip content is not at 0,0 coordinates: var bounds:Rectangle = mc.getBounds(Application.application.stage);(if you have an ActionScript project instead of Flex, you'll need to access the stage by other means) Trackbacks
Trackback specific URI for this entry
No Trackbacks
|
CategoriesSyndicate This BlogBlog Administration |
Powered by s9y - Design by Anna Filina