PDA

View Full Version : Loading Embedded Symbol and Resizing it?


drydo
08-03-2009, 11:12 AM
I'm experiencing an unusual problem in Flex where I can retreive symbols from an embedded SWF - but when I try to resize the movieclip it ignores the setting?

Here's a quick snippet...

// Embedded Library Item
[Embed(source="C:\\Art-Store\\Mono\\Air\\AirPlayer\\bin-debug\\Masks.swf", symbol='TR_BoxIn')]
[Bindable]
private var TwoBox_CrossoverSymbol:Class;

// Load the library item
mMaskMovie = new TwoBox_CrossoverSymbol() as MovieClip;
mMaskMovie.gotoAndStop(1);
// Position
mMaskMovie.x = mParent.ScreenWidth / 2;
mMaskMovie.y = mParent.ScreenHeight / 2;
mMaskMovie.visible = true;
// Set the dimensions
mMaskMovie.width = mParent.ScreenWidth;
mMaskMovie.height = mParent.ScreenHeight;
// Then add
this.addChild(mMaskMovie);

In short, setting the width and height simply doesn't work and tracing out the dimensions makes no difference. I've also tried wrapping the MovieClip into DisplayObject and utilising the 'setActualSize' but that didn't work either. Has anyone experienced this before or does Flex enforce the Width and Height of embedded symbols from an external SWF?

[Note: this code works perfectly in AS3 / Flash 10]

Thanks in advance

wvxvw
08-03-2009, 11:40 AM
Flex parsing of embedded symbols isn't... perfect. I had similar issues before, the workaround I found - compile resources from Flash to SWC and use those instead of [Embed]. If this isn't an option, then apply all the transformations through DisplayObject#transform.matrix, this seem to always work, while x/y/height/width sometimes behave unpredictably.

drydo
08-03-2009, 02:55 PM
Thank you very much! Got it working creating an SWC.

For those it may help, here's the steps I followed...

Within Flash (CS4), go into the Publish Settings and select the 'Export SWC' option then publish.
Within Flex (3), select 'Project' \ 'Properties' \ 'Flex Build Path' \
Select the 'Library Path' tab, click 'Add SWC' and select the published SWC file. Run through the dialog windows and click OK. You symbols should now be available through intellisense.

Cheers wvxvw! Out of interest, is there a quicker and smarter way of updating / refreshing the SWC apart from reproducing the steps above?