HOW ? (Stage.height - this.height)

[AS]onClipEvent (enterFrame) {

    bottom = 400-30;  // how can i get bottom to = ( Stage.height - this.height );
    top = 30;
    right = 550-30;
    left = 30;
    
    this.onPress = function() {
            
            this.startDrag(0, left, top, right, bottom);
            this.drag = true;
            this._alpha = 50;};
    
    this.onRelease = function() {
            
            this.stopDrag();
            this._alpha = 100;
            
            if (this._x<=80) {this._x = left;}
            if (this._x>=470) {this._x = right;}
            
            if (this._y<=80) {this._y = top;}
            if (this._y>=320) {this._y = bottom;}
    };}

[/AS]

[AS]bottom = Stage.height-this._height;[/AS]
?? :stuck_out_tongue:

By the way, you shouldn’t define the event handlers within the onClipEvent (enterFrame) handler. Use an onClipEvent (load) handler, or define them on the Frame actions. =)

Thanx for your respose Kax

I tried that already but it didn’t work… it must have been because of the onClipEvent (load);

Can you tell me why that is ?

also
[AS]
bottom = Stage.height-(this._height/2); // should be equal to ( 400 - 30 ) but is doesn’t.[/AS]

I don’t see why…

stage.height = 400
this._height = 60

Attached is the file

What do you mean!?

I traced the variable bottom, and guess what… it is equal to 370 (400-30)!! :-\

[AS]
bottom = Stage.height-(this._height/2); // should be equal to (400-30) but is doesn’t (bottom = 400-30; works)
top = this._height/2; // this works
right = Stage.width-(this._width/2); // should be equal to (550-30) but is doesn’t (right = 550-30; works)
left = this._width/2; // this works
[/AS]

I dont see why this is not working, I see no reason why it shouldn’t…
[AS]
bottom = Stage.height-(this._height/2); // should be equal to (400-30) but is doesn’t (bottom = 400-30; works)

bottom = 400-(this._height/2); // works
[/AS]

stage is = 400
(this._height/2); = 30

Stage.height = ???

Oh!! Now I know what you mean. :stuck_out_tongue:

Publish the SWF and test it in the Flash Player, the Stage width and height properties will be inaccurate in the Test Movie mode.

Far out !

well your right it does work… any idea why it doesn’t work when you test the movie ?

is this a bug, as I have never had it happen b4 ?

thanks for you help KAX

Nope… I have no idea. I’ll see if I can find anything about it.

And you’re welcome. =)

Aha, finally someone in the need for my fix!
Too bad you went to all this trouble, because I knew how to fix this when I read your first post :slight_smile:

Anyway, if you call Stage.width and Stage.height during Flash runtime, it will not give the correct properties. It will only do this once, after you start the movie!(*)

So what we need to do is catch the variables at that point, and save those. Instead of doing this in another variable, you can just overwrite the Stage properties.

Here’s my fix:

Stage = {width: Stage.width, height: Stage.height};

(*) - Well, Flash doesn’t even return the correct values, but the movie dimensions minus 4 :slight_smile:
It confirmed that this is fixed in Flash MX 2004, but the original program where invalid dimensions are being returned the second time still remain :frowning:

In addition, with the new Actionscript 2.0 parsing engine, you will not be allowed to overwrite a static object such as Stage anymore. Object classes need to be defined as “dynamic” in order to do so.

In other words, this fix is for FlashMX only!

Think. What happens when you test a movie in Flash? The swf window pops up and maximizes. What are the stage dimensions on a maximized window? **** big. So, in testing your swf in Flash, restore your swf window so it will be played with a normal stage size. Then the Stage object will report the ‘correct’ stage dimensions

(Im hoping I didnt do a skim thing where I missed the point as I often do)

I knew that, Eric. :slight_smile:

I wouldn’t call it a fix, though… you said it yourself, the Stage object will be overwritten if you do that. :-\

By the way, I registered at your site about a month ago… I’m still waiting for my confirmation email. :stuck_out_tongue:

[EDIT]See? You’re right again, sen. :whistle:[/EDIT]

Or, just add 4 :stuck_out_tongue:

[AS]onClipEvent (load) {
bottom = (Stage.height-(this._height/2))+4;
top = 30;
right = 550-30;
left = 30;
this.onPress = function() {
this.startDrag(0, left, top, right, bottom);
this.drag = true;
this._alpha = 50;

};
this.onRelease = function() {
	this.stopDrag();
	this._alpha = 100;
			if (this._x<=80) {this._x = left;}
	if (this._x>=470) {this._x = right;}
	
	if (this._y<=80) {this._y = top;}
	if (this._y>=320) {this._y = bottom;}
};

}
[/AS]

… don’t post so quickly ! :stuck_out_tongue:

*Originally posted by kax *
By the way, I registered at your site about a month ago… I’m still waiting for my confirmation email. :stuck_out_tongue:
**

LOL, then you probably registered right duing the serverchange. I’ll check if I can find your username, and active your account manually.

[edit]
[COLOR=red]Grrr, better give me your username,cause I can’t find you[/COLOR] [/edit]
-jr

*Originally posted by Eric Jr. *
**I’ll check if I can find your username, and active your account manually. **

Mine too please, I didn’t receive an e-mail either.

Hehe - Thanks, Eric. :thumb:

[EDIT]If you can’t find this username (kax), it must be kode.[/EDIT]

Kax, there are no members called “Kax” or “Kode” in my database.
Neither are you between people from Mexico :slight_smile:

You can give me your email so I can check for that, or you’ll need to re-register.

Voet, you’re done … check the activation email in your inbox!!

Ah bedankt Eric =)

LMAO :stuck_out_tongue:

I’ll try to re-register. :stuck_out_tongue:

**** that sucks … sorry mate …
Other then that, I’m almost unable to produce errors in my lastest CMS version …

**** provider has been an *** from the beginning :frowning:

[edit][color=red]LOL[/color][/edit]

Luis M … **** you were in there … you could have just told me your name :slight_smile:
Mexican :stuck_out_tongue: