Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I bring in front the objects in adobe flash when dragging and send it back.

New Here ,
Jul 17, 2015 Jul 17, 2015

Its a mobile game. Adobe flash cs6

TOPICS
ActionScript
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 17, 2015 Jul 17, 2015

Leo Angelo Laude wrote:

but i have many objects to be drag. it is possible to have one function?

yes, that's why i posted, '(but you should actually be using one function for all your startDrag() and another function for all your stopDrag() methods so you don't have to write the same code repeatedly.)'

you should be using something like:

var draggedObject:MovieClip;

var draggableObjectsA:Array=[...];

for(var i:int=0;i<draggableObjectsA.length;i++){

draggableObjectsA.addEventListener(MouseEvent.MOU

...
Translate
Community Expert ,
Jul 17, 2015 Jul 17, 2015

with your startDrag(), use:

whatever.parent.addChild(whatever);  // where whatever is the object that's starting to be dragged.

with stopDrag(), use:

whatever.parent.addChildAt(whatever,0);  // to add at bottom of display list

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2015 Jul 17, 2015

function dragDressKatipon1(m:MouseEvent){

mcDressKatipon.startDrag(true);
datingX=458;
datingY=300;
}

function undragDressKatipon1(m:MouseEvent){

mcDressKatipon.stopDrag();
  if (mcFigure.hitTestObject(mcDressKatipon)&& rightAns == 1){
trace("tama");
scoreDressCode++;
txtDressCodeScore.text = "" + scoreDressCode;
//txtDressCodeScore2.text = "" + scoreDressCode;
DressCode();
TweenLite.to(mcDressKatipon, 1, { x:1082.40, y: 304.15});
TweenLite.to(mcDressKatipon, 1, {x:datingX, y:datingY, delay:2, ease:Elastic.easeOut});
TweenLite.to(mccorrectDressCode, 1, {rotation: 360,  x:975.9, y: 6.55, ease:Elastic.easeInOut});
TweenLite.to(mccorrectDressCode, 2, {rotation: 360, delay:2, x:-975.9, y: -6.55, ease:Elastic.easeInOut});
}
else if(mcFigure.hitTestObject(mcDressKatipon) && rightAns != 1 ){
trace("mali");
wrong_DressCode++;
TweenLite.to(mcDressKatipon, 1, {x:datingX, y:datingY, ease:Elastic.easeOut});
if(wrong_DressCode == 1)
TweenLite.to(mcFirstLife, 1, {scaleX:0, scaleY:0});
}
if(wrong_DressCode > 1)
{
TweenLite.to(mcThirdLife, 1, {scaleX:0, scaleY:0});
}
if(wrong_DressCode > 2)
{
TweenLite.to(mcThirdLife, 1, {scaleX:0, scaleY:0});
TweenLite.to(GameOverDressCode, 1, {x:641.15, y:361.1});
TweenLite.to(txtScoreDressCode2, 1, {delay:.5, x:588, y:354.15});
TweenLite.to(mcPlayDressCode, 1, {delay:1, x:652.3, y:612.9});
}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2015 Jul 17, 2015

Leo Angelo Laude wrote:

function dragDressKatipon1(m:MouseEvent){

mcDressKatipon.startDrag(true);

mcDressKatipon.parent.addChild(mcDressKatipon);

datingX=458;

datingY=300;
}

function undragDressKatipon1(m:MouseEvent){

mcDressKatipon.stopDrag();

mcDressKatipon.parent.addChildAt(mcDressKatipon,0);

  if (mcFigure.hitTestObject(mcDressKatipon)&& rightAns == 1){
trace("tama");
scoreDressCode++;
txtDressCodeScore.text = "" + scoreDressCode;
//txtDressCodeScore2.text = "" + scoreDressCode;
DressCode();
TweenLite.to(mcDressKatipon, 1, { x:1082.40, y: 304.15});
TweenLite.to(mcDressKatipon, 1, {x:datingX, y:datingY, delay:2, ease:Elastic.easeOut});
TweenLite.to(mccorrectDressCode, 1, {rotation: 360,  x:975.9, y: 6.55, ease:Elastic.easeInOut});
TweenLite.to(mccorrectDressCode, 2, {rotation: 360, delay:2, x:-975.9, y: -6.55, ease:Elastic.easeInOut});
}
else if(mcFigure.hitTestObject(mcDressKatipon) && rightAns != 1 ){
trace("mali");
wrong_DressCode++;
TweenLite.to(mcDressKatipon, 1, {x:datingX, y:datingY, ease:Elastic.easeOut});
if(wrong_DressCode == 1)
TweenLite.to(mcFirstLife, 1, {scaleX:0, scaleY:0});
}
if(wrong_DressCode > 1)
{
TweenLite.to(mcThirdLife, 1, {scaleX:0, scaleY:0});
}
if(wrong_DressCode > 2)
{
TweenLite.to(mcThirdLife, 1, {scaleX:0, scaleY:0});
TweenLite.to(GameOverDressCode, 1, {x:641.15, y:361.1});
TweenLite.to(txtScoreDressCode2, 1, {delay:.5, x:588, y:354.15});
TweenLite.to(mcPlayDressCode, 1, {delay:1, x:652.3, y:612.9});
}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2015 Jul 17, 2015

thanks but when i drag into mcFigure (the container) it goes at the back.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2015 Jul 17, 2015

add the same code to mcFigure.

(but you should actually be using one function for all your startDrag() and another function for all your stopDrag() methods so you don't have to write the same code repeatedly.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2015 Jul 17, 2015

but i have many objects to be drag. it is possible to have one function?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2015 Jul 17, 2015

Leo Angelo Laude wrote:

but i have many objects to be drag. it is possible to have one function?

yes, that's why i posted, '(but you should actually be using one function for all your startDrag() and another function for all your stopDrag() methods so you don't have to write the same code repeatedly.)'

you should be using something like:

var draggedObject:MovieClip;

var draggableObjectsA:Array=[...];

for(var i:int=0;i<draggableObjectsA.length;i++){

draggableObjectsA.addEventListener(MouseEvent.MOUSE_DOWN,startdragF);

draggableObjectsA.origIndex=draggableObjectsA.parent.getChildIndex(draggableObjectsA);

}

function startdragF(e:MouseEvent):void{

draggedObject=e.currentTarget;

draggedObject.startDrag();

draggedObject.parent.addChild(draggedObject);

stage.addEventListener(MouseEvent.MOUSE_UP,stopdragF);

}
function stopdragF(e:MouseEvent):void{

draggedObject.stopDrag();

draggedObject.parent.addChildAt(draggedObject.origIndex);

stage.removeEventListener(MouseEvent.MOUSE_UP,stopdragF);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2015 Jul 17, 2015

if (mcFigure.hitTestObject(mcDressKatipon)&& rightAns == 1){

  

  mcDressKatipon.parent.addChildAt(mcDressKatipon, 155);

  trace("tama");

  scoreDressCode++;

  txtDressCodeScore.text = "" + scoreDressCode;

  //txtDressCodeScore2.text = "" + scoreDressCode;

  DressCode();

  TweenLite.to(mcDressKatipon, 1, { x:1082.40, y: 304.15});

  TweenLite.to(mcDressKatipon, 1, {delay:2, x:datingX, y:datingY, ease:Elastic.easeOut});

  TweenLite.to(mccorrectDressCode, 1, {rotation: 360,  x:975.9, y: 6.55, ease:Elastic.easeInOut});

  TweenLite.to(mccorrectDressCode, 2, {delay:2, rotation: 360,  x:-975.9, y: -6.55, ease:Elastic.easeInOut});

  }

look at the bold line. i added. it works. but after dragging a the object and back again, the object goes in front

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2015 Jul 17, 2015

Leo Angelo Laude wrote:

if (mcFigure.hitTestObject(mcDressKatipon)&& rightAns == 1){

 

  mcDressKatipon.parent.addChildAt(mcDressKatipon, 155);

that's not the code i suggested and almost certainly will cause a problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2015 Jul 17, 2015

Untitled.png

when i drag the dress into the human body its right. it goes in front. but after that i dress goes front also. let me send you the next picture

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2015 Jul 17, 2015

1.png

here the dress Katipun goes in front. It should the like bayani and kawal dress which is at the back

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2015 Jul 18, 2015

use the code in message 10.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015

i dont uderstand the code. sorry.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2015 Jul 18, 2015

just add your objects to var draggableObjectsA:Array=[...];

and use the code instead of the drag and drop code you're currently using.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015

i make new file

it has error

draggedObject=e.currentTarget;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.EventDispatcher;
import flash.events.Event;

var draggedObject:MovieClip;

var draggableObjectsA:Array=[mcBox];

for(var i:int=0;i<draggableObjectsA.length;i++){

draggableObjectsA.addEventListener(MouseEvent.MOUSE_DOWN,startdragF);

draggableObjectsA.origIndex=draggableObjectsA.parent.getChildIndex(draggableObjectsA );

}

function startdragF(e:MouseEvent){

draggedObject=e.currentTarget;

draggedObject.startDrag();

draggedObject.parent.addChild(draggedObject);

stage.addEventListener(MouseEvent.MOUSE_UP,stopdragF);

}

function stopdragF(e:MouseEvent){

draggedObject.stopDrag();

draggedObject.parent.addChildAt(draggedObject.origIndex);

stage.removeEventListener(MouseEvent.MOUSE_UP,stopdragF);

}

CHECK THIS. COPY AND PASTE

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2015 Jul 18, 2015

if the error is an implicit coercion error, use

draggedObject=MovieClip(e.currentTarget);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015

how about this?

draggedObject.parent.addChildAt(draggedObject.origIndex);

incorrect number of documents. Expected 2

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2015 Jul 18, 2015

use:

draggedObject.parent.addChildAt(draggedObject,draggedObject.origIndex);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015

thanks you so much. you helped me a lot

how about in not overlapping the falling objects?

(sorry for many questions)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2015 Jul 18, 2015

check your other thread about that.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015

how or where can I mark it as correct answers.

Sent from my iPhone

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2015 Jul 18, 2015

go to the forum using a full browser, How can I bring in front the objects in adobe flash when dragging and send it back.

and click correct answer:

Capture.PNG

and you may also be able to mark helpful answers by clicking actions:

Capture.PNG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2015 Jul 18, 2015

i maeked the message 10. but ib 21 dont have a correct answer button

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines