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

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

New Here ,
Feb 25, 2014 Feb 25, 2014

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

TOPICS
ActionScript
815
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 , Feb 25, 2014 Feb 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.

Translate
Community Expert ,
Feb 25, 2014 Feb 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.

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 ,
Feb 27, 2014 Feb 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!

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 ,
Feb 27, 2014 Feb 27, 2014

how can I make the items of clothing hidden on the layers where I don't want them seen?

again, assign their visible property to false.  for example, if you want tshirt1 to be invisible, use:

tshirt1.visible=false;

I am also having real problems with my 'next' button in the second key frame. 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(M ouseEvent.CLICK, onNextButtonBottomsClick);'

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

either femaleDragAndDropPage or femaleDragAndDropPage.femaleMenu or femaleDragAndDropPage.femaleMenu.nextButtonBottoms don't exist when that code executes.

The second error I have is:

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

somewhere (possibly a listener function where you're casting an event's currentTarget) you're trying to coerce NextButton to a PinkNextButton.
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 ,
Feb 27, 2014 Feb 27, 2014

I understand what you are saying but I have 10 possible tops which could be put onto the model but I want the one that the user selects to be remembered on the bottoms page but rather than having the 9 remaining tops shown in the right, I would now like the 10 possible trousers/shirts to be displayed. However, if I make everything invisible on the second frame, the top that has been dragged will no longer be displayed as it will also have to be made invisible to prevent it being shown under the botttoms. -Is there not an 'if' statement I can use for one of the possible 10 top/bottoms/shoes to be remembered?

The error #1010 is in the 'nextButtonBottoms' as the rest of the line has been used for other buttons and works fine however the coding and design is the same for this button as it is the button leading from the first to the second keyframe so I am unsure why there is an issue with this button.

The 'PinkNextButton' is what the button is originally called so everything else has a instance name from it.

Thanks once again for your help and sorry for all the questions, I am just up against it with this project but cannot resolve the errors or get my drag and drop to be remembered throughtout the pages.

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 ,
Feb 27, 2014 Feb 27, 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

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 ,
Feb 28, 2014 Feb 28, 2014

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;

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 ,
Mar 03, 2014 Mar 03, 2014

okay thank you!

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 ,
Mar 03, 2014 Mar 03, 2014
LATEST

you're welcome.

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