Wrong display of virtual camera in nested swf, flash action script 3 - actionscript-3

Im prity new in flash.
I have a virtual camera which zoom a square by these comands, (i got from internet).
parent.scaleX = 1 / scaleX;
parent.scaleY = 1 / scaleY;
parent.x = (width / 2 - x) / scaleX;
parent.y = (height / 2 - y) / scaleY;
It is inside a swf file, which will be displayed inside another flash file by using child movieclip as, inside a loader.
But the "parent" command in this nested swf cause it to display the square are to the whole area of main swf file, i want to make the nested swf file work seperatly inside parent swf file display virtual camer, not affect whol file.
Please hellp
Thank you

Related

Frame by Frame animation AS3

This is for AS3 FlashDevelop, Basically I'm super new to this. The most I've done in AS3 coding is display multiple images on a single frame and parallax images.
However I want to know how to display embedded Bitmap (.png pictures) as frames one after another,
like frame 1 = embedded image 1 frame 2 = embedded image 2 (frame 1 is gone but 2 shows) frame 3 = embedded image 3 (and so on.)
and they would continuously play as an animation and stop at the first frame until I press play again
I believe I would use nextFrame, stop and gotoframe but don't know where and what I need to code, I heard of bitmapdata but I'm stuck on how to use it in purpose of animating frame by frame.
EDIT: No I'm not animating sprites, rather it's more like cartoon process where you'll go frame by frame of the image files, as one appear the previous one disappears.
You could iterate through each frame and add the images after you load them.
If you do addChild() it should add it to the current frame you're on. Load the next image with a Loader, place it down with addChild, nextFrame(), and repeat until you have all the images. Then when they're all loaded (from what I guess would be some list you'd have in an array or an xml) take the user to frame 1. You might want to do this inside of a movieclip while having that and a cover graphic on your main stage so the user doesn't see all of the images while they're being loaded and placed.
[More about adding display objects to frames]

How to find the X, Y position of an object in external swf

I have a SWF application (A) that has a green object which moves on both X and Y axis,
this SWF application only runs with its SWF loader (B).
I created another SWF loader (C) which loads SWF loader (B). I want to know if it is possible to get the instance of that green object and its properties.
Or making a function to search for that green color on the stage and return X, Y position using the getPixels() method?
No, you shouldn't use getPixels it will be overkill for such task. Actually Loader has content property:
Contains the root display object of the SWF file or image (JPG, PNG, or GIF) file that was loaded by using the load() or loadBytes() methods.
You will be able to get desired green object by simply operating over display list, and understanding what are you doing after component is loaded. If you add content to the display list after every loading operation (Ex: addChild(loader.content)); and for example your green object has name (Ex: 'greenLantern') after full loading you will be able to get reference on it:
//After full loading, Code in loader C
var containerB: DisplayObjectContainer = getChildAt(0) as DisplayObjectContainer;
var appA: DisplayObjectContainer = containerB.getChildAt(0) as DisplayObjectContainer;
var greenLantern: DisplayObject = appA.getChildByName("greenLantern");
trace(greenLantern.magicProperty1, greenLantern.x, greenLantern.y);
Another approach is event bubbling. You could spawn event from application A and listen for it in loader C:
//Loader C
addEventListener("greenLanternHere", onGreenLanternEvent);
function onGreenLanternEvent(e:Event):void {
//Heeeellooooo moving green object
trace(e.target);
}
//Application A
greenLanternInstance.dispatchEvent(new Event("greenLanternHere", true));

How to change an image inside a Movieclip, from an external asset?

I have 2 SWF files.
One is for assets and contains some PNG files (which is actually a skin for my application), which exported to ActionScript.
The second one is for the main application, which loads the first SWF (using Loader) and uses its PNG files (using getClassDefinition to get the files).
I'm having some movieclips and buttons on the stage, which contains for than one simple frame (for example; a mute button, which has the "playing" state and "muted" state in 2 different frames of the mute's movieclip).
When I'm changing the images in the frames and then call gotoAndStop (to move to another frame inside to movieclip), the images returns to the originals.
Also, I have no idea how to swap the images inside the buttons.
Notice that I don't want to load an external movieclip (from the first SWF), but just PNGs.
Any idea?

Flash CS5 : MovieClip Printing In AS3

I am facing some problem while printing an swf from another swf movie.
I have two movies, A & B, in which B will be loaded to A and will be printed from A using a Print btn in A. The swf B has many layers including vector and jpeg files. When I load the movie B to movie A it's coming properly, but when I try to print only the jpeg image which is in the top layer of B is coming. I tried printing area of stage, which is also giving the same result. What is the problem?
Here is the code:
print_btn.addEventListener(MouseEvent.CLICK,printContent);
function printContent(evt:MouseEvent) {
var printJob:PrintJob = new PrintJob();
if (printJob.start()) {
if (loader_mc.width>printJob.pageWidth) {
loader_mc.width=printJob.pageWidth;
loader_mc.scaleY=loader_mc.scaleX;
}
printJob.addPage(loader_mc);
printJob.send();
}
}
I've got the problem solved to some extent. Now the problem is that there is a movieclip in the second flash file which is converted to a perspective view using the 3D rotation tool and an image is attached dynamically to it. When I am printing, I am getting everything except the perspective view of the image or even the mc.
Try to render a new movieclip and then print that one:
var jpgSource:BitmapData = new BitmapData (width size, height size);
jpgSource.draw(your source movieclip);

dimensions of loaded swf's stage

Here's the situation - I've got a shell that loads an external .swf. Now, that .swf is 800x600, but it's an animation piece, and there are elements that extends off the stage. When I load the .swf into the shell and call its width attribute, it returns 1200 - because it's including the elements that break out of the stage.
This isn't what I want - ideally, there would be two properties, one to return the 'calculated width' and one to return the 'default width'. Do these properties exist, and if not, what's the best workaround?
The width and height of the loaded SWF as defined by the FLA it was created with can be found in the Loader object in which you've loaded the SWF into.
swfLoader.contentLoaderInfo.width
swfLoader.contentLoaderInfo.height
This will always show you the dimensions as defined in the FLA properties. It makes no difference if any images, MovieClips, or what have you extend off the stage.
The stage.stageWidth and stage.stageHeight properties will always return the width of the stage, the stage is always the top most SWF. In other words, it will always represent the dimensions of the shell's stage. There is only ever one stage in a Flash application.
Mark is very likely right that the content loader info object will contain the correct width and height. I've never checked myself so I can't guarantee it. The docs say 'nominal' and contrast it with 'actual' so it seems reasonable.
There are a couple of other options. You can mask the external swf. Create a mask that is the size of the stage and put all content underneath it. Another idea is to create a movieclip based on a rectangular shape set it's alpha to 0 place it at x:0, y:0 and match it's width and height to stage. Give it an instance name and then when it is loaded use that value for the size.