How to place a mc above an embeded swf - actionscript-3

I am struggling to embed a swf in a flash movie so that it appears beneath a mc menubar.
The menu is in a mc on the main time line at the top layer.
The swf is embeded into a mc using the following :
swapChildren(fullmc, swfbox1);
var myLoader1 :Loader = new Loader();
swfbox1.addChild(myLoader1);
var url1 :URLRequest = new URLRequest("26A.swf");
myLoader1 .load(url1 );
stop();
However whatever I do (even trying "swapChildren" ) the embeded swf always appears on top of the menu mc hiding it completely.
Im sure theres a simple reason. Any help would be GREATLY appreciated. Thanks
Ed

have you tried? sorry my bad, i wrote too fast , try this instead
//if fullmc holds the mc you want above
var mc:MovieClip = this.root as MovieClip;
mc.addChildAt( swfbox1 , 0 );

Related

Actionscript 3 how to duplicate a symbol onto the next frame

Im a total beginner at using AS3. I want to know is how does one duplicate a symbol and make it appear in the next frame.
example: when the user clicks on the symbol in that frame, the same symbol will appear in the next frame. If it is not possible then how does one move that symbol to the next frame.
Thank You in advance for answering.
You should probably avoid to use timeline keyframe to achieve this kind of thing. However, if you really need to do it this way, here what I would do :
First, make sure the MovieClip you want to clone has ActionScript linkage.
Then:
my_mc.addEventListener(MouseEvent.CLICK,onClick)
function onClick(e:MouseEvent):void{
var m:MovieClip = MovieClip(e.currentTarget);
var c:Class = Object(m).constructor;
var clone:MovieClip = new c() as MovieClip;
gotoAndStop(2);
addChild(clone);
}
This will add the clone to the stage, so if you go back to frame 1, you'll see the clone. There's no way to add an object to a specific timeline frame. If you want to achieve such a thing, you have to target a container on frame 2 and add to clone to the container.
something like this :
function onClick(e:MouseEvent):void{
var m:MovieClip = MovieClip(e.currentTarget);
var c:Class = Object(m).constructor;
var clone:MovieClip = new c() as MovieClip;
gotoAndStop(2);
myContainerOnframe2.addChild(clone);
}

load an external swf (FlashPaper pdf) into a flash project

I have to do a very simple swf application able to show a series of pdf files.
Actually I was able to create on a single layer the menu interface (some buttons on frame 0 which redirect the user to other frames where the pdf should be showed).
Here my question:
I need a way to read the pdf inside the flash frame.
I've found a possible solution converting the pdf into an swf with FlashPaper 2
Now I wish to know how import the swf into the frame.
Reading some actionscript 3 guides I was able to create a container movieclip (a simple rectangle) into which I have loaded the swf with this code:
var swf:MovieClip;
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("test.swf"); //test.swf is my converted pdf
loader.load(defaultSWF);
screen_01.addChild(loader); //screen_01 is the container rectangle converted to movieclip
I've used a container movieclip to mantain the other objects (menu buttons) on the frame, and ecause it helps with the swf positioning.
I seen it is possible also using loader.x and loader.y and it works.
Unfortunately I wasn't able to control width and height of the swf/pdf file (loader.width and loader.height exists but if used cause the swf will not loaded at all)
Solution:
I've found a possible solution at this page. The idea is to change swf scale only after the load process is complete (positioning can be done even before).
Anyway I had to use Actionscript 2 for this project because FlashPaper converted pdf doesn't work properly with AS3, I don't know why...
here the code:
//insert an emplty movieclip to load the swf, I've called it screen_01
var movLoad:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myListener.onLoadInit = function(thisMc:MovieClip) {
thisMc._height = 600;
thisMc._width = 900;
thisMc._x = 50;
thisMc._y = 30;
};
movLoad.addListener(myListener);
movLoad.loadClip("folder/flashpaper_converted_pdf.swf.swf",screen_01);
You can modify the size of the loader using scaleX and scaleY properties.
Keep them equals so the swf isn't stretched.
You may also want to listen to the COMPLETE event to do such a thing :
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event)
{
var loader:Loader = e.currentTarget.loader;
loader.scaleX = loader.scaleY = 2; //Double the size of the loaded swf
}

How to make a symbol remove itself at a certain frame?

I'm struggling on doing a simple thing, I have an object that generates a smoke trail by creating and adding a simple animation done in flash. All works fine but I can't seem to find an easy way to make the smoke remove itself after playing the animation, if i add something like this.parent.removeChild(this); to the last frame of the animation the app simply crashes with Cannot access a property or method of a null object reference.
what am i doing wrong?
the animation keeps playing even thought the object is no longer being rendered, at the second call of this.parent.removeChild(this); the object was no longer parented to any object, stopping the animation solved the problem
thank you frankhermes
this.parent.removeChild(this);
this.stop();
in your main Movie clip assigned below code to a button(show button):
var swfLoader:Loader = new Loader();
stage.addChild(swfLoader);
var swfURL:URLRequest = new URLRequest("yourchildSWF.swf");
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
swfLoader.load(swfURL);
function loadComplete(e:Event):void
{
//swfLoader.x = (stage.stageWidth-swfLoader.width)/2; //for center align
//swfLoader.y = (stage.stageHeight-swfLoader.height)/2; //for center align
swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
swfLoader.content.addEventListener(MouseEvent.CLICK, function(e:Event)
{
swfLoader.unload();
} );
}
you must have a button in your child swf. when pressed on it, swf will be closed.(create a symbole as button for close button)
does not need any code in child swf.

How to control the image of an object in AS3

I have an object which is coded in a .as file, let's call it a widget, in widget.as. It is listed in the library as a MovieClip and is in fact a MovieClip. How can I, from the code in widget.as, overlay an image (Bitmap) from the library on it so that the Widget has four parts which can be switched between two different styles independently.
As an alternative, I could make a frame in the MovieClip of Widget for each possibility and make the code switch what frame I am on.
This must work in Adobe Flash CS3 and with ActionScript 3
If you have the image you want to show on top of it, and already have that split in four, then you could do something like this:
var tl:Bitmap = new Bitmap();
var tr:Bitmap = new Bitmap();
var bl:Bitmap = new Bitmap();
var br:Bitmap = new Bitmap();
addChild(tl);
addChild(tr);
addChild(bl);
addChild(br);

as3 accessing CHILD in External loaded swf file

How do I get to the MovieClips within an externally loaded Movie Clip.
Lets say I have a movie Called ONE in the swf I just loaded. How can I work with it alpha, position and other properties of the children of this clip?
CODE IN MAIN TIMLINE:
var LoadedMC:Loader = new Loader();
LoadedMC.load(new URLRequest("amplitude.swf"));
LoadedMC.addEventListener(Event.COMPLETE, bL);
function bL (e:Event):void{
addChild(LoadedMC);
}
Now its loaded I want to change the postino of the clip called ONE in the movie LoadedMC I just created.
Thanks for your help.
-Ed
I would think you would do something like:
//Cast the content into a movie clip
var someMC:MovieClip = MovieClip(LoadedMC.content);
//or try
var someMC:MovieClip = LoadedMC.content as MovieClip;
//then access the child
someMC.ONE.x = 50;
someMC.ONE.y = 100;