How Do Scene & Viewport Work?
Can someone point me in the direction of a CS4 MultiScaleContainer example. I can create the instance but I can't seem to make the viewable area more than the default which appears to be 100 x 100. I've tried setting the width and height of the container:MultiScaleContainer as well as setting the sceneWidth and sceneHeight.
Thanks!
j
Thanks!
j
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
The best answers from the company
-
Batkins,
I didn't mean to confuse you but how many 500x500px (250'000px^2) pieces fit into a 1000x1000px (1'000'000px^2) area? ;)
I do think you have the right idea about how it works.
Cheers,
Daniel
I’m being silly
The company says
this answers the question
-
Guys,
To clear this up once and for all: The MultiScaleScene object represents a plain old Sprite object inside MultiScaleContainer. This basically means that if you set your scene to 1000x1000px and add a Sprite of size 500x500px it will take up one fourth of your entire scene. In theory, it doesn't matter how big your scene is, it only serves as a reference on how big the children (renderers) you're adding should be. However, in practice it turned out an optimal dimension is a power of two and even better is specifically 16384 (or 2^14 as Claudius has correctly noticed).
I know the topic of viewport & scene warrants an in-depth article on my blog for itself. For example, it may seem weird that I've designed the viewport with a normalized coordinate system [0, 1] but scene not. However, this is only because having a scene with normalized coordinates in Flash would be a very brittle abstraction, considering everything is done in screen pixel coordinates.
I hope this explanation clears up at least a little bit of the concept of viewport & scene.
If you have further specific questions, feel free to ask.
Cheers,
Daniel
The company says
this answers the question
-
Inappropriate?After working with this for a while I've figured it out. Please feel free to improve on this solution, but it appears to have resolved the issue. Default sceneHeight and sceneWidth (100, 100) occur when setting container x, y properties before setting width and height. Also, it seems width & height and sceneWidth & sceneHeight must be the same.
private var viewWidth:uint = 720;
private var viewHeight:uint = 600;
container = new MultiScaleContainer();
container.x = 80;
container.y = 30;
container.width= viewWidth;
container.height = viewHeight;
/*
1. After initialization and creation add assets to container.
2. After adding assets set:
container.sceneWidth = viewWidth;
container.sceneHeight = viewHeight;
*/
-jag -
Inappropriate?I have been toying around with the container today. my findings include the following:
- sceneWidth, sceneHeight: The "virtual" size that is to be zoomed.
- width, height: set this to whatever suits your application, i usually set this to be the same size as my stage and leave x and y = 0.
- addding children to the container pins them onto the scene, which means they will be draggable, scale accodring to the container (add constraints and controllers to the container like you would add them to a MultiScaleImage).
There are Examples in the sdk/examples/ folder. The actionscript-folder contains a demo which uses the Container, Even if you don't have Flex Builder, the code might be useful for you.
-
Inappropriate?What values are the sceneHeight and sceneWidth actually supposed to represent? Are they percentage values? Are you supposed to feed in the width and height of the Sprite (or image) you are trying to represent in pixel values?
As far as I can tell if you change one of the values to be different from the other value (i.e. set the sceneHeight to 100 and sceneWidth to 50) it will skew the graph so that the perspective is off (skinnier in this case).
That being said, it would be nice to know what these properties actually expect to get fed.
Note: I have been toying around with sprites, which are vector, so perhaps that's why I'm not seeing a lot of differences if I change these values?
I’m Confused
-
Inappropriate?I have not yet needed to set these values. They are, however, appearing in many other cases where i read them.
As far as i know, the longer side will be 16384 - the shorter side will be determined by the aspect ratio. I have not yet found out what's so special about this number, except for the fact that it's 2^14.
If you need to set the size of your image, try scale or zoom.
-
Inappropriate?Guys,
To clear this up once and for all: The MultiScaleScene object represents a plain old Sprite object inside MultiScaleContainer. This basically means that if you set your scene to 1000x1000px and add a Sprite of size 500x500px it will take up one fourth of your entire scene. In theory, it doesn't matter how big your scene is, it only serves as a reference on how big the children (renderers) you're adding should be. However, in practice it turned out an optimal dimension is a power of two and even better is specifically 16384 (or 2^14 as Claudius has correctly noticed).
I know the topic of viewport & scene warrants an in-depth article on my blog for itself. For example, it may seem weird that I've designed the viewport with a normalized coordinate system [0, 1] but scene not. However, this is only because having a scene with normalized coordinates in Flash would be a very brittle abstraction, considering everything is done in screen pixel coordinates.
I hope this explanation clears up at least a little bit of the concept of viewport & scene.
If you have further specific questions, feel free to ask.
Cheers,
Daniel
The company says
this answers the question
-
Inappropriate?Why is there a 4:1 aspect ratio? I would have thought going into this that if there is a situation such as you outlined (if you set your scene to 1000x1000px and add a Sprite of size 500x500px), then the Sprite would take up one half of the entire scene. Just trying to understand how to use this better.
-
Inappropriate?Batkins,
I didn't mean to confuse you but how many 500x500px (250'000px^2) pieces fit into a 1000x1000px (1'000'000px^2) area? ;)
I do think you have the right idea about how it works.
Cheers,
Daniel
I’m being silly
The company says
this answers the question
-
I gotcha, makes sense. My apologies, I'm still a little unaccustomed to working with pixel width and page layout / sprite layout in flash / flex.
Loading Profile...




EMPLOYEE