Actionscript 3.0 :: Scale DisplayObject Based On Visible Bounds
Nov 5, 2010
I've been banging my head trying to figure out how to get this to work with no success... I have a class that extends MovieClip which loads a large image into it. This image has a mask applied to it to only display a specific section of the image. I need to be able to scale this MovieClip based on it's visible width & height while maintaining it's proportions.
I'm currently using Collin Moocks' approach (see it here:[URL]) to get the visible width and height of the movieclip, but I can't figure out how to get it to scale correctly based on those dimensions... Preferably I'd like to be able to set it's visible scaleX & scaleY properties similar to how you currently set the scaleX & scaleY, (i.e. movieclip.visibleScaleX = 1.5).
View 2 Replies
Similar Posts:
Jun 24, 2005
i have a container that is 100 x 100 and i have various symbols of different shapes and sizes (states for a U.S. map) that i am loading into that box and need to resizesome are bigger, some are smallerow to scale them proportionately larger or smaller depending on their size relative to the container.here's what i have so far
Code:
attachMovie(_root.curState, "curState", 100, {_x:25, _y:15});
widthBound = 100;
[code].....
View 3 Replies
Mar 3, 2009
I want to know which DisplayObject that is visible atposition x,y. Unfortunately, hitTestPoint returns true even ifanother DisplayObject lies above and blocks all visibility. Forexample:
View 7 Replies
Nov 6, 2009
For example I have a hierarchy of movie clips. mc1 is a child of mc, and mc2 is a child of mc1. Turns out that when I set
[Code]...
View 4 Replies
Aug 17, 2011
When I add a DisplayObject to a DisplayObjectContainer (e.g. a Sprite to a Sprite) in a function, it seems that the DisplayObject is actually added not immediately, but after finishing the function.[code]...
View 4 Replies
Aug 17, 2011
When I add a DisplayObject to a DisplayObjectContainer (e.g. a Sprite to a Sprite) in a function, it seems that the DisplayObject is actually added not immediately, but after finishing the function.
See this example:
Code:
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
[Code].....
So we have a simple green button, and when it is clicked, there's a red Sprite constructed and added to the stage. But actually the red Sprite isn't visible until the onClick() function has been fully executed.
Why is that and what can I do for the red Sprite to be visible immediately?
Is there some (for the developer invisible) global paint() or update() function, that is not executed until some stack is fully executed or something?
View 2 Replies
May 2, 2010
The following is entirely a math question. As we know, PerspectiveProjection delivers perspective transformations in 3D represented by the interdependent values of fieldOfView and focalLength according to the following formula:
focalLength = stageWidth/2 * (cos(fieldOfView/2) / sin(fieldOfView/2)
Q: How to get the visible on-screen size of the DisplayObject (Cube on the above-linked image) to which PerspectiveProjection has been applied? A more thorough description and illustrative code on the issue in ActionScript 3 lacks functionality for visible bounds of DisplayObject.
View 1 Replies
Jul 16, 2009
I animate a DisplayObject with a Motion XML (exported from Flash). The first time I apply a motion to it, everything works fine. The second time I apply a motion, the position / scale is reset to what it was before I first applied a motion. How can I keep the transform of the DisplayObject after a motion is played when I want to play a new motion ? I want the DisplayObject to start from where it was at the end of the first motion.Here's the code I use:
private function animate(motionXML:XML, target:DisplayObject):void
if(!animator)animator = new Animator(motionXML, target);
// Add event listerners
[code].......
View 5 Replies
Nov 28, 2009
S there any way filters applied to a DisplayObject (drop shadow, glow, bevel) can scale relatively with the parent (the DisplayObject it is inside)?And what about other properties like .distance for drop shadow?For example... If I have a 100px rectangle with a 10px glow inside a container object, and I set scaleX/scaleY of the container to .1, I want the glow to inherit the scale change from the parent (1/10th the size) just as the display object does that the filter is applied to.Instead, if you try this, you will see the glow stays at 10px no matter what scale the filter target or the container is transformed by.Pseudocode example (steps to reproduce),
1) create a sprite called _myOuterSprite on stage at scaleX = scaleY = 1
2) create a sprite called _myInnerSprite inside _myOuterSprite at scaleX = scaleY = 1
3) draw 100px rectangle into _myInnerSprite
4) apply 10px glow to _myInnerSprite
5) transform scale of _myOuterSprite to .1
Result:
- child sprite (rectangle) scales to 1/10th the size
- glow stays the same size
How can I make it so that glow scales to 1/10th as well?
...without capturing and scaling bitmap data
...without losing interactivity on objects
...in a way that would work visually for every filter, not just glow (drop shadow has distance property too, etc)
View 7 Replies
Nov 28, 2009
(i'm using flashdevelop / flex sdk)IS there any way filters applied to a DisplayObject (drop shadow, glow, bevel) can scale relatively with the parent (the DisplayObject it is inside)?And what about other properties like .distance for drop shadow?
For example... If I have a 100px rectangle with a 10px glow inside a container object, and I set scaleX/scaleY of the container to .1, I want the glow to inherit the scale change from the parent (1/10th the size) just as the display object does that the filter is applied to.Instead, if you try this, you will see the glow stays at 10px no matter what scale the filter target or the container is transformed by.Pseudocode example (steps to reproduce),
1) create a sprite called _myOuterSprite on stage at scaleX = scaleY = 1
2) create a sprite called _myInnerSprite inside _myOuterSprite at scaleX = scaleY = 1
3) draw 100px rectangle into _myInnerSprite
4) apply 10px glow to _myInnerSprite
5) transform scale of _myOuterSprite to .1
Result:
- child sprite (rectangle) scales to 1/10th the size
- glow stays the same size
How can I make it so that glow scales to 1/10th as well?...without capturing and scaling bitmap data ...without losing interactivity on objects...in a way that would work visually for every filter, not just glow (drop shadow has distance property too, etc)
View 4 Replies
Jan 12, 2010
Has anyone got any alternatives to what Colin Moock has coded to GET VISIBLE WIDTH/HEIGHT OF A DISPLAY OBJECT in ActionScript 3? That esp. in perspective of DisplayObjects that have 3D transforms applied and visible dimensions of which you need to consider for a calculation.
View 2 Replies
Mar 4, 2009
Is there a way to adjust the rasterising of a vector based displayobject?
my problem is this: I create a textfield for example, and after moving it to z = -400 the whole text will look horrible (just like a low quality jpeg or so) as it comes closer to the viewport. I already know the vector shapes gets rasterized as soon the z value is set but there should be at least a way how it is done!?
View 2 Replies
Jan 17, 2010
Ive probably ran into some code like this before. just cant remember where. I have 2 display objects on my stage. One is rotating and the other is positioned 90 degrees from the rotating object. As the object rotates, the other object adjusts its x and y positioning from the rotating object..
If this doesnt make sense, then let me explain what I am trying to do. I have a spaceship in my flash game. this ship has 2 torrets siting on the left and right wing. as the ship turns, the torrets need to remain on the wings.
View 2 Replies
Aug 23, 2009
I have a SendData class that sends form info to a php script. It is a static class that does not extend anything. I want to be able to dispatch an event if there is an error, or when it gets info back from the server. I have a custom event class that I have been using to dispatch events like this, but I have only used that in displayObject extended classes.The problem is, it seems like something has to be a displayObject based class to dispatch events. I know there must be a way to do this, but I'm having trouble finding it in searches.
View 2 Replies
Jan 19, 2010
I have airplanes that are flying past the screen from a top down view. when the air planes crash, I scale them down to make it appear as if they are falling closer to the ground and farther away from the screen. I have turrets on these crafts as well. they are seperate objects from the air plan. I scale them down as well. The only problem is they dont reposition correctly. they stay in their x and y positions even though they are being scaled it looks as if they are being pulled away from the air plane. is it possible to reposition them correctly based on the size on the object they sit on (i.e. the air planes)
View 1 Replies
Feb 7, 2007
I would like to scale a movie clip based on how close the mouse gets to it, but flash slows when there are a ton of these. I'm looking for a new method
onMouseMove = function(){
var dx:Number = this._x - _parent._xmouse;
var dy:Number = this._y - _parent._ymouse;
[Code].....
View 1 Replies
Jun 26, 2007
I'm looking to create a rotating set of images, simulated to look 3D... that can rotate either left or right, reactive to someones mouse location.
The path of the images would look like a flat oval, and as the images came to the forefront, they would be at full scale, have the lowest position (high _y), have the highest depth (appear in front of everything else) and be dead center _x.
As they slide left or right, they would reduce everything by a relative 50% to the final shift (scale, _y, and depth) until they got to the end, moving in an upward arc following the oval path. When they got to the end, and kept rotating beyond (move in the opposite _x. but appear to follow the flow of the arc), continuing to decrease in scale, _y, and depth.
View 1 Replies
Oct 26, 2010
I would like to be able to quickly check if a given DisplayObject is a descendant (not in the inheritance sense - ie. child, grandchild, great-grandchild, great-great-grandchild, etc.) of another DisplayObject. There doesn't seem to be a native way to do this and I can only think of two ways to achieve it: Create the mother of all nested loops. Seems a bit, I dunno, wrong? Dispatch a bubbling event at the 'child' and check if the potential 'parent' receives it.
[Code]...
View 2 Replies
Sep 28, 2011
My question is: Set parentSprite.visible = false will make all children in parentSprite all invisible, right? And is there any way to just make parentSprite itself invisible without effecting it's children?
View 2 Replies
Aug 8, 2010
I want to click on an object and make it appear and disappear. As the object is rectangular, I figured putting a white button the same size on a white background on a layer underneath the object would do this, but I can't seem to make it happen.I'm a complete novice, frustrated as I've been trying to achieve this all day and I'm sure it should be pretty simple, but could you give me the idiots guide. I know how to name an instance, make an object, script in actions on a separate layer. I would like to draw the button myself and give it an instance rather than drag it off the button component (as I can't work out how to make the component button white, change its size etc.!)
View 5 Replies
Apr 1, 2009
Code:
my_Dyn_Txt1._visible = false
cb1.onRelease=function()[code]....
When the checkbox (cb1) is clicked the "my_Dyn_Txt1" is visible. The problem I'm having is - when I move forwad and back in my frames the checkboxes which were clicked are not visible due to
Code:
my_Dyn_Txt1._visible = false
How can I make ("my_Dyn_Txt1"), a clicked checkbox STAY VISIBLE even after I move forwad and back in my FLA frames?
View 11 Replies
Mar 8, 2007
Scenario: main moveiclip with 4 other clips in it. I want the rolledover clip to scale up and all the others to scale down and blur.
Question: What is the most effiecent way to code this. Would it be a "for in loop"? I am trying to minimize the code and would rather not use a whole bunch of if then statements.
View 3 Replies
Feb 19, 2010
I want my flash content to scale when I scale my browser window.
View 5 Replies
Jan 14, 2006
How can I convert the current scale of the instance to 100% so I can easily "visualize" and manage the instance when I modify its scale? Here's the actionscript, it works, but I just want the temp._xscale and temp._yscale to be in percentages, not real numbers.
Code:
USflag.onMouseDown = function ()
{
var temp = USflag;
onEnterFrame = function ()
[code]....
One last thing, what's the tag you have to put that is designed for boxing actionscripts? I'm suing [ code ][ /code ]
View 1 Replies
Mar 4, 2010
I want to make a little thing pop up when I put press a button... Would the best way to do this by doing a - movieclipname._visible = true/false
View 3 Replies
Sep 7, 2010
Okay, this should be relatively easy but I'm running into errors. My main character is visible in the beginning of the game (where the main menu is) and because I coded it so that all of the enemies don't spawn unless the main character is visible, the enemies spawn too. As a result, if you stay at the main menu for long enough, the score continues to go up, the health goes down when enemies attack, etc.
View 1 Replies
Mar 30, 2011
when the video reaches 1 minute, a button appears. is there a way to hide the button again if the user uses the seek bar to go back to the 30 second (or any time before 1 minute) point?
View 2 Replies
Dec 4, 2009
My Flash image will not scale.if you zoom in, it gets chopped up. if you zoom out, it has a big blank area.What should I change in order to have this Flash image scale just like the rest of the site? [URL]It is the Flash in the center.
View 1 Replies
Mar 3, 2009
I opened up the NY Times homepage, and they have this giant Apple addvertisement that has animations over the entire top half of the page, outside the area occupied by the swf.
View 1 Replies
Nov 10, 2011
Although I put _x = player._x etc. code in an onEnterFrame function the masking mc is moving without the player
You see...the player is held within some borders. When cornered and then hit, the mask moves according to how it would move normally, but without the player (because he is held in place by some borders)...
Also, if I don't have a problem but I'm missing a crucial piece of code,
code on masking mc
ActionScript Code:
stop();
this._x = _root.player._x;
this._y = _root.player._y;
radiance = 180 / Math.PI;
[Code]...
View 1 Replies