use 1 object multiple times in as3? - actionscript-3

I'm trying to make something like bookmarks, I have 1 note on the stage and when the user clicks it, it starts to drag and the users drops it where they want. the problem is I want these notes to be dragged multiple times.. here is my code:
import flash.events.MouseEvent;
//notess is the instance name of the movie clip on the stage
notess.inputText.visible = false;
//delet is a delete button inside the movie clip,
notess.delet.visible = false;
//the class of the object i want to drag
var note:notes = new notes ;
notess.addEventListener(MouseEvent.CLICK , newNote);
function newNote(e:MouseEvent):void
{
for (var i:Number = 1; i<10; i++)
{
addChild(note);
//inpuText is a text field in notess movie clip
note.inputText.visible = false;
note.x = mouseX;
note.y = mouseY;
note.addEventListener( MouseEvent.MOUSE_DOWN , drag);
note.addEventListener( MouseEvent.MOUSE_UP , drop);
note.delet.addEventListener( MouseEvent.CLICK , delet);
}
}
function drag(e:MouseEvent):void
{
note.startDrag();
}
function drop(e:MouseEvent):void
{
e.currentTarget.stopDrag();
note.inputText.visible = true;
note.delet.visible = true;
}
function delet(e:MouseEvent):void
{
removeChild(note);
}
any help will be appreciated.

You need to create a new instance of your note class when you drop, copy the location and other variables from the note you were dragging, add your new note to the stage, and return the dragging note to its original position.
Something like:
function drop($e:MouseEvent):void
{
$e.currentTarget.stopDrag();
dropNote($e.currentTarget as Note);
}
var newNote:Note;
function dropNote($note:Note):void
{
newNote = new Note();
// Copy vars:
newNote.x = $note.x;
newNote.y = $note.y;
// etc.
// restore original note.
// You will need to store its original position before you begin dragging:
$note.x = $note.originalX;
$note.y = $note.orgiinalY;
// etc.
// Finally, add your new note to the stage:
addChild(newNote);
}
... this is pseudo-code really, since I don't know if you need to add the new note to a list, or link it to its original note. If you Google ActionScript Drag Drop Duplicate, you will find quite a few more examples.

I think you are not target the drag object in drag function and problem in object instantiation
for (var i:Number = 1; i<numberOfNodes; i++) {
note = new note();
addChild(note);
...
....
}
function drag(e:MouseEvent):void{
(e.target).startDrag();
}

If you are dragging around multiple types of objects (eg. Notes and Images), you could do something like this, rather than hard coding the type of object to be instantiated.
function drop(e:MouseEvent):void{
// Get a reference to the class of the dragged object
var className:String = flash.utils.getQualifiedClassName(e.currentTarget);
var TheClass:Class = flash.utils.getDefinitionByName(className) as Class;
var scope:DisplayObjectContainer = this; // The Drop Target
// Convert the position of the dragged clip to local coordinates
var position:Point = scope.globalToLocal( DisplayObject(e.currentTarget).localToGlobal() );
// Create a new instance of the dragged object
var instance:DisplayObject = new TheClass();
instance.x = position.x;
instance.y = position.y;
scope.addChild(instance);
}

Related

AS3 Error drag and drop multiple draggable object to multiple target

I want to make the game drag and drop to create multiple draggable objects and it can dragged to multiple targets. But I encountered an error when I drag to the first object that I choose to certain target object is not dragged to the target and then I drag it to another target then succeed. I wanted to fix it. And if you can fix it when the object is dragged to the target and then want to be replaced by another object then the dragged object will be replaced and returned to its original position.
This is a overview the program
And this is the source codes that I use
var xPos:int;
var yPos:int;
var poin:int = 0;
var namaobj1:String;
var namaobj2:String;
addListeners(membaca, menulis, berenang, sepakbola, melukis, memasak, menari, bercocoktanam, beladiri, bermainmusik);
proses.addEventListener(MouseEvent.CLICK,proses1);
function getPosition(target:Object):void
{
xPos = target.x;
yPos = target.y;
}
function dragObject(e:MouseEvent):void
{
getPosition(e.target);
e.target.startDrag(true);
}
function stopDragObject(e:MouseEvent):void
{
if (e.target.hitTestObject(getChildByName("target2")))
{
e.target.x = getChildByName("target2").x;
e.target.y = getChildByName("target2").y;
namaobj2 = e.target.name;
}
else if (e.target.hitTestObject(getChildByName("target1")))
{
e.target.x = getChildByName("target1").x;
e.target.y = getChildByName("target1").y;
namaobj1 = e.target.name;
}
else
{
e.target.x = xPos;
e.target.y = yPos;
}
pil1.text = namaobj1;
pil2.text = namaobj2;
e.target.stopDrag();
}
function addListeners(... objects):void
{
for (var i:int = 0; i < objects.length; i++)
{
objects[i].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
objects[i].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
}
}
I'm using draggable objects by putting addListener function.
I also include his .fla can be downloaded here ( TEST.FLA ) rather you can more easily apply fixed codes
You can add Mouse_UP event in your targets instead of you dragged objects. Then when the MOUSE_UP event is trigged, you will know which objects is your target(e.target) without hitTestObject. The code is as follows:
You could have to set dragged object's mouseEnabled when mouse down, and true after dragged.

