tags:

views:

403

answers:

2

Hello all,

I am trying to load an swf file which has button skins as images (In the library of the swf file i have given export properties which is 'TickMark') and set the skin of a flex button using StyleManager.setStyleDeclaration.

I am getting errors like 'Argument count mismatch on TickMark(). Expected 2, got 0.'

This is what i am trying to do:

 private function init():void
            {
             loader = new Loader();
             loader.contentLoaderInfo.addEventListener(Event.COMPLETE,styleSWFLoaded);
             loader.load(new URLRequest("styles.swf"),new LoaderContext(false,ApplicationDomain.currentDomain));

            }

  private function createStyle(styleName:String):void
            {

             var style:CSSStyleDeclaration = new CSSStyleDeclaration(styleName);


                var cls:Class = ApplicationDomain.currentDomain.getDefinition(ss) as Class;

                style.setStyle("upSkin",cls);

              }
             }
             StyleManager.setStyleDeclaration(".buttonme",style,true);
            }

When I apply this new style 'buttonme' to a button i am getting below error:

ArgumentError: Error #1063: Argument count mismatch on TickMark(). Expected 2, got 0.

Not sure why is this happening, and strange thing is, when I embed the same swf file it works, like below:

[Embed(source="styles.swf", symbol="Tick")] 
private var GraphicClass:Class;

If I use the class GraphicClass in setStyleDeclaration, it works... but basically I want it dynamically.

Or there are other easy methods to skin (image) a flex button dynamically?

A: 

You should be able to set your skin like that dynamically. It probably has to do with your TickMark class. I'm assuming when you do style.setStyle("upSkin", cls);, that cls is TickMark and it has two required constructor args: TickMark(arg1:Object, arg2:Object). Is that true? Somewhere in the setStyle method its doing new cls().

If so, just make sure there's no constructor arguments and it should work.

If not, try following the stack trace and using breakpoints in Flex Builder if you don't already, that should help pinpoint the problem.

Best, Lance

viatropos
Hi Lance,The TickMark class is defined in the FLA file (export setting). As the asset i am setting for export is an image, the export settings takes the base class as BitmapData. BitmapData class requires two parameters, which is width and height.The new cls() is happening inside the flex components, and i saw it is calling that without parameters.It should point out that we cannot use BitmapData as the asset for skinning flex component, or we are missing something really here.
Vipin
A: 

I believe, when you embed the export-symbol in your flex-app, it would be taking care of size and perhaps just embedding the png directly.

As your symbol-class extends BitmapData, it has to be instantiated by passing required arguments in constructor. So whatever error you get, is by design and work as expected.

You can wrap png in some other type of symbols (sprite, movieclip, etc) and export. That should work fine when used in setStyle (..,..)

Abdul Qabiz
Thanks for the reply, abdul. I did try wrapping the image in a movieclip, but when I set the class to setStyle(upSkin,cls), it throws an error that cannot convert class MyClass to FlexDisplayObject, at newSkin = IFlexDisplayObject(new newSkinClass()); in the Button.as class. :(
Vipin