ActionScript 2.0 :: Dynamically Center Text In Movieclip Button?
Feb 14, 2006
I'm finishing up a project that has a grid of 60 buttons -- two different button movieclips on which I've done some scripting for links, alpha tweens, etc. Each instance of the movieclip button is uniquely named.
In side each of the two different style of movieclip buttons is a dynamic text field that, unfortunately, is sized to the dimensions of the movieclip background. Thus, when dynamic text is pulled in (from XML-based arrays) to populate the movieclip buttons, it is top aligned if only 1 line long. Given this current setup, how can I dynamically center (vertically and horiztonally) the dynamic text field within each of the two movieclip buttons?
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
this["recipe"+i] = new recipelistname(); this["recipe"+i].buttonMode = true; this["recipe"+i].recipeid = i;
[Code]....
The problem is that the movieclip rotates around the center. The textfield inside the movieclip is starting at 0,0. But it still rotates around the center, how can I make it rotate at 0,0?
I'm trying to see if there's a way to change the registration point of a MovieClip that's importing an image dynamically?Here is my code where I add an image to an "overlayHolder":
What I need to do is rotate this image later on, upon interaction from someone, but need it to rotate with a center-registration.I've seen a bunch of tutorials/forums talk about centering a registration point when you're drawing a Sprite on the stage, but not when you're importing an image.
I created a somewhat custom Spark button by doing the File > New > MXML skin and basing it on spark.components.button. The problem is that I need to add an extra text field to the button component and dynamically change that text...but of course, the property isn't recognized on a Spark Button.
Is there a simple way to add this field to my custom button skin & its property so it can be addressed? If not, is there a simple way to take what I've done and just extend the Spark Button? I can't seem to find any examples that show how to do it without writing it all up in ActionScript.
Buttons works in many ways as movieclips, but for an example they dont have the getBounds method..etc etc..Is it possible to "equip" a native button, so it has al theese methods?..and behves more like a movieclip "why don't just use a movieclip".
What I'm trying to do is create a Simple Trivia Game by making the MovieClips and adding the text from the database (MySQL). Here's part of my code that I have working:
ActionScript Code: private function displayAnswersText() { select1MC.x = 50;
[code]....
what I like to be able to do is have it where I could just have the movieClip be selectable by the mouse. However when I try the following:
I want to create a movieclip so that that I can create text inside of it and make it clickable. I want to do this all dynamically since I am using ZendAMF to pull in database information to put in the text box. So far I have this:
Code: function createNames():void { nameCont = new MovieClip();
I just want to center my dynamically loaded movieclip, into it's container box. Not center on the stage, but make it center with the container_mc it loads in.
You know when you load a external swf, it loads from the top left corner. How can the loaded image or movie load centered instead of aligned top-left?
I am actually using the XML thumbnail gallery here at kirupa. [URL]
I have three movieclips (used as buttons) on my main MC. The following code swaps the depth of a dynamically loaded image the when I rollOver each movieclip (button). I want to put the button.rollOver code in a for loop so I dont have to repeat this code for every image loaded.
I have several images that are loaded dynamic.Now I want them to center in the container.How is that done? I can get the width and height but I can't adjust the x values on the loaderinfo object. Heres part of the code:
... part of function ... for (var i:uint=0; i<numPictures; i++) { var pictLdr:Loader = new Loader();[code].......
I have a presentation with various embedded and external videos linked to it. I need them to be positioned in the center of the screen no matter what resolution the user is running, therefore I need to position them dynamically and not with specific co-ordinates. I have found a link and some code that does this, but its a big chunk of code and I would like to put this code in my main .as file, as a function, and then in my main timeline when I have a video - just use one line of code to call the function and apply it to a movieclip with the video inside.[code]...
I'm doing a little photo rotation front-end for a site I'm working on. It's a custom photo gallery site that needs to have a photo rotation functionality to it. The back-end developers couldn't find a decent way to do it in Javascript, so they've come to me to figure it out in Flash.They pointed me to the Flickr rotation tool as an example. Seems like it should be straightforward:Load photo into empty movie clip on stageRe-center photo movie clip to the stageUse left/right rotation buttons to rotate image in 90 degree incrementsThat said, I'm having a tough time, after I load a photo into the empty movieclip, using a rotate left and rotate right button to spin the photo around. Obviously, the registration point is in top-left corner of the photo movieclip when the photo is loaded.
I've read that rotation can be managed by putting the clip to be rotated into an outer clip, but...there's a catch......I won't ever know what the exact size of the photo being loaded is going to be, so I can't set the outer clip to a certain size. I only know that it will never be wider than 100px.
I have a presentation with various embedded and external videos linked to it. I need them to be positioned in the center of the screen no matter what resolution the user is running, therefore I need to position them dynamically and not with specific co-ordinates. I have found a link and some code that does this, but its a big chunk of code and I would like to put this code in my main .as file, as a function, and then in my main timeline when I have a video - just use one line of code to call the function and apply it to a movieclip with the video inside.
Using the new 3D features in CS4. I know you can change the 3d center point manually via the Transform panel, but does anyone know how to do this dynamically at runtime? (ie via code)
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've read a few of the other threads on this subject but still had no luck. I'm loading jpgs via an xml file and the pics are all diffrent sizes. I'm trying to figure out how to center the image once loaded, but am running into brick wall after brick wall.[code]...
I have created a slideshow, in which image is loaded dynamically from a xml. the issue is the images gets aligned to left ,top position by default. i want it to center align.
I have created a slideshow, in which image is loaded dynamically from a xml. the issue is the images gets aligned to left ,top position by default. i want it to center align.
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 () {
Lets say you have a bunch of similar movieclips and you want to move anyone of them dynamically. We would use:
[Code]...
Something like that. However, my issue is not selecting a movieclip dynamically, but selecting another movieclip dynamically within a dynamically selected movieclip.
I am having a problem with my text alignment and I can't figure out a way to correct this. Unfortunately, I'm using a mac with CS3 and a Windows computer with CS4, so it could either be an OS difference, a version difference, or a software bug which I can't figure out.
For some reason, the text on my Mac with CS3 are not in the vertical center of the text fields. This causes a problem with my "align vertical centers" alignments, meaning I've had to do the alignment by hand to get it to look right. When I moved my file to my laptop to keep working on my project at home, I noticed that the text alignment was correct on my laptop, causing all of the text placement throughout my document to be off. This means that I can only work on the one computer and can't bring the project home to work through the weekends.
I have made an image showing the difference of how the text is aligned on the two versions, and a sample of how it affects my project when i bring it between computers.
I made the file on the mac (CS3) first, and so the alignment is designed to look correct on there. When i bring it to the PC (CS4) the text shifts down, placing it back in the center of the text boxes and ruining the alignment.
When I publish the file it keeps the formatting of each system. IE - publishing on the mac makes the final product look like it does on the mac, and publishing on the windows computer makes it look like it looks on the windows computer. The file published from the mac has the mac alignment on both computers, and the file published from the pc has the alignment of the pc on both computers.
I am having a problem with my text alignment and I can't figure out a way to correct this. Unfortunately, I'm using a mac with CS3 and a Windows computer with CS4, so it could either be an OS difference, a version difference, or a software bug which I can't figure out.
Update: I downloaded a trial CS4 and the problem persists. This seems to be a mac issue. For some reason, the text on my Mac with CS3 are not in the vertical center of the text fields. This causes a problem with my "align vertical centers" alignments, meaning I've had to do the alignment by hand to get it to look right. When I moved my file to my laptop to keep working on my project at home, I noticed that the text alignment was correct on my laptop, causing all of the text placement throughout my document to be off. This means that I can only work on the one computer and can't bring the project home to work through the weekends. I have made an image showing the difference of how the text is aligned on the two versions, and a sample of how it affects my project when i bring it between computers.
I made the file on the mac (CS3) first, and so the alignment is designed to look correct on there. When i bring it to the PC (CS4) the text shifts down, placing it back in the center of the text boxes and ruining the alignment. When I publish the file it keeps the formatting of each system. IE - publishing on the mac makes the final product look like it does on the mac, and publishing on the windows computer makes it look like it looks on the windows computer. The file published from the mac has the mac alignment on both computers, and the file published from the pc has the alignment of the pc on both computers.
Just to clarify, the way flash handles text fields on windows / cs4 is how I imagine it should be. I made the file on mac/CS3 however, and so when i said "ruins the alignment" I should have said "fixes the alignment problem, but breaks my alignment which was made to compensate for the problem I was experiencing."
I was wondering how to center dynamic text in a text box?I tried setting the TEXTINSTANCENAME.html object to true, and then setting the TEXTINSTANCENAME.htmlText to text wrapped in the <center> and </center> html tags, but it didn't work. The text is still too far to the left.
I'm dynamically creating an empty movieclip inside another movieclip to load an image into it. How could i make sure that this image is always centred in the movieclip?
Also, if i have a attached movieclip named E.G. 1M how do i find out the x and y position to make it appear next to each other?