LoadMovieclips Array Click Btn Array

How can click on any button to load the array into the concrete contents of the array Teddy I Grateful (Load Movieclips Array Click button Array)
var teddy:Array = [home,about,products,services,contact];
var l:int = teddy.length;
for (var j:int = 0; j < l; j++) {
var mc1=new teddy[j];
var mc2=new teddy[1];
teddy[j].buttonMode = true;
var Btn:Array = [Btnhome,Btnabout,Btnproducts,Btnservices,Btncontact];
var W:int = Btn.length;
for (var i:int = 0; i < W; i++) {
var mc:MovieClip = new Btn[i];
mc.buttonMode = true;
mc.x=400+i*100;
mc.y=600+i;
mc.addEventListener(MouseEvent.CLICK, clickHandler);
addChild(mc);
}
}
function clickHandler(event:MouseEvent):void {
switch (event.currentTarget) {
case mc :
addChild(mc1);
trace("home");
mc1.x=400;
mc1.y=200;
break;
case mc :
addChild(mc2);
trace("about");
mc2.x=400
mc2.y=300
break;
case products_mc :
trace("products");
break;
case services_mc :
trace("services");
break;
case contact_mc :
trace("contact");
break;
}}
if [home,about,products,services,contact],
and [Btnhome,Btnabout,Btnproducts,Btnservices,Btncontact] are object instance Name's, then your code is wrong.
But in that case, you can position them once, then each time set them visible/invisible with this;
// set as invisible
myArray[i].visible = false;
// set as visible
myArray[i].visible = true;
Else, if you have to re-create them each time, then you must specify an Object Class for your objects, and call them with their object classes
var mc = new myObjClass();
And to give object classes names that you can refer from your code, do the following;
In your Library panel,
Select the MovieClip you want to create instances of,
[Right-Click] > Properties...
Check Export for ActionScript
And give Class name below. Then use that class name in your code to create new MovieClip instances of it every time.
Depending on your Flash version that process can be slightly different. But you can google it anyway.
Hope that helps.
Okay I will try to help you one more time. But you must talk to the people trying to help you. If you dont understand just ask. Also at least up-vote useful answers to your questions or mark as correct if it works okay. Otherwise no-one wants to type tutorials (because there is Google and ActionScript manual for that).
The best way to test my shown code is... Make a new blank FLA file and save to some folder. Now go to Properties (ctrl+F3) and in the Class: box type in there Array_buttons_v1 (press enter and save FLA again). Now you can click the pencil icon next to Class: box to edit your Class document. You will replace that auto-code with mine shown below.. (in photo: MyClass becomes Array_buttons_v1)
image borrowed from: Adobe.com
You will also need 5 movieClips in your library (ctrl+L). That is one movieClip to use as button MC and then four other movieClips to be added on stage when you click. Each one in Library must be right-clicked and choose "properties" then in Linkage section tick Export for Actionscript and use the following name in Class box shown there..
one small MC as button use: btn_MC (later we make MC clickable just like a real button)
other four MCs to add when button clicked use: MC1, MC2, MC3, MC4
Now you can use the main Properties (crtl+F3) to click the pencil icon (see pencil in photo) and delete all that automatic code and paste this code there.. (try to understand what code is doing, not just copy+paste..). It makes four buttons from MC class name btn_MC into some array and then loads other four MCs to array then from Mc array can add to screen too. Hope it helps
package
{
//** You will need more IMPORTS as you use other Flash features (APIs)
//** But these two is enough here.. check AS3 manual or tutorials for what to add
import flash.display.MovieClip;
import flash.events.*;
public class Array_buttons_v1 extends MovieClip
{
public var MC_Array:Array = []; //new array is empty
public var Btn_Array:Array = [];
public var MC_0 : MC1 = new MC1();
public var MC_1 : MC2 = new MC2();
public var MC_2 : MC3 = new MC3();
public var MC_3 : MC4 = new MC4();
public var btn_0 : btn_MC = new btn_MC();
public var btn_1 : btn_MC = new btn_MC();
public var btn_2 : btn_MC = new btn_MC();
public var btn_3 : btn_MC = new btn_MC();
public var mClips_holder : MovieClip = new MovieClip;
public var buttons_holder : MovieClip = new MovieClip;
public function Array_buttons_v1()
{
//** Update MC array.. items are counted from 0,1,2,3 (NOT 1,2,3,4)
MC_Array = [ MC_0, MC_1, MC_2, MC_3 ]; //meaning array pos [ 0, 1, 2, 3 ]
stage.addChild( mClips_holder ); //will hold
mClips_holder.y = 70; //move down so its not blocking anything
//** Update Buttons array
Btn_Array = [ btn_0, btn_1, btn_2, btn_3 ];
stage.addChild( buttons_holder ); //put Button holder on stage
//buttons_holder.addChild( Btn_Array [0] ); //put Buttons inside holder
var insert_pos:int = 0; //will use as screen "adding position" for buttons
//** To add all in array.. we start from pos of 0 and count up to 3
//** For every count number we do instructions inside { } until count finished
for (var arr_pos:int = 0; arr_pos <= 3; arr_pos++) //create some counter
{
trace("position inside the array is now : " + arr_pos);
//** setup instance Names for movieClips inside the MC Array
//** later you can access each one by name using "getChildByName" as MC_1 or MC_2 etc..
MC_Array[arr_pos].name = "MC_" + ( String(arr_pos) );
//** setup Buttons (names, clicked functions etc )..
Btn_Array[arr_pos].name = "button_" + ( String(arr_pos) );
Btn_Array[arr_pos].buttonMode = true; //make clickable before adding to screen
Btn_Array[arr_pos].addEventListener(MouseEvent.CLICK, button_Clicked);
buttons_holder.addChildAt( Btn_Array [arr_pos], arr_pos ); //add to container
buttons_holder.getChildAt(arr_pos).x = insert_pos;
trace("pos of btn is now : " + buttons_holder.getChildAt(arr_pos).x);
//update the adding position amount
insert_pos += 50; //add +50 pixels distance for next item
} //end For loop
}
public function button_Clicked ( evt :MouseEvent ) : void
{
//** Use "evt" because it matches with above "evt:MouseEvent" for access
trace( "Button name: " + evt.currentTarget.name + " ..was clicked" );
//** Now you can use IF statement to run another function(s)
//if (evt.currentTarget.name == "button_0") { some_Test(); }
//** or Use SWITCH statement (better and easier)
switch (evt.currentTarget.name)
{
case "button_0" :
//mClips_holder.addChild(MC_0); //** can be done like this ..
mClips_holder.addChild( MC_Array[0] ); //but you wanted from array so do this way..
mClips_holder.getChildByName("MC_0").x = 0;
some_Test(); //to do some other function
//** to stop this button listening for mouse clicked
//Btn_Array[0].removeEventListener(MouseEvent.CLICK, button_Clicked);
break;
case "button_1" :
mClips_holder.addChild(MC_1);
mClips_holder.getChildByName("MC_1").x = 40;
//Btn_Array[1].removeEventListener(MouseEvent.CLICK, button_Clicked);
break;
case "button_2" :
mClips_holder.addChild(MC_2);
mClips_holder.getChildByName("MC_2").x = 80;
//Btn_Array[2].removeEventListener(MouseEvent.CLICK, button_Clicked);
break;
case "button_3" :
mClips_holder.addChild(MC_3);
mClips_holder.getChildByName("MC_3").x = 120;
break;
} //end Switch/Case
}
public function some_Test ( ) : void
{
trace(" ### This is some other function... do extra things in this section");
//your extra code here..
}
}
}

