Actionscript 3 :: Display Centre MovieClip - Flex4?
Mar 6, 2011How to have that movieClip created to be created at the centre of the screen?
View 1 RepliesHow to have that movieClip created to be created at the centre of the screen?
View 1 RepliesJust a quick one. Using AS3, how would I ensure that a movieClip always stays in the centre of the stage on resize?
View 1 RepliesI'm trying to drag & rotate a planet so it spins around with the mouse -instance name: PlayerThe code works really well but it doesn't seem to rotate around the centre, instead it rotates from the top left corner.I'm quite a noob at as3 so I'm not quite sure where I've gone wrong with my code to be able to fix this. Do I need to specify the dimensions of the stage or the planet? I have altered the Stage from the the default 550 x 400 (if this could be the problem).
ActionScript Code:
import flash.events.MouseEvent;
import flash.events.Event;
[code].....
I'm trying to get my new character system working with my fairly simple physics system. I have code at the bottom of the page which demonstrates my collision function. The most important line, which I've bolded, is:
Code:
currentPlayer.y = hitBlock.y - ((hitBlock.height * 0.5) + (avatar.height * 0.5)) ;
I wrote this myself, all logic dictates that it should work. We start with the position of the centre of the block. We add half of it's height, to reach the top surface of the block. And then we add half the avatar's height, which should give the exact point to put him at so that his feet touch the top of the block. This code should be able to account for any arbitrary heights of block or avatar. But it's not working, my avatar is stuck just a little bit inside the block.As far as I'm aware, my math is perfect. So the only source of the problem I can think of is in the objects themselves. I'm not fully sure what the registration point is - logic would dictate that it's the recognised root point of the object, and when I tell an object to go to a coordinate, I would guess it's moved so that point rests exactly on the coords.I'm not entirely sure how to change it though.When I look at my movieclip in edit mode, it look like this.
The image has been downscaled so it's tricky to see the details, but I want to draw attention to the fact that there's three points of interest on it. Around the middle of the bounding box is a white circle,I think that's the registration point. A bit above that, on the figure's upper torso, is a crosshair. And to the topleft of the bounding box, just outside of it, is a second crosshair.What's also interesting is that when I deselect the movieclip, the white circle and the second crosshair (outside the BB) vanish. But the one on his chest stays put.If I move the movieclip, all three of the above things go with it. I can select the circle and drag it around, but not the crosshairs.my collision code:
Code:
//if main hits a block, then stop jumping
//this loop will check a hit test with any block
for(var i:int = 0;i < world.blockHolder.numChildren; i++)[code]............
I posted a question regarding how to make a ladybug move around the screen and I managed to make a class that loaded a ladybug png then using a timer moves the bug around the screen...
but I have a huge problem...this has been bugging me all day and cannot find a solution...
The ladybug moves around the screen but rotates towards the moving direction before moving. The problem is that the ladybug is rotating at 0,0 axis and not at the centre of the movieClip. Is there a way to offset the registration point so that the ladybug rotates centred?
[Code]...
package {
public class priyan {
public var a:String = "priyan";
public var b:String = "bhagavath";
public function method():void {
trace(a);
trace(b);
The above script, i got it from one of the ActionScript 3.0 book. i just work it out in flash. But it shown error 5000: The class 'priyan' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
[Code]...
I try to load an swf in my flex 4 project using the following line of code: <mx:SWFLoader id="game_swf" source="demo.swf" complete="init()" /> the demo.swf file is another project i created using flex 4. the problem is that when i run the application i see only the loading bar of the demo.swf flash file and nothing else. if i try to load a different swf file (for a example a game i downloaded), it loads just fine.
View 1 RepliesI was wondering if there is a shortcut so i can always set a MovieClip to display at the tippy top of the display list?
Also i understand that WebViewLayer will always display above the display list.
I'm currently working on editing the pages on my website but for some reason these errors are apearing. Also some of the text that should be on the .swf disapears. Any help will be apreciated
This is error I am getting:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::SimpleButton@40692fa1 to flash.display.MovieClip.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
[code].....
i have a Tweener question....here is the lib..so here is the error i get?
## [Tweener] Error: [object Loader] raised an error while executing the 'onComplete'handler.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@2035d1c1 to flash.display.MovieClip.[code].....
and here is why:
Code:
import caurina.transitions.*;[code]....
i tryed to use just the loaders...not working..its just for mcs i think...
For my project I need to copy the graphics of a Movieclip with all of its children without copying anything else into a second Movieclip. I cannot use the Bitmap classes because I need the graphics to be displayed as a vector and I cannot use a method that simply copies the clip by calling the instructor ie:
var copy:MovieClip = clip.constructor. Is there any way to copy only the display portions of a clip into another Movieclip without turning it into a bitmap?
how i might use a movieclip as a rollover in Flash to display another movieclip?
Simple as...
If i could be re-directed either, that'd do...
I want to take screenshot of a movieclip and then display that screenshot in other movie clip.I dont want to save the screenshot so i dont think i need to use some server side scripting like Php....i just want to display the screenshot in other movie clip.
View 13 RepliesI have a MovieClip called chipmovie which I have exported to a class method called ChipMovie, when I try and add it to another movieclip, for some reason it doesn't display.
I have checked Export for ActionScript and Export in Frame 1.The code that adds it to the MovieClip is as follows:
public function addChip(chip:Number)
{
var newChip:ChipMovie = new ChipMovie();[code].....
In the output it says:
init y = -151 height is 0
for all the ChipMovie objects I try to add.
I have multiple points on a Google map that i need to pinpoint.How would i find the two points that are farthest away from each other and get my map center an zoom accordingly?[code]Just copy and paste into root time line to test
View 1 RepliesI have seen a couple of flash movies of late that have a nifty element to them, when the user resizes his window the movie slides to the centre or relative position, rather than snapping.THIS SITE is one example of the effect I mean When you resize your window the text moves gradually to a relative position.How is this done? is it via action scripting or through the html/java?It is a nice little touch, I like it. Do you think if you can dictate the position of certain elements you can dictate the size of elements according to window size?
View 9 RepliesUsing this code:
[Code]...
I have a compass that is rotating depending on the position of the mouse, however it rotates it from the top left of the stage not the movie clip, how to get the AS to recognise the centre of the compass.. Also, I thought a nice touch would be if the compass had a slight "wobble"
i am struggling to work something out here and am hoping that someone on here can put me right...i have a flash movie that uses a liquid type layout (ie all from top left to fill the stage) - part of the movie is a navigation that when clicked slides around the stage to set positions.the problem is that the nav co-ordinates (points it travels to) are all based around top left of the stage, and i need to make it work from the centre of the stage.this is an example of one slide actions on one of the buttons named CLEAR:
PHP Code:
panel.CLEAR.onRelease = function(){
yTargetMC = 325;
[code].....
I have been struggling with the affect the browser zoom level has on my application for days. Finally I built the below test swf and noticed that when user zoom in using the browser zoom (IE 8) the box centering stopped working correctly.Movie with moviclip named box and button named mybtn with three text fields:
[Code]...
i am struggling to work something out here and am hoping that someone on here can put me right...i have a flash movie that uses a liquid type layout (ie all from top left to fill the stage) - part of the movie is a navigation that when clicked slides around the stage to set positions. the problem is that the nav co-ordinates (points it travels to) are all based around top left of the stage, and i need to make it work from the centre of the stage.this is an example of one slide actions on one of the buttons named CLEAR:
PHP Code:
panel.CLEAR.onReleasefunction(){
yTargetMC 325;
[code]....
I have a movie clip symbol on my stage, called 'symbol', i have centred it on the stage using the following.[code]...
View 2 RepliesIs there a way to have the startDrag command not lock to the centre of a MC but to have it snap and drag from a set location, ie _x and _y positions, on a MC.
View 8 RepliesI just finished reading and building the Photo Gallery using XML and Flash tutorial.Now i was editing it a bit to my desire, but im having trouble with positioning.My external images are all different sizes, and I would like to align them to the horizontal center of my Flash area.[code]
View 3 RepliesI'm new to AS and trying to learn new stuff by going through Kirupa's tuts and old threads, I came across this image resize from Best of Kirupa.url..At the moment all loading images as well as frame are resizing with top left corner always in fixed position. I've been trying to amend the existing AS, so both frame and images always stay and do the resizing at horizontal centre of the movie?
View 8 Repliesthought I'd posted this but clearly not I created a rectangle and in the centre using the text tool places the number 1 try as I might I cannot find an easy way to centre the number in relation to the rectangle behind it. Is there an easy way? tried the alignment tools but failed
View 1 RepliesI've ceated 18 buttons 1-18 on two rows and using the alignment tool made then all gapped the same and in line etc. I now want to centre the two rows of buttons on the stage. I've shift clicked to select all the buttons but no matter what option I pick in window alignment I can't get it to work.
View 2 RepliesI've created an mc which functions as my map and controls to go with that which allow the map to be moved around and key points navigated to and zoomed in on at varying zoom levels.I'm using scaleX and scaleY to scale the map mc and a list of x and y positions to correctly position the map for each key point. The map mc starts at 1:1 scale ratio with the screen and it's registration point is at 0,0.When I want to go to a certain area I perform this calculation (offsetX and offsetY are the center of the screen and posX and posY are predined offsets on the map):[code]
I now need to implement a zoom in / out function and this is what I'm struggling with. The zoom should use the center of the screen as the reg point for the scale, so I've been trying something along the lines of the following to get the correct x and y position to set after the scale:[code]I know this is wrong but I've shown this to give you an idea of my train of thought, I need to work out what the new x and y will be to ensure that the area that is being zoomed in on, stays in the center of the screen.So in my mind this gets the distance from the current position of the map relative to the center point of the screen (offsetX, offsetY) then scales that distance by the new scale.
CustomAppSkin Class
<?xml version="1.0" encoding="utf-8"?>
<s:Skin name="CustomApplicationSkin"
xmlns:fx="http://ns.adobe.com/mxml/2009"
[code].....
I have two rectangles: var rect1:Rectangle = new Rectangle(66,147,89,67);
var rect2:Rectangle = new Rectangle(155,147,89,67);
How to calculate the centre point of these rectangles based on their x and y positions. I want the centre point to be calculated with relative to stage
i want to know how can i centre the position of the image that we load. all these three external images when load are loaded from left top corner.i mean if i resize the images to less width and height they load from top left corner. i want them to load in the centre
View 3 Replies