ActionScript 2.0 :: Center A Dynamically Generated Movie Clip On Stage?
Feb 4, 2009
I have created an empty movie clip in the root, I load dynamically some jpg to the empty movie clip, but now I want to center it and I can't I have this code, it centers the movie clip but on the registration point of 0,0 not in the middle of the movie clip so the movie clip will show up nice and centered.
ActionScript Code:
var stageL:Object = new Object ();
stageL.onResize = function () {
I am trying to test it. I am loading swf's into movie clip with XML stacking each other vertically. I found out that after movie clip is reached the height of 65000 px the other loaded swfs will not be loaded correctly. They are loaded from the 0 point again overlap previously loaded swfs.
I am trying to test it. I am loading swf's into movie clip with XML stacking each other vertically. I found out that after movie clip is reached the height of 65000 px the other loaded swfs will not be loaded correctly. They are loaded from the 0 point again overlap previously loaded swfs.
i have a triangle that i generate using the following code:
Code: Select allinternal function generateTriangle(w, h, topPoint, color = "0xFF9900") { var triangle:MovieClip = new MovieClip(); with (triangle.graphics) {
[Code]....
I use this function and a foreach loop to generate 9 differently colored and sized triangles, which works fine when i place them on the canvas. But if i try to rotate them they rotate around the 0,0 point - i want them to rotate around the center of the individual triangles, how do i do that?
1. How do i move a dynamically generated triangle inside a movieclip? Solved using [URL]
2. How do i access each of the triangles inside the movieclip, or even better, place them in 9 different movieclips using addChild so that i can move them around individually?
I'll start off by saying I'm using Flash 8, Actionscript 2.0, and exporting as FlashPlayer 6.I'm trying to do this long landscape with a movie clip labeled, "mainMovie", let's say it's approximately 3600 x 600, while the stage/document dimensions are 800 x 600 .I have script on it so that moving the cursor to the left or right edge of the stage, the entire movie clip shifts left or right and through the rest of the landscape, similar to the 360 vr tours you see for some real estate sites online.On the main stage, I have that movie clip called, "mainMovie". Inside "mainMovie", is another clip called, "singleStrip", and inside that clip, I have other smaller movie clips through the landscape which are labeled and consist of random stuff, like shapes and items and stuff.
Everything works fine. The extra step that I am attempting is that I want the user to be able to scroll through the clip, "click" on an item, and then that item zooms into the front center stage and plays a small animation about that item. These items that are found throughout the landscape are movie clips themselves with script on them to be recognized as buttons.My problem with that is even though the center of my stage would be x=400, y=300, since my mainMovie on the stage scrolls from left to right, when I put in code to tween the item to a center position, that position is only set to the inside of the movie clip and not the center of the stage. I need to center a movie clip within two other clips to the stage.An example of the path of any of those items would be sort of like,
[code]...
That didn't work. It shifted it to a different position, not being the center of the stage.At another point, I tried to fake it out, placing a movie clip of a red ball on the main timeline in the center of the stage, and changed my code to:
[code]...
This didn't work, either.I do have other code that affects the motion scroll of the mainMovie from left to right, but I don't think this is the problem, I could be wrong.
I am trying to do something that seems like it should be relatively easy. Well bang goes that theory. Here is what I am trying to do. I have the path to a group of images stored in an xml file. I want to load them to a movie clip on the stage. doing this directly by reading the xml file and using loadMovie("filename"); bsaically does what I want it to do with just a few problems, 1. the movie repeats so the same image is pulled from the server multiple times sucking up bandwidth. 2. On slow connections the images can sometimes load slow making the movie not display properly. What I would like to do is load all the images into some structure and add the images to the movieclip in the time line when needed. How does one accomplish this in action script 2.0?
In a perfect world, I would just load all the images to an array and load the array element to the movieclip on the stage.
I'm trying to dynamically load multiple images to a Movie Clip on the stage. Where I am having trouble, is when I position different sized images one under another.
What I have done is, assign a variable for the position for the _y of the next image. eg. var spacing:Number = 0;
Since I'm loading the images from a XML file, I've included the height for each image aswell. This is where I am having trouble
Say for example, the image I am loading is 400px high, 'spacing' then appears to be 0400 and not 400. After I load the second image, which is 500px high, spacing appears to be 0400500 and not 900.
Having trouble with this one, let's say I have a 800x600 stage with a movieclip on stage. Now inside this mc I have a red dot thrown randomly somewhere inside. How can I make my mc move so that it centers that red dot to the center of the stage? I need the animation to be dynamic but I can't figure out the formula to do it
Users provide various elements of content for the final Flash movie, eg. text and photos. We want to be able to allow the user to download the movie they create in a format such as MP4 which they can play on their local computer or upload to YouTube.
I dynamically generate movie clips in a for loop. But at the end of the loop, only the last created movie clip exists. Others simply disppears.[code]...
I'm trying to detect a mouse rollovers on dynamically generated movie clips but I just can't make it work. Only way I can make it work is to put actions inside the duplicated movieclip.
var total = 6; myThumbs = new Array(); for(i=0; i<total; i++) {
[Code]....
Everything works fine except when I roll over the mc the value of this["myThumb"+i] is undefined.
new Tween(clip,"_x",Bounce.easeInOut,clip._x,Stage.wid th,6,false); new Tween(clip,"_x",Bounce.easeInOut,clip._x,Stage.hei ght,7,false);
what would be the correct way to write this to make clip go to the center of the stage and stop? At the moment it takes off to the left, never to be seen again..
I have a flash file that reads and XML file, it creates an empty movie clip in a placeholder (mc_image_holder) for each entry in the file, so 4 entries in the XML file = 4 movie clips inside the placeholder. it does this like so:
Code: if(success) { var nm:MovieClip = mc_image_holder.createEmptyMovieClip("swfHolder"+i,-((i) * 10)); nm.loadMovie(filename);
[code]....
however, for some reason, the last created movie clip in the place holder never fires the onEnterFrame event more than once, so, If I were to trace the word "hi" I would only get it once, where as if I apply that to each of the other three that are created, it would put it many times, as it should.
I'm try to build a photo gallery using the flash components SlideShowPro and ThumbGrid. I have put ThumbGrid inside a movie clip called thumbs_mc that slides in and out when you mouse over it to show or hide the thumbs. That part is working, but I would like to have the stage and thumbs_mc resize to the browser width with ThumbGrid centered inside thumbs_mc.
Resize and scaling the stage and movie clips is not a problem, but I can't figure out how to keep ThumbGrid centered inside the containing movie clip. ThumbGrid is a fixed width component, and the only way I can get it to work is to have the mc the same width as the component. Here's the part of the AS that I'm using to control the positioning now:
(using actionscript 2.0) I have a mc titled 'mc_othersitterimage1' Within 'mc_othersitterimage1' I have one layer with a simple shape that measures 85px x 85px, and I have another layer that has this actionscript on it:
('perfectsitterimageURL1' is a variable for an image url. All of the images are NOT the exact same size.) I'd like the image to load in the center of my 85x85 pixel square. I have the registration point in the center of 'mc_othersitterimage1', but it still doesn't seem to work
I am getting some overlap issues when I'm using the hitTestObject function to determine if I am over a particular target area. Is there anyway I can have the center of my movie clip determine if it's over the target area instead of using the whole clip? I am using:
mc.hitTestObject(targeItem);
It is the "mc" that i would like to use the center point instead of the whole movie clip.
Im having trouble centering my movie clips on the stage.
I have postioned movie clip holders on the stage and and coded them to be invisible (10 of them). If the images loaded are less than 10, the extra movie clip holders stay invisible and the loaded ones become visible.I am struggling to center the visible movie clip holders.[code]...
i am trying to center the image once clicked, i have multiple images(4) and want them to open dead center on the stage i would also like to close the opened image when the next one opens and return it to original position!
what i have got so far:-
stop();port1_mc.doubleClickEnabled=true; var centerX:uint = stage.stageWidth / 2;var centerY:uint = stage.stageHeight / 2; port1_mc.addEventListener(MouseEvent.DOUBLE_CLICK, go); function go(evt:MouseEvent):void{ //opens image to the stage gotoAndPlay (2);}
I have a movie clip of all counties in the state of Montana (allcnt_mc). Within allcnt_mc there are individual movie clips specific to each county with name equal to the county's name. When clicking on a county, I'd like to zoom to that county and center the stage on it. I've added event listeners to all counties through querying an xml table that has demographic info I am calling into dynamic text boxes. Here is the code I have thus far to load the xml and add the listeners to the county movie clips.
//load xml var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
i have the following code which works. Its for two buttons either side of a movie clip (holder_mc) which holds the images. The images load but their top left corner go to the 0,0 position of the movie clip (top left). My images are all different sizes and i want them all to be centred. I have looked at alot of threads and cant figure it out.
I have got a movie clip that is dynamically created with actionscript I then load an external swf into that movieclip. My problem is having it centered when I view it in my browser..How do place I center that dynamic created movie clip? I was trying this but it's not seeming to work.
Code:
var container:MovieClip = this.createEmptyMovieClip("container_mc", 0); container._x =Stage.width/2; container._y =Stage.height/2;
I have a movie clip container that contains 7 smaller movie clips, images converted to movie clips actually. This is a scrolling banner that can scroll left or right.
How do I start in the middle of this banner instead of the far left? That is, when the script first loads I want to be able to scroll left and right, not just right.
So I am creating a photo gallery and in the process I have created a button that links to a movieclip and plays it to appear as a popup window of the larger picture.
I want to load a random movie clip from the library to an empty clip on the stage called (bg_graphics). the clips in the library are called (green, blue, yellow).