How to apply drag and drop function to all frames in movie clip? Actionscript3

Each frame contain 1 text field. I apply the code on timeline.
But it only gets applied to the last object, which means that I can only drag and drop the last object. Why?
How can I improve this so that I can drag and drop all objects?
for(var j:uint=0; j<3; j++)
{
var q:Ans = new Ans();
q.stop();
q.x = j * 300+50;// set position
q.y = 500;
var r:uint = Math.floor(Math.random() * q_list.length);
q.qface = q_list[r];// assign face to card
q_list.splice(r,1);// remove face from list;
q.gotoAndStop(q.qface+1);
q.addEventListener(MouseEvent.MOUSE_DOWN, startAnsDrag);
q.addEventListener(MouseEvent.MOUSE_UP, stopAnsDrag);
q.addEventListener(Event.ENTER_FRAME, dragAns);
addChild(q);// show the card
}
//----------------------------drag
// offset between sprite location and click
var clickOffset:Point = null;
// user clicked
function startAnsDrag(event:MouseEvent) :void
{
clickOffset = new Point(event.localX, event.localY);
}
// user released
function stopAnsDrag(event:MouseEvent) :void
{
clickOffset = null;
}
// run every frame
function dragAns(event:Event) :void
{
if (clickOffset != null)
{ // must be dragging
q.x = clickOffset.x+mouseX+135;
q.y = clickOffset.y+mouseY;
}
}
Make a new layer in the timeline just for your drag-and-drop code, which you can remove from your other actionscript. Put the code on the first frame in that layer. Now click on and select the last frame on that layer in which you want the code to be effective (probably the last frame of the MovieClip). Press F5 to draw-out the range of frames which will be affected by the code. Voila!

