Mc Placed On Stage Centrally
Hi everyone I have a range of attached movie clips that are different widths. can someone explain how to always ensure that current Mc is centered on the stage. Im so tired i cant think straight i know its something like this:- _root.master_clip._x=_root.master_clip.Stage.width/2 respect Kippereye
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 12-12-2005, 08:24 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
- Centrally Alling Swf Within HTML
- Drawing An Image Centrally Whilst Rotating And Scaling
- Unhappy Adjusting Columns And Rows On Stage Resize, According To Stage.width.
- Stage.width && Stage.height Doesn't Work Anymore?
- Create Array On Stage, Mathematically Referring To Objects On The Stage
- Create Array On Stage, Mathematically Referring To Objects On The Stage
- Stage.width And Stage.height Not Matching Document Settings?
- Stage.height And Stage.width Erratic Values?
- F8 Movieclip Change On Stage Causes The Entire Stage To Dissapear
- External MC Loaded On Stage, I Can Press Buttons That Are On The Stage Through It...
- Stage.width, Stage.height, Add.Listeners Problem
- MX2004 -- Stage.height And Stage.width Different From Mac To Windows
- External MC Loaded On Stage, I Can Press Buttons That Are On The Stage Through It...
- Stage.width & Stage.height Problems
- MC Moves OFF Stage Left, Appears ON Stage Right?
- Flex Stage Overtakes Flash Stage
- Stage.height & Stage.width Return 0
- Scale Proportion Past Stage But Not Below Stage
- Stage.align And Stage.scale(X,Y) Algorithms
- Stage > Origin Issue When Resizing Stage
- Help With Stage.align/stage To Browser Re-sizing
- Moving An Object Thats Off The Stage Onto The Stage
- Stage.width, Stage.height
- Stage Width Vs. Stage Height
- Stage.width Stage.height Help
- Stage Resize To That Of External Swf Stage...
- Stage.scaleMode And Stage.stageWidth
- Drag From Outside Stage To Stage And Drop
- FullScreen One Element On Stage And Not The Whole Stage
- Stage Resize To That Of External Swf Stage...
- Define Certain Areas On The Stage As The Stage?
- Stage Resize To That Of External Swf Stage...
- [AS] Stage.width & Stage.height
- Stage.width & Stage.height
- Moving The Stage After Resizing - Or Moving All Objects On The Stage? Heeeelp
- Why Is "stage" Accesible But I Cant Access Things On Stage
- I Can't See Anything On The Stage During The Preloader Stage
- Resize Scroller To Stage.width, Need To Get The Stage.width Value
- "this" Returning Null, And Stage.width/Stage.height Returning 0 ?
- "this" Returning Null, And Stage.width/Stage.height Returning 0 ?
- Keeping Character On Stage Plus Keeping Moving Background With Character On Stage
- Keeping Character On Stage Plus Keeping Moving Background With Character On Stage
- Root, Stage And Stage "its All The Same To Me"
- Why Stage.root.addEventListener & Root.stage.addEventListener Both Work ?
- Stage
- HELP Off The Stage?
- Containing MC's Within The Stage
- Stage
- Stage Help
Centrally Alling Swf Within HTML
my front page (index) has flash used for the graphics etc but i would like this image centrally allined on all browsers. Its okay on safari but IE has it postioned left. Also is there any code i can put into the html document to make it auto resize to the viewers screen.
thanks all!
Drawing An Image Centrally Whilst Rotating And Scaling
Hi everyone,
This is my first post here; just trying to make the awkward transition from J2ME and C++ to AS 3.0! Things aren't going too badly so far, but I've stumbled across a problem with drawing a rotated image centrally whilst scaling it. I found that you can draw an image centrally by doing this:
target.x = -(width >> 1);
target.y = -(height >> 1);
...but if I scale and rotate the image then it doesn't get draw centred around target_x, target_y. I'm guessing this is where I'm going wrong:
target.x = target_x - (target.width >> 1);
target.y = target_y - (target.height >> 1);
I've copied and pasted the entire code below - any advice would be great, thanks for your time!
Cheers,
Mike.
/////////////////////////////////////////////////
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.Stage;
public class Target extends Sprite
{
private var target:Bitmap;
private var target_x:Number;
private var target_y:Number;
[ Embed ( source = "target.png" ) ] private var targetGFXClass:Class;
public function Target ( )
{
// instantiate embedded assets
target = new targetGFXClass( );
target.scaleX = 0.0;
target.scaleY = 0.0;
// attach target to display list
addChild( target );
}
// initialization, called after parent addChild
public function init ( ):void
{
target_x = Math.random() * stage.stageWidth;
target_y = Math.random() * stage.stageHeight;
// start step triggering based on enterframe event
addEventListener( Event.ENTER_FRAME , step );
}
public function step ( event:Event ):void
{
if (target.scaleX < 1)
{
target.scaleX += 0.1;
target.scaleY += 0.1;
}
else
{
target.rotation++;
}
x = target_x - (target.width >> 1);
y = target_y - (target.height >> 1);
}
}
}
Unhappy Adjusting Columns And Rows On Stage Resize, According To Stage.width.
Hey fello flashers,
what i'm trying to achieve can be seen here, at the FWA's website.
When you resize the browser window the thumbnails rows and columns adjust accordingly to fit.I've managed to attach the thumbnails correct when my enableButtons() function is called but i'm unsure how to approach resizing.
if anyone has encounted this problem before or can help, then pls do i'm a little confounded on this one.
thanks
cam
Stage.align = "TL";
var numberOfGalleries:Number = 20;
var thumbMarginX:Number = 163;
var thumbMarginY:Number = 109;
function init():Void {
enableButtons(numberOfGalleries);
resizeStage();
}
function enableButtons(numberOfGalleries:Number):Void {
currentRow = 0;
currentColumn = 0;
for (i=0; i<numberOfGalleries; i++) {
tracker = i;
thumbsDisplayer = this.createEmptyMovieClip("thumbsDisplayer_mc", this.getNextHighestDepth());
currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail._y = currentRow*thumbMarginY;
currentColumn++;
if (currentThumbnail._x>(Stage.width-(currentThumbnail._width + thumbMarginX))) {
currentRow++;
currentColumn = 0;
}
}
}
function resizeStage() {
var myListener:Object = new Object();
myListener.onResize = function(e:Object):Void {
//
}
Stage.addListener(myListener);
}
init();
Create Array On Stage, Mathematically Referring To Objects On The Stage
Ok what I want to do is create a set of small images on the stage and name them sequentially like you would an array, then refer to them mathematically in actionscript. I tried naming them as an array but it says that the name is reserved for the system or something. Does anyone know how to get an array of objects onto the stage, or have an idea of something else I could do to get the same effect?
Create Array On Stage, Mathematically Referring To Objects On The Stage
Ok what I want to do is create a set of small images on the stage and name them sequentially like you would an array, then refer to them mathematically in actionscript. I tried naming them as an array but it says that the name is reserved for the system or something. Does anyone know how to get an array of objects onto the stage, or have an idea of something else I could do to get the same effect?
Stage.width And Stage.height Not Matching Document Settings?
Ok, so I have no idea why this would be happening and its driving me nuts. I have my Flash movie size set to 960x650. However, when I trace stage.width and stage.height, I get:
950.05x630
Why in the world would this be happening? It's screwing up all the work I'm trying to put into positioning elements relative to the stage size. Thanks for any help!
Stage.height And Stage.width Erratic Values?
Hey folks,
I was wondering if it happens in all Flash everywhere, or just in mine:
When I trace Stage.height and Stage.width, I always get erratic values:
Stage.height gets me always 4 pixels less than real
Stage.height gets me always 104 pixels less than real
This, way if my stage has 760 x 400, it will return values 756 x 296.
Anybody knows why?
Thanks!
F8 Movieclip Change On Stage Causes The Entire Stage To Dissapear
I have my stage with a background picture.
On stage left are buttons, and on stage right I have a movieclip (mc_Preview).
When the user puts his mouse over each button I would like the movieclip to move to a different frame.
the problem is when the mouse moves over a button, i see the movieclip move but then the entire stage dissappears and turns a few shades of gray.
Does this sound familiar to anyone?
Any help would be greatly appreciated!
External MC Loaded On Stage, I Can Press Buttons That Are On The Stage Through It...
I'm used to AS3, and I don't have much experience in AS2. I'm trying to modify an older flash file done in AS2.
An external swf is loaded using this code...
ActionScript Code:
on(release) {
loadMovieNum("supplimental/external.swf", 500);
}
The problem is that even though this external movie covers the whole stage, My mouse can still "see" buttons that are on the stage, and I can click them. I don't want to be able to click the buttons through my external movie. Thanks for any help.
Stage.width, Stage.height, Add.Listeners Problem
Hi
i found the way yesterday to ensure my mc stays full screen. now i want to animate the same mc if i can in reaction to a button click.
not sure how this next step goes. do i need another addlistener to the background mc that im tweening ?
kindly check the .fla. to see what i mean.
its very rough cut but hopefully you can get the gist of it.
when the text button is clicked, the bg reverts to the top left of the screen.
thanks
-dj
MX2004 -- Stage.height And Stage.width Different From Mac To Windows
I have a really strange problem that is ruining my movie. I have set the size of the stage to 450px by 400px in the properties dialog. In my actionscript, I've got all kinds of things that rely on Stage.width. So, I developed everything in MX2004 on Mac, and everything worked swimmingly. So, I opened up the exact same file in MX2004 and everything is placed wrong on the stage. So when I did a trace of Stage.width, I got 940px, and a trace of Stage.height gave me a figure of 763 pixels. If I do the same traces on the Mac, I get what I expect, 450px for width and 400px for height. Does anybody have any ideas as to what might cause this kind of discrepancy?
Thanks,
John
External MC Loaded On Stage, I Can Press Buttons That Are On The Stage Through It...
An external swf is loaded using this code...
Code:
on(release) {
loadMovieNum("supplimental/external.swf", 500);
}
The problem is that even though this external movie covers the whole stage, My mouse can still "see" buttons that are on the stage, and I can click them. I don't want to be able to click the buttons through my external movie. Thanks for any help.
Stage.width & Stage.height Problems
Why is it when I use this script attached to an empty movie clip the box seems to always be short on the height side? The width is fine. See attached FLV.
frame.fla.zip
Thanks in advance for any feedback.
Code:
onClipEvent (load) {
this._x = 0;
this._y = 0;
this.moveTo(0, 0);
this.lineStyle(1, 0x000000, 100);
this.beginFill(0x000000, 0);
this.lineTo(Stage.width-1, 0);
this.lineTo(Stage.width-1, Stage.height-1);
this.lineTo(0, Stage.height-1);
this.lineTo(0, 0);
this.endFill();
}
MC Moves OFF Stage Left, Appears ON Stage Right?
i have an MC that is being moved left and right by the arrow keys. (no up or down movment)
i want to make it so when the MC is moved and disapers off stage left or right, it appears on the opposite side of the stage...
MC moves off stage right, comes on stage left.
MC moves off stage left, comes on stage right.
Belwo is my code that moves my MC, what do I need to add for the above action?
ActionScript Code:
var oldladyspeed:Number = 5;
stage.addEventListener(KeyboardEvent.KEY_DOWN, downHandler);
function downHandler(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.LEFT) {
oldlady.x -= oldladyspeed;
}
if(event.keyCode == Keyboard.RIGHT) {
oldlady.x += oldladyspeed;
}
}
THANKS
Flex Stage Overtakes Flash Stage
I'm loading a flex swf into a flash swf, and it seems that flex takes over the stage in quadrant 4, if you look at as a grid:
-------------|-------------
-------------|-------------
-------------|-------------
__________o__________
-------------| **********
-------------| *Quadrant*
-------------| ****4*****
And at the origin is the top left corner of the flex swf.
Now since the flex swf only takes up a small amount of Quadrant 4, when an Alert message from the flex swf comes up (from mx library) it looks up professional since it is not placed in the center of the application, but the center of quadrant 4.
Does anyone know, how to restrict stage access to only the predefined application width and height so the Alert message will be centered in the flex swf.
Thanks in advance,
Basil Al-Dajane
PS. worth mentioning, I'm using Flash CS3 and Flex 3.0, both running on ActionScript 3.0
Stage.height & Stage.width Return 0
First, hey there, cool forum. This is my first post...anyways...
I'm having what, I want to assume, is a common issue and there's something I'm missing here...I have a flash movie that works fine (that is Stage.height and Stage.width) return their proper values when the actual SWF is played in the flash player, however, when I put the movie into an HTML page and set it's height and width to 100%, Stage.width and Stage.height are 0 and my neato script breaks.
I realize I'm scaling the movie, but it seems to me that Stage.width and Stage.height should work regardless...and the fact it gives me 0 is even more odd, as though it's not working at all.
Scale Proportion Past Stage But Not Below Stage
This goes out to Scotty or any other guru floating around out here.
I need the image_mc movieclip in this .fla to scale to fit browser, however i need the image to scale in proportion. I would also need a listener of sorts that will NOT allow the image_mc movieclip to scale below the stage size of 1024 x 768.
Can anyone drop some science on me?
http://www.spent2000.com/scale_propo..._for_stage.fla
Thanks in advance.
- 400x5
Stage.align And Stage.scale(X,Y) Algorithms
Hello, I'm after a good way to take a image scale it to where:the image scale propotionately (image.scaleY == image.scaleX);
the image must scale to fit the browser, But.
the image must not leave empty areas of the stage exposed (upscale the image if needed to cover blank stage area exposed, which will clip off a end of the image and thats where Stage.align comes in)
the stage.align will help give scale orientation, meaning from what direction will the image scale. This is important since this can cause a few problems with centering of the image upon rescale and you also want to know what end is most likely to get clipped off in the event that the image needs to upscale to cover blank stage areas.
as I have it now
_imageHolder is a hypothetical image and stage is a reference to the stage.
I know this algorithm is not a best practice and it don't cover the stage completely. Any help would be great.
PHP Code:
if((_imageHolder.width >= stage.stageWidth) && (_imageHolder.height >= stage.stageHeight)){ if(_imageHolder.width >= stage.stageWidth){ _imageHolder.width = stage.stageWidth; _imageHolder.scaleY = _imageHolder.scaleX; }else if(_imageHolder.height >= stage.stageHeight){ _imageHolder.height = stage.stageHeight; _imageHolder.scaleX = _imageHolder.scaleY; } }else if((_imageHolder.width <= stage.stageWidth) && (_imageHolder.height <= stage.stageHeight)){ if(_imageHolder.width < stage.stageWidth){ _imageHolder.width = stage.stageWidth; _imageHolder.scaleY = _imageHolder.scaleX; }else if(_imageHolder.height < stage.stageHeight){ _imageHolder.height = stage.stageHeight; _imageHolder.scaleX = _imageHolder.scaleY; } } }
This event will be in a function that fires when the stage rescales or when the image loads.
Also what is a good idea to deal with the stage.align problems that can come up?
Stage > Origin Issue When Resizing Stage
Hey. Its 7:00am and Im dead tired looking for an answer to my noob question.
Basically I was wondering if someone could explain to me why the origin of the stage changes when performing a browser resize?? The thing is that when it is resized to a size larger than the original stage size the origin has negative values. On the other hand when I resize the stage to a size smaller than the original I get positive values for the origin. (Upper Left hand corner).
Ive tried setting the stage.align property to top left but i still get these crazy values and i was just hoping that someone could explain this behavior to me.
Too make matters even worse is that the results I get when previewing the movie in the IDE Flash Player is not even close to the results I get in the browser Flash Player. Could it have something to do with the fact that I recently installed Flash Player 10?
Id also like to take advantage of this thread to ask if it is possible to set the stage w/h to 100% via the swf metatag. Ive tried to do this but have been unsucesful.
Here is the link... which is not even close to what Im seeing when previewing in the Flash IDE. '
http://www.pixelbrigade.com
Help With Stage.align/stage To Browser Re-sizing
Hi Guys..
I wonder if you can help... I'm wanting to create a flash site that has a fluid layout.
I've attempted to follow various tutorials and looked through the books that I have, but at present I'm struggling.
I'm using CS3 on the Mac platform and I'm really quite new to actionscripting.
I want to create a page which has a "menu" hugging the top left hand corner of the browser, a "footer/heading" sitting at the bottom right (both with a slight margin from the edges of the browser window). Then once completed I will add a central area for the main content.
* Can I do this with the Stage.align coding and using "listeners?"
* Is there a particular stage size that works best for designing a site/layout like this?
* What I have attempted so far, is it actually resizing to the browser size at all?
Can anybody please help, I've asked around on a few other forums and as I said looked at tutorials but I can't seem to apply the coding to achieve the results that I want!
Thankyou in advance!
(I will post a link to what I have so far.. I just need to make a few amendments)
Moving An Object Thats Off The Stage Onto The Stage
For a Flash class thats coming up we need to do a little game. Now my idea is to make a GTA 1 style game. We have the car movements down but what i'm having trouble with is making the car stay centered and moving objects that arnt currently onto the screen onto the screen. EG Car is in the center (Always stays in the center) Car moves forward, the background (Road, buildings etc...)Move down the screen and new objects apear on top the screen and move downwards or right, left upwards depending on the direction the car is moving. Any help would be greatly appericated.
Stage.width, Stage.height
Does anyone know why the stage dimensions are coming out wrong. I have a movie set at 800 x 600. I do trace(Stage.width);
trace(Stage.height); and get 796 and 596. What's going on here? I have seen at least one other post with the same issue, but there were no responses.
Best regards...
Lance
Stage Width Vs. Stage Height
hello.
still looking how to maintain max. stage width and height. i have managed to achieve it on the width, but for some reason have been unable to do it for the height. that is, i have managed to make a line go from one side to the other (almost) but cant figure out how to do it on the vertical.
zbot is the horiz line at the botton
ztop for the one above
the problem, is for xleft (the vertical lineon the left)
i have included what i think to be the nearest code yet, and a fla.
any help, thanks a lot.
Code:
Stage.align = "LT";
Stage.scaleMode = "noScale";
bg._width = System.capabilities.screenResolutionX-20;
bg._height = System.capabilities.screenResolutionY-70;
bg.onResize = function() {
this._x = (Stage.width-this._width)/2;
this._y = (Stage.height-this._height)/2;
};
Stage.addListener(bg);
zbot._x = 62;
zbot.onResize = function() {
this._width = Stage.width;
};
Stage.addListener(zbot);
////
xleft._x = 270;
xleft.onResize = function() {
this._height = Stage.height;
};
Stage.addListener(zbot);
////
ztop._x = 62;
ztop.onResize = function() {
this._width = Stage.width;
};
Stage.addListener(ztop);
// get the content clip to stay fixed horizontally centred
content.onResize = function() {
this._x = (Stage.width-this._width)/2;
};
Stage.addListener(content);
// manually invoke the onResize events for the clips to start things off
bg.onResize();
zbot.onResize();
ztop.onResize();
xleft.onResize();
content.onResize();
Stage.width Stage.height Help
I have the main swf(main) which loads in another swf(loaded). The loaded swf looks at the main swf for the Stage.width and height.
Is there a way for the loaded swf to look at its own Stage.width and height and not main?
Stage Resize To That Of External Swf Stage...
Hi everyone, and thanks in advance for reading...
I am trying to make an online display application...with two views...standard view, and full screen view...
the standard view can be seen at www.expocadvr.com/temp/default.html
I have a main SWF file which contains a movieclip which the two external SWFs are being loaded into...
the difference between the two views is the size of the main vewing window...in the fullscreen version, the window takes up the whole browser window(with small margins) and I want this view to be scalable to the broswer so if the user changes the browser size, the window will resize as well...
In the standard view, the tools are visible on the left, and I do not want the movie to scale with the browser, I just want it to center on the browser...
how would I go about changing the stage size of the main movie to accomodate the two different stage sizes of the external swfs and at the same time have one scale and center, and the other only center...
please help.
Thanks,
Paul
Stage.scaleMode And Stage.stageWidth
What am I missing here? According to the docs:
Quote:
When the value of the scaleMode property is not set to StageScaleMode.NO_SCALE, the stageWidth property represents the width of the SWF file as set during authoring in the Document Properties dialog box. This means that the value of the stageWidth property stays constant as you resize the Flash Player window. This property cannot be set.
So stick this in a new FLA
ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, onResize);
function onResize(e:Event=null):void
{
trace( stage.stageWidth );
}
and the traces are of different values. According to the docs, this shouldn't be happening. What's going on? Did I miss something little?
Drag From Outside Stage To Stage And Drop
Hey folks,
I've been banging my head on this certain question for ages now. Is it possible to drag something, that is outside Flash, into Flash and drop it on the Stage and then read what it is? And then of course, I mean in the Player - not the authoring tool itself. The idea is to be able to pick, for instance, the URL from the browser and drop it onto the application and then the app can read the URL and do something with it. Same for other pieces of intel: bookmarks, pieces of text, notes, maybe images and so on. Issue like this is fixed in Java within a jiffy, but is it also possible in AS3? Anyone experience with this stuff? I'd be happy with any help, and thanks for reading!
- lwmxynedtodth
FullScreen One Element On Stage And Not The Whole Stage
Hello Smart People.
Imagine a stage. Imagine a series of images (smaller than the stage and spread out evenly) that have been loaded into a bunch of "swfContainer" movieClips via the Loader Class. Is it possible to make one of these "swfContainer" movieClips go FullScreen and nothing else (i.e. not the entire stage, just the _mc that one of these images sits in)?
Would be cool if there was a way. Any insights?
-ropeGun
Stage Resize To That Of External Swf Stage...
Hi everyone, and thanks in advance for reading...
I am trying to make an online display application...with two views...standard view, and full screen view...
the standard view can be seen at www.expocadvr.com/temp/default.html
I have a main SWF file which contains a movieclip which the two external SWFs are being loaded into...
the difference between the two views is the size of the main vewing window...in the fullscreen version, the window takes up the whole browser window(with small margins) and I want this view to be scalable to the broswer so if the user changes the browser size, the window will resize as well...
In the standard view, the tools are visible on the left, and I do not want the movie to scale with the browser, I just want it to center on the browser...
how would I go about changing the stage size of the main movie to accomodate the two different stage sizes of the external swfs and at the same time have one scale and center, and the other only center...
please help.
Thanks,
Paul
Define Certain Areas On The Stage As The Stage?
Is it possible to define only certain areas of the stage as the actual stage? As to say if I have the following code:
stage.addEventListener(MouseEvent.CLICK, burnIt);
function burnIt(event:MouseEvent):void {
timer.start();
timer2.start();
}
Is it possible to define only a section of the stage as clickable? Maybe within a mask? Also from the code above, how do a stop the timer with another click?
Thanks
Stage Resize To That Of External Swf Stage...
Hi everyone, and thanks in advance for reading...
I am trying to make an online display application...with two views...standard view, and full screen view...
the standard view can be seen at www.expocadvr.com/temp/default.html
I have a main SWF file which contains a movieclip which the two external SWFs are being loaded into...
the difference between the two views is the size of the main vewing window...in the fullscreen version, the window takes up the whole browser window(with small margins) and I want this view to be scalable to the broswer so if the user changes the browser size, the window will resize as well...
In the standard view, the tools are visible on the left, and I do not want the movie to scale with the browser, I just want it to center on the browser...
how would I go about changing the stage size of the main movie to accomodate the two different stage sizes of the external swfs and at the same time have one scale and center, and the other only center...
please help.
Thanks,
Paul
[AS] Stage.width & Stage.height
Is it possible to dynamically adjust the Stage.width / Stage.height properties. As an example, my author time stage settings are at 700 by 500. Based on what I pulled from database, is it possible to resize the dimensions of the root swf based on the content which is tabulated into the data ?
Stage.width & Stage.height
Can someone please look at my code and point out the obvious where I cannot see?
Everything seems to be working correctly with the exception of the Stage.width and Stage.height properties the pictures float off the stage.
Code:
import mx.transitions.Tween;
var photoScale = 30;
var photoAlpha = 60;
var clipWidth = 380;
var clipHeight = 300;
var flyerInit:Object = Object();
randomize = function (min:Number, max:Number):Number
{
var range = max - min;
var resultRandom = Math.random() * range;
resultRandom += min;
return resultRandom;
};
flyerInit.onEnterFrame = function()
{
this._x += this.speedX;
this._y += this.speedY;
this._rotation += this.speedR;
if (this._x < 0 || this._x > clipWidth)
{
this.speedX *= -1;
this.speedR *= -1;
}
};
if (this._y < 0 || this._y > clipHeight)
{
newFlyer.speedY *= -1;
newFlyer.speedR *= -1;
}
flyerInit.onRelease = function()
{
if (!this.select)
{
this.speedX = 0;
this.speedY = 0;
this.speedR = 0;
var locxTween:Tween = new Tween(this, "_x", non, this._x, clipWidth / 2, 1, true);
var locyTween:Tween = new Tween(this, "_y", non, this._y, clipHeight / 2, 1, true);
var rotateTween:Tween = new Tween(this, "_rotation", non, this._rotation, 0, 1, true);
var scalexTween:Tween = new Tween(this, "_xscale", non, this._xscale, 100, 1, true);
var scaleyTween:Tween = new Tween(this, "_yscale", non, this._yscale, 100, 1, true);
var alphaTween:Tween = new Tween(this, "_alpha", non, this._alpha, 100, 1, true);
var newDepth = this._parent.getNextHighestDepth();
this.swapDepths(newDepth);
this.select = true;
}else {
this.speedX = randomize(-2, 2);
this.speedY = randomize(-2, 2);
this.speedR = randomize(-2, 2);
var scalexTween:Tween = new Tween(this, "_xscale", non, this._xscale, photoScale, 1, true);
var scaleyTween:Tween = new Tween(this, "_yscale", non, this._yscale, photoScale, 1, true);
var alphaTween:Tween = new Tween(this, "_alpha", non, 100, photoAlpha, 1, true);
this.select = false;
}
};
for (var i:Number = 1; i < 9; i++)
{
var newPhoto:String = "p" + String(i);
var newName:String = "flyer" + String(i);
var newDepth:Number = this.getNextHighestDepth();
var newFlyer = this.attachMovie(newPhoto, newName, newDepth, flyerInit);
newFlyer._xscale = photoScale;
newFlyer._yscale = photoScale;
newFlyer._alpha = photoAlpha;
newFlyer._x = Math.random() * clipWidth;
newFlyer._y = Math.random() * clipHeight;
newFlyer.speedX = randomize(-2, 2);
newFlyer.speedY = randomize(-2, 2);
newFlyer.speedR = randomize(-2, 2);
newFlyer.select = false;
}
please help
thanks,
tmo
Moving The Stage After Resizing - Or Moving All Objects On The Stage? Heeeelp
Hello! I'm in dire need of help!
I've been forced to resize the stage of my movie but as the stage is expanded to the right and down everything ends up in the wrong place. So I wonder:
Is there any way to move the stage rather than the contents thereon?
or
is there a way to move all the content on all layers and even all scenes simultaneously?
or
is there a way to expand the stage equeally on all sides rather than just right and down?
THANKS ALOT TO WHOEVER COULD HELP ME!
Freddy D, Stockholm, Sweden
Why Is "stage" Accesible But I Cant Access Things On Stage
I have placed a textfield on the stage and in a class however cannot access this textfield but I can access simply stage
eg trace(stage) but not trace(stage.debug)
1119: Access of possibly undefined property debug through a reference with static type flash.display:Stage.
if i declare it in the class like so
private var stage:Stage; or public var stage:Stage;
I get other errors.
Im converting to 3 from 2 and the new error pessages are harder to decipher.
In fact just scripting in the first frame produces the same errors, so it not the class.
thanks
I Can't See Anything On The Stage During The Preloader Stage
Can somebody download my flash file and explain why I can't see anything on the stage during the preloading phase?
The file is located at home.earthlink.net/~i2x/question.zip (The upload file feature in this forum isn't working -- at least right now. )
It's a Flash MX file. But the preloader is basic Flash 4 type. Even when I use the the preloader in this A.S. tutorial I can't see anything on the stage.
Resize Scroller To Stage.width, Need To Get The Stage.width Value
hey all. I'm battling this problem and have finally caved for help. I can't seem to get the mask_mc._width to return the acurate value. at a fixed stage size the scroller seems to work fine, but changing the mask_mc.width to a variable set to Stage.width doesn't. I know the Stage.width property is read only, but does that mean i cant get a value from it. Anything i am missing? suggestions? I suppose this would be similar to resizing a scrollbar to full height. Thanks ahead of time.
mask_mc._width = Stage.width;
stageListener = new Object();
stageListener.onResize = function() {
mask_mc._width = Stage.width;
}
Stage.addListener(stageListener);
var scrollSpeed = 0.2;
var maxScrollOffset = 16;
function setContentTarget(scrollPercent) {
if (scrollPercent<0) scrollPercent=0;
if (scrollPercent>1) scrollPercent=1;
this.targetY = this.mask_mc._x - scrollPercent * ((this.contentMC._width+20)-this.mask_mc._width);this.onEnterFrame = setContentY;
}
function setContentY() {
this.contentMC._x += (this.targetY-this.contentMC._x) * scrollSpeed;
if (Math.abs(this.targetY-this.contentMC._x) < 1){
delete this.onEnterFrame;
}
}
this.onMouseMove = function() {
if (this.mask_mc.hitTest(_root._xmouse, _root._ymouse, false)) setContentTarget((this.mask_mc._xmouse-maxScrollOffset)/(this.mask_mc._width-2*maxScrollOffset));
}
"this" Returning Null, And Stage.width/Stage.height Returning 0 ?
I am sure this has been answered or partially answered before, however, search limitations prevent the use of the word 'this' pretty much, so hoping someone will answer this for me.
For some weird reason, tracing (or using) a 'this' will return null in _root. Now, I could simply replace all instances of 'this' with _root, however, if I ever choose to embed this flash movie i am working on into another, it will mess everything up. Any help here would be appreciated.
Also too, I've been having issues with Stage.width and Stage.height. I currently have Stage.scaleMode = "noScale"; and for whatever reason, the Stage.width and Stage.height are returning 0. I was under the impression that, with noScale, Stage.width and Stage.height returned the actual size of the movie displayed in the browser. Does anyone know why this is returning 0? Could this be related to my 'this' == null problem?
Any help is appreciated.
"this" Returning Null, And Stage.width/Stage.height Returning 0 ?
I am sure this has been answered or partially answered before, however, search limitations prevent the use of the word 'this' pretty much, so hoping someone will answer this for me.
For some weird reason, tracing (or using) a 'this' will return null in _root. Now, I could simply replace all instances of 'this' with _root, however, if I ever choose to embed this flash movie i am working on into another, it will mess everything up. Any help here would be appreciated.
Also too, I've been having issues with Stage.width and Stage.height. I currently have Stage.scaleMode = "noScale"; and for whatever reason, the Stage.width and Stage.height are returning 0. I was under the impression that, with noScale, Stage.width and Stage.height returned the actual size of the movie displayed in the browser. Does anyone know why this is returning 0? Could this be related to my 'this' == null problem?
Any help is appreciated.
Keeping Character On Stage Plus Keeping Moving Background With Character On Stage
Im in the process of creating a superman game.. and i right now have him in walking mode .. i created him which is superman_mc . which has his waking animations etc.. inside and i have created a background mc which is level1_mc which basicly moves along with superman as he walks. .the problem i am getting is keeping the back ground from moving off the stage and superman from going off the stage i can keep superman on the stage and in one place on the stage with the code i have now but the background still moves off.. here is the code i have :
stop();
//Superman walk & flying movements
fly = "off";
_root.onEnterframe = function() {
if (Key.isDown(70)) {
_root.superman_mc.gotoAndPlay(4);
_root.superman_mc._y -= 17;
fly = "on";
}
if (_root.superman_mc, hitTest(_root.right_mc)) {
_root.superman_mc._x = 700;
}
//moves superman right
if (Key.isDown(39) & fly == "off") {
_root.superman_mc.gotoAndPlay(3);
_root.superman_mc._x += 17;
_root.level1_mc._x -= 17;
direction = "center";
//makes superman face foward
} else if (direction == "center") {
_root.superman_mc.gotoAndStop(1);
}
//moves superman left
if (Key.isDown(37) & fly == "off") {
_root.superman_mc.gotoAndPlay(2);
_root.superman_mc._x -= 17;
_root.level1_mc._x += 17;
direction = "left";
} else if (direction == "left") {
_root.superman_mc.gotoAndStop(1);
}
};
whats happening is that the background keeps going but since i have it setup to move along with superman .. if anyone can help thank you alot..
-rob-
Keeping Character On Stage Plus Keeping Moving Background With Character On Stage
Im in the process of creating a superman game.. and i right now have him in walking mode .. i created him which is superman_mc . which has his waking animations etc.. inside and i have created a background mc which is level1_mc which basicly moves along with superman as he walks. .the problem i am getting is keeping the back ground from moving off the stage and superman from going off the stage i can keep superman on the stage and in one place on the stage with the code i have now but the background still moves off.. here is the code i have :
stop();
//Superman walk & flying movements
fly = "off";
_root.onEnterframe = function() {
if (Key.isDown(70)) {
_root.superman_mc.gotoAndPlay(4);
_root.superman_mc._y -= 17;
fly = "on";
}
if (_root.superman_mc, hitTest(_root.right_mc)) {
_root.superman_mc._x = 700;
}
//moves superman right
if (Key.isDown(39) & fly == "off") {
_root.superman_mc.gotoAndPlay(3);
_root.superman_mc._x += 17;
_root.level1_mc._x -= 17;
direction = "center";
//makes superman face foward
} else if (direction == "center") {
_root.superman_mc.gotoAndStop(1);
}
//moves superman left
if (Key.isDown(37) & fly == "off") {
_root.superman_mc.gotoAndPlay(2);
_root.superman_mc._x -= 17;
_root.level1_mc._x += 17;
direction = "left";
} else if (direction == "left") {
_root.superman_mc.gotoAndStop(1);
}
};
whats happening is that the background keeps going but since i have it setup to move along with superman .. if anyone can help thank you alot..
-rob-
Root, Stage And Stage "its All The Same To Me"
what is the difference to these other than same will work in some situations and some wont. i just finished migrating a script from 2.0 took me 2 hours.
there was a place where Stage dint work but root did.
another thing... can i load an html page into the code to get some info? any security issues with that?
Stage
I am very new to Flash and cannot get past the very first hurdle. I have set the stage to 640 X 480. I am under the impression that everything that I do on the stage will be visible and everything off stage will not be visible. This is not the case when I test the movie. I can still see objects that I have off the stage. It works fine in Director but I can't get it right in Flash.What am I doing wrong? Thanks in anticipation of your help.
HELP Off The Stage?
The problem- there is a symbol that is so large that it goes off the end of the symbol stage (not the movie stage). is there a way to adjust this size or otherwise access the hidden content without moving it?
Containing MC's Within The Stage
http://www.blookie.com/test/bubbles.htm
I have this script (below). It makes a MC called bubble_mc duplicate itself and then 'float' in random directions all over the screen.
I need to constrain them to my 800*600 stage. That way, if they randomly go to the edge they will get kicked back out again.
Also, I have a script that will cause a MC (needle_mc.tip_mc) to 'pop' the bubble when it touches (via hitTest). I would like for the bubbles to duplicate again for each bubble popped. In other words, if I have 25 bubbles floating around, when you pop one, another will be created so there is always 25 bubbles.
Also, is there a way to make this more effeciant? I know there is a way to
unLoad the unused script possibly, but don't know how.
How do I alter the script to do this?
Thanks.
// this enables drag on the button movie clip
needle_mc.onPress = function() {
this.startDrag();
};
// this enables drop on the button movie clip
needle_mc.onRelease = function() {
this.stopDrag();
};
// sets onRelease to onRelease AND onReleaseOutSide
needle_mc.onReleaseOutside = needle_mc.onRelease;
// creates new mc's and makes them move randomly
bubble_mc.onEnterFrame = function() {
this.xpos += Math.floor(Math.random()*3)-1;
this.ypos += Math.floor(Math.random()*3)-1;
this._x += this.xpos;
this._y += this.ypos;
// this makes the tip of the needle make the bubble pop
if (this.hitTest(needle_mc.tip_mc)) {
this.unloadMovie();
}
};
// Duplicate the movie clip many times
for (i=3; i<=10; ++i) {
bubble_mc.duplicateMovieClip("bubble"+i+"_mc", i, bubble_mc);
}
Stage
Is there a way of making objects that leave the stage become invisible even if the scale of the movie is altererd? Ive only been able to do it creating a big black frame all around the stage.
Stage Help
what is a good stage size for a one page site. I need to know what size will fit well in a browser without any scrolling up or down. I was thinking that it sould be in a scale of 8/6 like moniters are but im not shure
|