I have these 2 separate FLA (AS3) files and I want to merge them together. One FLA, let's name "Animation.fla", consists of a 1-frame animation with a class assigned to its main stage, let's label it "MainStage.cs." The other FLA file, label it, "Navigator.fla", consists of 3 frames where I have to navigate different frames to get to the animation on the Animation.fla.
I have tried nesting the two but I gain errors when trying to convert the whole Animation.fla to movieclip and put it on the frame of the Navigator.fla. It's seems it's not the correct way to do it.
Please fill me in with ideas on merging animations with Classes since I'm still new to this.
I have tried nesting the two but I
gain errors when trying to convert the
whole Animation.fla to movieclip and
put it on the frame of the
Navigator.fla. It's seems it's not the
correct way to do it.
This is one way to do it. It could be that your code has errors. Please post your code.
In the meantime, check if:
-your MovieClips have instance names
-you are referencing your MovieClips correctly in your code.
You could you create a new movieclip on the stage of Animation.fla and select all of the frames in Navigator.fla, right click and "copy frames". Then go back to Animation.fla and paste them into your new movieclip. This will work if you don't have a main class in Animation.fla.
Related
I have a game in which I have three different scenes. In the first scene, the objects (movieclips) were added through the flash editor, meaning that no actionscript was used to add them (not added with addChild). After that ive decided that I want to do the second and third scene entirely through actionscript and every object that is added is added with addChild(). The problem with this is that now the objects that have been added through actionscript appear in front of the ones added manually through the editor and I want it to be the other way around. I know that addChildAt() exists but I have over a 100 objects so it doesn't seem like a good option. In short: How do I set the Z-Indexes of movieclips that have been added through the flash editor and not through actionscript.
At first I tell you, this is not a good practice.
I give you some methods:
1.add child at to the back of others:
addChildAt(myDisplayObject,0);
so your added children will go back.
2.set the index of display obects:
first you should give them instance names, then in code:
setChildIndex(myDisplayObect,myIndex);
so you set the index of your display object.
I H☺ P E this helps
So I have a main scene called Game. In that scene, I have a movieclip called Shop. Inside that movieclip called shop, I have another movie clip called upgradeweapon2. Inside upgradeweapon2, I have a button called "upgradeweaponpb".
I am working in actionscript, in the frame of the movie clip upgradeweapon2. I am trying to edit a variable called "weaponlvl" that was declared in Game. A picture to show what I mean:
http://gyazo.com/96b04ab89ea4a589bee560d53d165b03.png
I am getting the following error: Access of undefined property weaponlvl.
Please tell me there is a way around this... I know weaponlvl is defined in the root scene, game, but is there a way to make the declaration valid across levels of MovieClips, or at least a way to transfer the values accross?
Here is the code I am trying to add:
stop();
upgradepb.addEventListener(MouseEvent.CLICK, upgradeweapon5);
function upgradeweapon5(event:MouseEvent):void{
weaponlvl++;
}
EDIT: Alright I simplified my code, It's just a movieclip, not two layers. But still the same error. Any idea what I can do?
weaponlvl is on the frame of upgradeweapon2.upgradeweaponpb; it is not on the root layer, so therefore in action script it will not make sense. You have two options:
Get weaponlvl through MovieClip(root).weaponlvl or this.parent.parent (which is also the root).
I've gathered all game pages on different frames of movieclip called game. in that game movieclip there are 4 different frames. on third frame I have some drag & drop functionality. When I drag one item, I want it to be on the front, I mean all other objects on that frame must not block the view of current dragging object. I used this.setChildIndex(currentDraggingObject,this.numChildren-1); but the problem is whenever I drag objects, when I change the frame, those objects are shown on that frames as well.
In short description: When I set an object's Index in MovieClip(game) , that object is seen in each frame of MovieClip(game) , how can I fix this?
I've searched the result online but couldn't find a solution.
Thank you
-Ozan
Instead of this:
this.setChildIndex(currentDraggingObject,this.numChildren-1);
You can simply use this:
this.addChild(currentDraggingObject); //shorter and clearer
If you have some object on a frame and you actually add it again, it indeed stays there in the other frames (I found this out too). The best/fastest solution would be to simple remove them before you are going to change the frame with this.removeChild(object)
i am working with several nested movieclip objects in a project. but i get into trouble with the buttons i created and implemented in the nested movieclips:
to describe it in a simple way:
I have a main movieclip with five frames, including two buttons with listeners to browse between the frames. Then inside of one Frame I have another movieclip with its own buttons. i instanciated it by hand not through code and gave it a specific name like "nestedMc".
Now I dont want to build the Listeners for those buttons inside the class of the nested movieclip class but in its parent class, which works fine until i then goto another frame in the main movieclips timeline and come back.
obviously every time flash enters a frame its contents get created anew (and therefore get new instance names). I could now try solve this through filling the frames via code.
But maybe there is another way to make sure the frame contains the same instance everytime i enter?
Timeline scripting is a dirty business, and really, a carry-over compatibility layer for Actionscript 2 projects. Whenever possible, I highly recommend not doing it, and simply keeping all of your code in your document class. As you're experiencing, timeline code causes headaches.
Consider instead just creating both states of your Stage (it sounds like that's what your two buttons are jumping between) and simply hiding them offstage or setting their alpha to zero and their mouseEnabled state to false. Furthermore, if the purpose of your frames is to play animation (a tween), consider instead switching to a much more powerful suite such as TweenLite. Moving an object over a hundred pixels (smoothly) can be as easy as:
TweenLite.to(redBall, 3, {x:100});
Now, if you're manually adding these items to the stage, as long as the object is a dynamic one, you can assign an instance name to it which will be saved between frame loads. Be aware the object name is not the same as the instanced name. For example:
var redBall:Ball = new Ball();
redBall.name = "bubbles";
The object's name is Ball, but it's represented as a variable called redBall. Its actual DisplayList name will likely be ambiguous (such as "Instance71"), and I can manually define it as "bubbles". 3 different names for the same object, all very different and necessary.
Even if you give the object a displayList name, you may not be able to reference it through code unless you enable Automatically declare stage instances, which basically creates on each object a pointer to the displayList object.
That said, you can always fetch the object by other means. Obviously, your buttons are always appearing, but you're trying to find a very specific object on the stage. At this point, we can use getChildByName() or getChildAt().
Hope that helps.
-Cheers
For my project I need to copy the graphics of a Movieclip with all of its children without copying anything else into a second Movieclip. I cannot use the Bitmap classes because I need the graphics to be displayed as a vector and I cannot use a method that simply copies the clip by calling the instructor ie:
var copy:MovieClip = clip.constructor
Is there any way to copy only the display portions of a clip into another Movieclip without turning it into a bitmap?
Thanks
Cloning display objects out of the box in as3 is no easy task. Here is a tutorial explaining the several approaches that have been attempted over the years and what works and what does not:
http://www.dannyburbol.com/2009/01/movieclip-clone-flash-as3/