How to get index of a Bitmap Image from bitmapdata(from an Array)?

I am wondering if i have an Array that push content that is Bitmap, how do i get index of a specific image when clicked. I tried to use indexOf but no luck, my codes are below.
Thanks for your time!
Code:
//First Part is where i add the URLRequest and add the image into contentHolder then onto Stage
function loadImage():void {
for(var i:int = 5; i < somedata.length; i++){
if(somedata[i]){
var loader:Loader = new Loader();
loader.load(new URLRequest("http://www.rentaid.info/rent/"+somedata[i]));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
}
}
}
function onImageLoaded(e:Event):void {
loadedArray.push(e.target.content as Bitmap);
for(var i:int = 0; i < loadedArray.length; i++){
var currentY1:int = 200;
e.currentTarget.loader.content.height =200;
e.currentTarget.loader.content.y += currentY1;
currentY1 += e.currentTarget.loader.content.height +300;
_contentHolder.mouseChildren = false; // ignore children mouseEvents
_contentHolder.mouseEnabled = true; // enable mouse on the object - normally set to true by default
_contentHolder.useHandCursor = true; // add hand cursor on mouse over
_contentHolder.buttonMode = true;
_contentHolder.addChild(loadedArray[i]);
addChild(_contentHolder);
_contentHolder.addEventListener(MouseEvent.CLICK, gotoscene);
}
}
// then the part where i try to get the index
function gotoscene(e:MouseEvent):void {
var index:Number;
index = loadedArray.indexOf(e.target);
trace(index);
}
Edit:
var viewport:Viewport = new Viewport();
viewport.y = 0;
viewport.addChild(_contentHolder);
Your first question has very simple answer:
var image:Bitmap = new Bitmap();
var images:Array = new Array(image);
for (var i:uint = 0; i < images.length; i++) {
// images[i].bitmapData is the original image in your array
// image.bitmapData is searched one
if (images[i].bitmapData == image.bitmapData) {
// found
}
}
But your problem is bigger than this. I see you keep wandering around..
You should add listener to each child, not the content holder as one. I usually don't use Loaders, but get their Bitmaps and wrap them in Sprites or something, that I add into the scene. You should store either this Sprite or your Loader into that array, not the Bitmap. Then add listener to each of them (Sprite or Loader, not Bitmap) and get the target. Depending on what you've stored in the array, you can easily get it as:
function gotoscene(e:MouseEvent):void {
var index:uint = loadedArray(indexOf(e.target));
}
But it's important to store one specific type that will actually be clickable. Don't think about the Bitmap - it's only a graphic representation, and doesn't do much in the code.
**EDIT:
Okay I'm adding the code you need but it's important to understand what you are doing and not just rely on someone else's answer :)
function onImageLoaded(e:Event):void {
var bitmap:Bitmap = e.target.content as Bitmap; // get the Bitmap
var image:Sprite = new Sprite();
image.addChild(bitmap); // wrap it inside new Sprite
// add listener to Sprite!
image.addEventListener(MouseEvent.CLICK, gotoscene);
// gets url of current image (http://website.com/images/image1.jpg)
var url:String = e.target.loaderURL;
// get only the number from that url by replacing or by some other way
// this removes the first part and results in "1.jpg"
var name:String = url.replace("http://website.com/images/image", "");
// this removes the extension and results in number only - 1, 2, 3
// it's important to change this depending on your naming convention
name = name.replace(".jpg", "");
image.name = "button" + name; // results in "button1", "button2", "button3"
// store object, name, or whatever (not really needed in your case, but commonly used)
loadedArray.push(image.name);
image.x = counter * 100; // position so you can see them, at 100, 200, 300, etc.
_contentHolder.addChild(image); // add newly created Sprite to content
}
function gotoscene(e:MouseEvent):void {
var name:String = e.target.name;
// strips down "button" from "button1", and only the number remains,
// which is 1, 2, 3, etc. the number of the scene :)
var scene:uint = name.replace("button", "");
// you're the man now :)
}

