How do I resize the stage dimensions, without shifting it to the left? My stage is wider than the content area. All I want is to reduce the width of the stage, but keep the live area in the center (like resizing the canvas in Photoshop. Is it possible to do this?
Are you talking about doing this during development or later, after you publish?
You may need to do this in two stages, first, you resize the Flash doc.
Main menu.. Modify/Document and set your stage size.
Then center your content as needed... the "Align and Transform" panel may be helpful.
Best wishes,
Adninjastrator
No. This file is already created. The live (content area) is 1100 px wide, but it's floating withing a stage that is 1500 px wide. I designed it this way, because I wanted to see how it looks in a browser, with white space on each side. Now I would like to reduce the stage size to 1200 px wide. When I do that, the content does no longer float in the center. I cannot move the content over, because there are a lot of layers and keyframes. I thought I could shrink the stage ( and not the content), like it's done in Photoshop when you try to reduce the canvas size, and it asks you how to position the new canvas size. Would you know if there is a way of doing that?
If you want the content to scale down as you reduce the size then use this actionscript code:
import flash.display.StageScaleMode;
stage.scaleMode = StageScaleMode.NO_BORDER;
If you want it to stay centered but not scale try:
import flash.display.StageScaleMode;
import flash.display.StageAlign;
stage.scaleMode = StageScaleMode.NO_SCALE;
// now remove anything that looks like: stage.align = StageAlign.TOP_LEFT;
Apps like Flash Builder can auto-set StageAlign.TOP_LEFT for you thinking that's what you want (because usually it is). If you don't specify a StageAlign but you do specify StageScaleMode.NO_SCALE, when you reduce size it will equally take width and height from the top bottom left and right.
Be warned, this means your left edge will no longer be 0px nor will your top be 0px. If you had a (default doc size) of 550x400 and you resize to 450x300 (remove 100px from width and height) then your left edge would be half the amount removed, or 50px. As will your top edge be half the amount removed, or, 50px. This makes placing things difficult sometimes.
Where should I insert this piece of code? On the first frame of the timeline? It seems so complicated. In Photoshop it's so easy to position the canvas. I learned my lesson with this one. Next time when I design a web site in Flash, I'll make sure I'll only allow 10 px on each side for the content to float withinn that stage.
On frame one of a new layer click on the frame, open the actions panel and yes, that's where you put it.
I follwed your advise, and created a new first frame on a new layer, and this is the code I got from you:
import flash.display.StageScaleMode;
import flash.display.StageAlign;
stage.scaleMode = StageScaleMode.NO_SCALE;
//now remove anything that looks like: stage.align = StageAlign.TOP_LEFT;
When I go to resize the stage, it does the same thing, it gets positioned on the left. Please advise.
When you see // before anything it means a "comment". As in, it's not code. That's me telling you to look around your document and see if you see anything setting stage.align to something. By default your behavior should happen. It works like Photoshop canvas, except in Photoshop x=0, y=0 is not reset. In Flash, 0 always remains where it was originally. So if you add to the width, your left edge becomes a negative number, if you subtract, it becomes positive.
e.g. add 500px to size, your left edge is now -250px
e.g. subtract 500px to size, your left edge is now 250px.
You mentioned Photoshop so just think about changes flash's size as if Photoshop NEVER updated the 0 pixel position on canvas resize. If you shink your photoshop canvas then you'd see -250 on the ruler. If you added to it you'd see 250 as your left edge. Hope that makes sense.
What always helps is containing your entire animation inside a single movieclip. Therefore you can move that single clip and all its contents at once. Think of it like adding all your Photoshop layers under a single folder, then selecting the folder and moving it.. All layers would move inside the folder.
It still does not work. I deleted your comment out of the code. Is there something else I need to include in the code you gave me? All I want is to reduce the widht of the stage, from 1500px to 1200px, without having it aligned to the left.
I also like your idea of creating a movie clip of the antire content, this way I can move the clip around. Is there a way of doing this now, after all the content has already been created?
It will always clip the canvas from upper left.
If you're just loading this into a website then HTML can handle it as long as you have the ability to scale enabled. You'd go on frame 1 and use this code:
import flash.display.StageScaleMode;
stage.scaleMode = StageScaleMode.EXACT_FIT;
Then go into your HTML and where it says the width="1500" just change it to width="1200" and the SWF will scale itself to that size. Things will get smaller though. It won't be like a "Canvas" in photoshop, it will be like an "Image Resize".
To do it like canvas you'll have to produce your animation and import it into another file at the size you want.
e.g.
1. Export your animation to "animation.swf"
2. Make a new document at your desired size (e.g. 1200px wide)
3. Hit File->Import->Import to Library
4. Choose animation.swf
5. You will see a new movieclip in the library.
6. Drag the movieclip on the stage and center it as desired.
If you don't Import to Library then it will just import a bunch of frames to be sure to use Import to Library rather than just Import.
None of these two options work. The first option is ruled out. I did specify that I do NOT want the image to resize, I only want the stage to resize, not the image. That's exactly why I am going through all this trouble.
The second option is as bad as the first. Once you import an .swf file into a new Flash document, it looses all the animation, it scrambles all content to a frame by frame timeline. Besides, each time I would need to update this content, I would have to go back to the original Flash file, and then export, and import the .swf file again. It's probably easier for me if I just rebuild the file from scratch. Unless you know of a better option.
Do yourself a favor and re-read my instructions. I will bold them because you did not read them.
If you don't "Import to Library" then it will just import a bunch of frames so be sure to use Import to Library rather than just import.
Last line of my last post.
I also said this in step 3.
You will receive one MovieClip symbol in your library that can be placed on your stage.
Be sure to read through entire posts. We read yours.
If you prefer to do it with code then export the animation.swf as mentioned. Now open a new AS3 document and use this code on a frame script (click in frame 1, open the Actions panel, type this):
// imports
import flash.display.Loader;
import flash.net.URLRequest;
// request loading SWF
var anim:Loader = new Loader();
addChild(anim);
anim.load(new URLRequest("animation.swf"));
// set a custom position to re-center, e.g. from 1500 to 1200 width
// half of that 300px difference is 150px
anim.x = -150;
I did read your instructions, and yes, I did import the .swf file to Library. You should have known that an.swf file has all its content embedded. You cannot edit an .swf file, unless you crak it with some thrid party software, even then it all gets scrambled. That's why once you import it to Library and drag the clip onto the stage, you get a bunch of frames. Try it yourself, and you'll see.
Regarding your code, I won't even try it, because, if this didn't work so far, I don't think your code will do it. Try to read more about .swf files, and you will see that they are not editable, even if you import them to Library. You'll get a bunch of frames.
It's definitely not a good idea to go around introducing yourself as having no idea how to code or use flash, then telling me what has been said is untrue.
Clearly you need extra help. Here's a quick video proving the concept. I rarely do this but there's something about being called a liar that is unhelpful enough to warrant it.
I was dismayed enough to actually record this on a laptop with a trackpad to explain the terrible mouse movement.
Firstly, I have never said that I have no idea how to code or use Flash. I have been using Flash since it was bought as FutureSplash by Macromedia (about 15 years ago). However, there are still things I don't knbow about Flash, I don't claim to be a Flash guru. That's why I posted the question.
Secondly, your "quick video" missed the whole point. It's totally irrelevant to what my question was about. I did tell you that I imported the .swf file to Library in a new document. The prblem with that is that all the animation gets scrambled, the. swf file crunches the content into a bunch of frames. This is exactly what I didn't want to happen. I want to be able to edit my animation, without having to go back to the original file, and then export, import again. That is the whole point. If you don't beleve me, go ahead and open your little animation .swf file in your new document, and you'll see: your tween is gone, it's only a bunch of frames.
Thirdly, I did NOT call you a liar. I just said that the code you gave me did not work. Why are you so defensive, you should not take this as a personal matter. If you're angry/miserable, you're trying to pick a fight with someone, I'm not the right person for that. You should not reply to these postings if you have such a negative approach. I don't want to fight, all I wanted is to solve my little Flash issue. So please don't write to me any more, and keep your anger/misery to yourself.
You asked in post #4 where to put the code, nor did you know what that basic code does. That tells anyone you're definitely not an avid user as these are the absolute Flash 101 basics.
The code I posted would work and is called a stub. Again, if you've been using it for a decade and a half you should have no problem with it. I'd post a video on that but I don't need another lecture.
Lastly, no, you can't do what you want. You can't choose a registration point and canvas crop in flash. That's the point of the video. It's the easiest no-code route, as that's what it seemed like you needed.
Good luck.
AGAIN, I have never claimed to be a Flash Coder. I have been using Flash for about 15 years, but mostly on the Design side, and very simple AS, and I have won many awards for my Flash designs. However, I am not by any means a coder. That's why I posted the question.
AGAIN, just try to open your animation from your video, and you'll see it's all scarmabled to a bunch of frames.
AGAIN, I do not need your "help" any more. You have not helped me at all.
[ personal attacks removed by admin ]
Any more abusive language in this thread and it will be locked. Repeated violations of the forums terms of use will result in your accounts being suspended.