Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic container/stage sizing? 1

Status
Not open for further replies.

Leozack

MIS
Oct 25, 2002
867
GB
Hi all - been workin away on makin my tool dynamicly sized. So it can read in an x/y size along with other stuff and set everything up. Currently I've got the container clips positioning and sizing correctly (had issues when referencing clips within clips (the parent of the child would be effected for some reason so moved all clips to root).

But is there a way to set the stage size? Else if the dynamically read size is bigger than the preplaced default it goes off the edge of the stage and disappears. I'm thinking there isn't a way to do this :/

Also, I noticed the image I imported via loadMovie was also enlarged. I knew there was effects like that from using scale etc, but I'm just using a preplaced library item, setting it's x/y and width/height, before I load anything into it. Surely I can do that before loading something and not have the something resized to the same ratio as the container now is to it's original proportions? x.x

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
But not dynamically from within flash? I guess that makes sense. So I'd ahev to choose a maximum possible width and height and just scale down within that dynamically but be unable to scale any higher.

Any thoughts in resizing an image in a clip and getting it working properly unlike my attempts? :(


_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
so lemme get this straight ... I embed my flash at a set size, read in a size for the stage, and call flash telling it to somehow enlarge the stage? or is that to embed a new one at the new size?

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
I thought it'd be nice ot let the user specify the applet size in their config xml file. And of course I can shrink the initial stuff down but I can't enlarge it because the stage isn't big enough. But I can't change the stagesize dynamically can I? I guess I could try to launch it in 100% of a popup that they can resize themself or something? But no it's not the end user that I want to dictate the display size, but the designer. o_o

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Does that explain it ok?

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Well no I mean I can create a stage of any size or a window of any size but the thing is he size I want to make it is read into flash from xml so flash must already exist?

I mean if it's totally impossible to resize a whole stage once it's been created then I'll forget about it and just give them a set of choices or no choice at all :) Or make it 100% of something and it's upto them what size they make that something.

Out of interest, if you make a - say - 320*240 flashmovie and someone makes it fullscreen or drags it bigger somehow, does all your code and pixel positions etc stil work out ok relatively or does it all screw up?

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Flash cannot change its Stage size but the browser/player window can be resized by user/script. If the window size is changed the Stage size will change if it's not fixed. If that happens elements inside also resizes proportionally.



Kenneth Kawamoto
 
Ok so the *only* way to resize a flash stage already made is to call it without size settings inside a popup window you created to be a set size, which can then be resized with js or by the user, and the flash scales proportionately and coded/pixel operations work with it rather than huddling to the top left original pixel placement. And that's the only way?

Hmm. Basically it's a gallery style app and I thought it good if they had a choice of what size to make the whole thing. But if it gets scaled rather than resized then contents would get scaled too including their imported pics? I dunno, I'm confusing myself now :/

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
I notice you said "If the window size is changed the Stage size will change if it's not fixed" ... how can it be not fixed?

I've just got what I think is successful code example for image resizing though I'm not sure entirely how the prototype function is working maybe someone can tell me what it's doing precisely that I can't make work without it?
Code:
MovieClip.prototype.loadImage = function(url, vars) {
	if (this.onData != undefined && this.onData != null) {
		this._parent.createEmptyMovieClip("__fixEvents", 7777);
		this._parent.__fixEvents.theTarget = this;
		this._parent.__fixEvents.onData = this.onData;
		if (this.onLoad != undefined && this.onLoad != null) {
			this._parent.__fixEvents.onLoad = this.onLoad;
		}
		this._parent.__fixEvents.onEnterFrame = function() {
			this.oldv = this.v;
			this.v = this.theTarget.getBytesLoaded();
			if (this.v != this.oldv) {
				this.onData.call(this.theTarget);
			}
			if (this.v == this.theTarget.getBytesTotal() && (this.theTarget._width>0) && (this.theTarget._height>0)) {
				this.theTarget.onData = this.onData;
				if (this.onLoad != undefined) {
					this.theTarget.onLoad = this.onLoad;
				}
				this.onLoad.call(this.theTarget);
				this.removeMovieClip();
			}
		};
	}
	this.LoadMovie(url, vars);
};

I then wrote my own code to just say
Code:
thisImage_mc._quality = "BEST";
thisImage_mc.onData = function() {
};
thisImage_mc.onLoad = function() {
	if (thisImage_mc._width > thisImage_mc._height) {
		thisImage_mc._xscale = thisImage_mc._yscale = (maxWidth/thisImage_mc._width) * 100;
	} else {
		thisImage_mc._yscale = thisImage_mc._xscale = (maxHeight/thisImage_mc._height) * 100;
	}
};
thisImage_mc.loadImage(thisFile);

But I'm using SWFobject to display this flash (it may be displayed otherways by end users though, possibly) and I am setting the stage size in the html to be the default flash movie stage size on my project, eg
Code:
var so = new SWFObject("vTour.swf", "vTour", "640", "480", "6", "#FFFFFF");
so.write("flashcontent");

But then - if the flash reads in from the xml and the xml says use 800 * 600, the flash all works dynamically fine, but the stage size remains the sme so you don't see the stage areas outside of it. Is there a way round this or should I just tighten all use of the application and dish out rules instead fo flexibility?

Oh, and I was wondering if there was a way when importing images to set a transparency colour, so all pixels of that colour are transparent and you see the contents behind it? Or am I limited ot jus overall alpha or making masks or something (if so please lmk how) :)

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
So you're saying read the xml in first using JS and set the flash using that and then the flash won't need to resize? And that's the only way?

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
And now I think about it - even if I sized the stage using SWFObjet ... surely if my flashfile was saved as, say, 640*480 and I display it at 800*600, it is stretching everything ... so if I loaded an 800*600 picture in you'd still only get the first 640*480 of it but stretched to 800*600? Or am I just confusing that with mc containers? :/ Guess I'm thinking just lik ea html page that resizes with the browser or windowsize it's given to popup in, but the content doesn't get stretched so the bigger it is the more content you fit in.

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Well my content uses library items that are a fixed size (only gradient bg's) but it positions and sizes these boxes dynamically based on the x*y size of the project. I then make empty movieclips over the top of them to put content in. Apart from the textboxes which I write to directly, I guess these will get shrunk//stretched etc?

== So ... JS reads in XML. Sets stagesize with SWFObject from x*y projectsize.
== Flash reads in XML. Positions and sizes objects by x*y projectsize. Reads in images and shrinks them to fit the window.

That's ok? Else I could just fix the size or give a limited selection of 2 or 3 sizes.

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
No but all the project stuff is xml based. Ok ^^

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top