Page 1 of 1
can i change the viewport size dynamically?
Posted: 20 Nov 2008, 09:08
by hirokimo
hi,
i know i could set the os viewport size in component panel,and it works,
but if i want to change the os viewport size dynamically,i mean according to the stage width or something else,is it possible?
thx~~~
Re: Changing viewport size
Posted: 20 Nov 2008, 09:14
by morgflast
I was actually having a similar, simpler problem. I would like to know how to 'statically' resize the viewport for openspace, so that the openspace window is larger than 640x480.
If you happen to have some instructions about how to do this, it would be much appreciated.
Thank you!
Re: Changing viewport size
Posted: 20 Nov 2008, 09:16
by morgflast
To clarify the above post, we are interested in exporting the Openspace libraries as an swc file for Flex to use with a larger viewport.
morgflast wrote:I was actually having a similar, simpler problem. I would like to know how to 'statically' resize the viewport for openspace, so that the openspace window is larger than 640x480.
If you happen to have some instructions about how to do this, it would be much appreciated.
Thank you!
Posted: 20 Nov 2008, 14:34
by Bax
hirokimo:
dinamically changing the size of the OpenSpace component is not possible. When initialized, OpenSpace "reads" the viewport size and it can't be changed later.
morgflast:
you need the Flex Component Kit for Flash.
Create a new fla in Flash and drag the
FlexComponentBase component to its library.
Then create a new movieclip, set it to be exported for ActionScript and give it a class name (for example
OpenSpaceWrapper) and set its base class as
mx.flash.UIMovieClip.
Drag the OpenSpace component inside the movieclip and give it an instance name, for example
os.
Then create the OpenSpaceWrapper.as class like this:
Code: Select all
package
{
import mx.flash.UIMovieClip;
import mx.events.ResizeEvent ;
public class OpenSpaceWrapper extends UIMovieClip
{
function OpenSpaceWrapper()
{
_width = os.width
_height = os.height
}
override public function get measuredWidth():Number
{
return os.width
}
override public function get measuredHeight():Number
{
return os.height
}
override public function setActualSize(newWidth:Number, newHeight:Number):void
{
if (newWidth != _width || newHeight != _height)
{
_width = newWidth
_height = newHeight
os.setSize(_width,_height)
}
}
}
}
In the end, export the swc following the guidelines of the Flex Component Kit for Flash.
This has not been fully tested, but should do the trick: when you resize the wrapper in Flex, OpenSpace is resized accordingly. Of course what said to hirokimo is still valid: if you resize the wrapper after OpenSpace initialization, the OpenSpace behavior will be messed up.
Important: see this reply below for a possible issue and its workaround
Posted: 21 Nov 2008, 01:44
by hirokimo
to bax:
ok,i see,it`s unreasonable to change the viewport size when the os componet initialized.
to morgflast:
i`ve tested this way in flex(actionscript project),and it works
here`s my step:
1.export a swc file with os componet
2.add the swc into an actionscript project in flex.
3.var os:OpenSpace = new OpenSpace();
4.os.setSize(800,250); or you can, os.setSize(stage.stageWidth,stage.stageHeight);
5.load the os skin,os bg....
and as bax said,the size could not be resized again only if you reload the os.
thx u guys~
Posted: 24 Mar 2009, 11:18
by Paul Scherbak
Hi!
I create OpenSpace component how is specified above, by means of OpenSpaceWrapper. I use MXML, AS3 in FlashDevelop. The component successfully created, avatars can move, but over tiles there is a white area.
And after a while it is informed on an error:
Code: Select all
ReferenceError: The POWERED BY OPENSPACE text must be visible!
at com.smartfoxserver.openspace::OpenSpace/com.smartfoxserver.openspace:OpenSpace::onLinkTest()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()
Help, please...
Posted: 25 Mar 2009, 06:45
by Bax
Not clear why you have that white rectangle covering OpenSpace. Maybe you can send your code an we will give it a look.
The error is due to the fact that the rectangle partially covers the OpenSpace logo in the top-right corner (this is not allowed when using the evaluation version of OpenSpace).
Posted: 25 Mar 2009, 16:17
by Bax
I create OpenSpace component how is specified above, by means of OpenSpaceWrapper. The component successfully created, avatars can move, but over tiles there is a white area.
It took a while, but we have an explanation to this strange behavior. It seems that Flex doesn't like the mask that the OpenSpace component uses internally to hide tiles and background portions outside of the viewport. That white rectangle is the movieclip which "should" become a mask.
The good news is that this issue show up only if you place the OpenSpaceWrapper (see code above) on the stage via ActionScript. If you create it directly inside the mxml and set its width/height, it works like a charm.
This issue has already been fixed in the engine of the next OpenSpace version (under development, please don't ask the release date!), which will be distributed as a Flex native component (side by side with a Flash native component).
Posted: 26 Mar 2009, 09:52
by Paul Scherbak
Thanks, it works!
Posted: 18 May 2009, 15:15
by nig3d
one problem I have using flex or flash develop is that I can't compile the code of my avatar.
My avatar is a fla file which a movieclip inheriting from an OS avatar object so I can't compile it with flex.
Do you have some hints about it?
Posted: 19 May 2009, 09:13
by Paul Scherbak
nig3d wrote:one problem I have using flex or flash develop is that I can't compile the code of my avatar.
My avatar is a fla file which a movieclip inheriting from an OS avatar object so I can't compile it with flex.
Do you have some hints about it?
The class an avatar is compiled by "publish" in Flash.