Multiple movieclips all go to the same spot; What am i doing wrong?

So I'm trying to shoot multiple bullets out of my body and it all works except I have an odd problem of just one bullet showing up and updating to set position for the new ones.
I have a move able player thats supposed to shoot and I test this code by moving the player and shooting. Im taking it step by step in creating this.
The result of tracing the bulletContainer counts correctly in that its telling me that movieclips ARE being added to the stage; I Just know it comes down to some kind of logic that im forgetting.
Here's My Code (The Bullet it self is a class)
UPDATE*
Everything in this code works fine except for I stated earlier some code seems reduntned because I've resorted to a different approaches.
BulletGod Class:
public class bulletGod extends MovieClip{
//Register Variables
//~Global
var globalPath = "http://127.0.0.1/fleshvirusv3/serverside/"
//~MovieCLips
var newBullet:bulletClass = new bulletClass();
//~Boolean
var loadingBulletInProgress:Number = 0;
var shootingWeapon:Number = 0;
//~Timers
var fireBulletsInterval = setInterval(fireBullets, 1);
var bulletFireEvent;
//~Arrays
var bulletArray:Array = new Array();
var bulletType:Array = new Array();
var bulletContainer:Array = new Array();
//~Networking
var netBulletRequest:URLRequest = new URLRequest(globalPath+"bullets.php");
var netBulletVariables:URLVariables = new URLVariables();
var netBulletLoader:URLLoader = new URLLoader();
//~Bullet Image Loader
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest();
public function bulletGod() {
//Load every bullet for every gun
//Compile data to be requested
netBulletVariables.act = "loadBullets"
netBulletRequest.method = URLRequestMethod.POST
netBulletRequest.data = netBulletVariables;
netBulletLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
netBulletLoader.addEventListener(Event.COMPLETE, getBulletImages);
netBulletLoader.load(netBulletRequest);
}
private function getBulletImages(bulletImageData:Event){
//Request every bullet URL image
//Set vars
var bulletData = bulletImageData.target.data;
//Load images
for(var i:Number = 0; i < bulletData.numBullets; i++){
bulletArray.push(bulletData["id"+i.toString()]);
bulletType.push(bulletData["bullet"+i.toString()]);
//trace(bulletData["id"+i]+"-"+bulletData["bullet"+i]);
}
//All the arrays have been set start firing the image loader/replacer
var imageLoaderInterval = setInterval(imageReplacer, 10);
}
private function imageReplacer(){
//Check to see which image needs replacing
if(!loadingBulletInProgress){
//Begin loading the next image
//Search for the next "String" in the bulletType:Array, and replace it with an image
for(var i:Number = 0; i < bulletType.length; i++){
if(getQualifiedClassName(bulletType[i]) == "String"){
//Load this image
mRequest = new URLRequest(globalPath+"ammo/"+bulletType[i]);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadImage);
mLoader.load(mRequest);
//Stop imageReplacer() while we load image
loadingBulletInProgress = 1;
//Stop this for() loop while we load image
i = 999;
}
}
}
}
private function loadImage(BlackHole:Event){
//Image has loaded; find which array slot it needs to go into
for(var i:Number = 0; i <= bulletType.length; i++){
if(getQualifiedClassName(bulletType[i]) == "String"){
//We found which array type it belongs to; now replace the text/url location with the actual image data
var tmpNewBullet:MovieClip = new MovieClip;
tmpNewBullet.addChild(mLoader);
//Add image to array
bulletType[i] = tmpNewBullet;
//Restart loadingBullets if there are more left
loadingBulletInProgress = 0;
//Stop for() loop
i = 999;
}
}
}
//###############################################################################################################################################
private function fireBullets(){
//If player is holding down mouse; Fire weapon at rate of fire.
if(shootingWeapon >= 1){
if(bulletFireEvent == null){
//Start shooting bullets
bulletFireEvent = setInterval(allowShooting, 500);
}
}
if(shootingWeapon == 0){
//The user is not shooting so stop all bullets from firing
if(bulletFireEvent != null){
//Strop firing bullets
clearInterval(bulletFireEvent);
bulletFireEvent = null
}
}
}
private function allowShooting(){
//This function actually adds the bullets on screen
//Search for correct bullet/ammo image to attach
var bulletId:Number = 0;
for(var i:Number = 0; i < bulletArray.length; i++){
if(bulletArray[i] == shootingWeapon){
//Bullet found
bulletId = i;
//End For() loop
i = 999;
}
}
//Create new bullet
//Create Tmp Bullet
var tmpBulletId:MovieClip = new MovieClip
tmpBulletId.addChild(newBullet);
tmpBulletId.addChild(bulletType[bulletId]);
//Add To Stage
addChild(tmpBulletId)
bulletContainer.push(tmpBulletId); //Add to array of bullets
//Orientate this bullet from players body
var bulletTmpId:Number = bulletContainer.length
bulletTmpId--;
bulletContainer[bulletTmpId].x = Object(root).localSurvivor.x
bulletContainer[bulletTmpId].y = Object(root).localSurvivor.y
//addChild(bulletContainer[bulletTmpId]);
}
//_______________EXTERNAL EVENTS_______________________
public function fireBullet(weaponId:Number){
shootingWeapon = weaponId;
}
public function stopFireBullets(){
shootingWeapon = 0;
}
}
}
BulletClass:
package com{
import flash.display.*
import flash.utils.*
import flash.net.*
import flash.events.*
public class bulletClass extends MovieClip {
public var damage:Number = 0;
public function bulletClass() {
//SOME MOVEMENT CODE HERE
}
public function addAvatar(Obj:MovieClip){
this.addChild(Obj);
}
}
}
Well ... if I may say so, this code looks quite wrong. Either something is missing from the code or this code will never make the bullets fly.
First off, you can set x and y of the new bullet directly (replace everything after "orientate this bullet from players body" with this):
tmpBulletId.x = Object(root).localSurvivor.x;
tmpBulletId.y = Object(root).localSurvivor.y;
Perhaps this already helps, but your code there should already do the same.
But to let these bullets fly into any direction, you also need to add an event listener, like so:
tmpBulletId.addEventListener(Event.ENTER_FRAME, moveBullet);
function moveBullet(e:Event) {
var movedBullet:MovieClip = MovieClip(e.currentTarget);
if (movedBullet.x < 0 || movedBullet.x > movedBullet.stage.width ||
movedBullet.y < 0 || movedBullet.y > movedBullet.stage.height) {
// remove move listener, because the bullet moved out of stage
movedBullet.removeEventListener(Event.ENTER_FRAME);
}
// remove the comment (the //) from the line that you need
MovieClip(e.currentTarget).x += 1; // move right
// MovieClip(e.currentTarget).y -= 1; // move up
// MovieClip(e.currentTarget).x -= 1; // move left
// MovieClip(e.currentTarget).y += 1; // move down
}
This example lets your bullet fly to the right. If you need it flying into another direction, just comment out the line with the "move right" comment and uncomment one of the other lines.
This is of course a very simple example, but it should get you started.
I hope this helps, and that my answer is not the wrong answer to the question.
As far as I have expirienced it you can have only one copy of MovieClip object added to specific child. Best approach is to use ByteArray for the clip source and instantiate new MovieClip and pass the ByteArray as a source. It have something to do with child/parent relation since a DisplayObject can have only one parent (and a way to detach the object from scene too).
Well i ended up writeing the whole code from scratch for a 3rd time and ran into a similar problem and just for reference to anybody else that comes to a problem thats random as this one i found that problem was likly does to a conversion error somewhere that doesn't necessarily break any compiling rules. Just that i was calling a movieclip and not the class it self.