Skip to main content
Known Participant
February 25, 2014
Answered

How to make an item be remembered once the page is changed?

  • February 25, 2014
  • 1 reply
  • 854 views

Hi,

For my school project I am trying to create a drag and drop product on Adobe Flash CS4 using Action Script 3.0.

I have three keyframes:

- The first one has tops to be dragged and dropped onto the model

-The second one has skirts/trousers to be dragged and dropped onto the model

-The third has shoes to be dragged and dropped onto the model

But once the top has been dragged and droped and the next button is selected displaying the skirts/trousers, the top which has been dragged and dropped onto the model is no longer displayed.

Does anyone know what coding I need to add to get each item of clothing to be remembered once it has been dragged and dropped onto the model, so it is visible on the following pages?

Many Thanks

This topic has been closed for replies.
Correct answer kglad

extend the layer that includes your tops to your 3rd frame.  in frame 2, assign all the tops' visible property to false except the one dragged onto your model.  likewise for your skirts/trousers.

or you could probably apply e.currentTarget.parent.addChild(e.currentTarget) to the drop listener function when something is dropped on the model.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 25, 2014

extend the layer that includes your tops to your 3rd frame.  in frame 2, assign all the tops' visible property to false except the one dragged onto your model.  likewise for your skirts/trousers.

or you could probably apply e.currentTarget.parent.addChild(e.currentTarget) to the drop listener function when something is dropped on the model.

Known Participant
February 27, 2014

Thank you very much for your response.

I'm so sorry, this is probably a really silly question but how can I make the items of clothing hidden on the layers where I don't want them seen?

I am also having real problems with my 'next' button in the second key frame.

I am recieving two errors for this button and have tried everything that I can think of, so was wondering if you were able to have a look at my coding for this button and tell me if it is correct bearing in mind that the button is on the second keyframe but should take you to the third.

The first error I am recieving is:

'TypeError: Error #1010: A term is undefined and has no properties'

for the line

'femaleDragAndDropPage.femaleMenu.nextButtonBottoms.addEventListener(MouseEvent.CLICK, onNextButtonBottomsClick);'

-The nextButtonBottoms is the button leading from the second to the third key frame-

The second error I have is:

'TypeError: Error #1034: Type Coercion failed: cannot convert NextButton@246159c1 to PinkNextButton.

at flash.display::MovieClip/gotoAndStop()
at Main/onNextButton3Click()'

for the line

'femaleDragAndDropPage.femaleMenu.gotoAndStop(2);'

-This line is for my next button on the first keyframe which leads to the second one and only appears when it is selected-

On the first keyframe, there is also a next button (with a different instance name) which leads to the second keyframe which works fine so I used the same coding for the next button leading from the second to third keyframe but changed the instance name. This is where I then recieved the errors so cannot view the rest of my pages which come after this one.

Thank ypu so much for your help!

kglad
Community Expert
Community Expert
February 28, 2014

I have managed to resolve my last error but would still really appreciate your help in getting my drag and drop to be remembered and resolving: 'TypeError: Error #1010: A term is undefined and has no properties'

Thanks once again for all your help


assign variables to store the value of the last dragged top, for example:

var draggedTop:Movieclip;

then in your drop listeners use:

draggedTop=event.currentTarget;

and on your pants page use:

for(loop through all your tops){

assign their visible property to false

}

draggedTop.visible=true;