plugin alignement ?

  • Hi,

    I'd like to know how I can align my image in my swf.

    My swf document is 550 px x 400 px.

    If I include it as a plugin, I would like to align my image in the top left.

    If it's a hotspot, it would be rather be align in the middle.

    My swf is loading image dynamically, so I don't know in advance what is the size of the image, and I can't resize my swf document manually.

    I check if my swf is load as a plugin or a hotspot by checking the first letter of my objet, and if it's a hotspot I can align my image in the middle with image.x = (stageWidth/2) and image.y = (stageHeight/2) but I'd like a better solution.

    Is there a way to "crop" my swf to the size of the image ? I dont know how to access to the dimension of my swf (it's not the document

    Klaus, I think you don't have the problem because you make the plugin with flex, and the dimension of the swf is not written "in hard".

    (I hope my english is enough comprehensible and I apologize for all my mistakes *smile* )

  • Hi,


    I'm not sure if I understand what you want to do

    is this correct:
    1. you have a swf app as plugin or hotspot
    2. this swf has a fixed size
    3. you load images with unknown size into this swf
    4. you want to align the loaded image in the middle (hotspot) or top left (plugin)


    maybe this could work:

    1. register a plugin RESIZE event: (have a look in the textfield.as for exampe)

    Code
    krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_RESIZE, resizeEvent);

    2. in the xml - set the width and height of the plugin/hotspot to "0":
    this will call the resize event to do the resize, but there just ignore the "0" size,
    (but for the internal alignment calculation krpano uses a width and height of "0")

    3. load your image, and set the "x" and "y" attributes of your image (of the Flash object!) to "0"
    for top left align or to the negative half width/height for middle align:

    Code
    image.x = (-image.width) / 2;
    image.y = (-image.height) / 2;
  • I'm not sure if I understand what you want to do


    I'm not a native english speaker, so my english can be a little bit messy sometimes *smile*

    is this correct:
    1. you have a swf app as plugin or hotspot
    2. this swf has a fixed size
    3. you load images with unknown size into this swf
    4. you want to align the loaded image in the middle (hotspot) or top left (plugin)


    That's it !

    I'll try.

    I've just found the edge attribute for the plugin, but I think it's not up-to-date, because by defaut, edge is the same as origin, and origin is decrepated.

    Regards,

  • Hi,

    I don't understand everything ...

    I don't know what to put inside the resizeEvent function.

    and, for the hotspot, I need the width="0" and height="0", to be in the middle. But if I put the same value for plugin, it disappears ?

    Anyway, I use your point 3 and I've found a solution :

    Code
    if ( plugin_path.indexOf("hotspot") == 0 )
        {
    		image.x  = - image.width/2 ; 
    		image.y = - image.height/2 ;
    	}

    Thanks for the answer *smile*

    Regards,

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!