Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-05-2012, 01:42 AM   #121
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

you're funny jenn

I thought you said there was no errors?
Ok, what's happening is you are calling dragDrop(), before the image is finished loading, so in turn, you are calling it before slicePuzzle() has been called at the end of the load, or in other words, the array has not been filled with pieces yet.

What we have to do is wait for the load to finish, let me have a look at it for a few minutes, I'll try to think of an easy way to explain it.

It might just be easier if you enable dragging automatically from within the Puzzle class whe the image has loaded, would that suit you or do you want to retain the ability to control that from outside the class?
sparX is offline   Reply With Quote
Old 05-05-2012, 01:47 AM   #122
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

Well that's easier now that you showed me your MainTimeline code.
Just move puzzle.dragDrop() into the startPuzzle() function.

But you still have the problem of being able to click that start button before the load is complete.

I'll just give you a quick fix for it, I don't think it is something you need to confuse yourself with right now, but I never know with you what you are going to understand.
sparX is offline   Reply With Quote
Old 05-05-2012, 02:08 AM   #123
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

Ok, from your loadingDone() function in the puzzle class, we are just going to redispatch the event object that is passed to that function. We will then listen on the 'puzzle' instance on the timeline for an event of that type, & when that occurs, enable the start button.
Make sense?

Add this to end of loadingDone() function,
ActionScript Code:
dispatchEvent(event);

Add this to your mainTimeline,
ActionScript Code:
puzzle.addEventListener(Event.COMPLETE, puzzleReady); function puzzleReady(e:Event):void {      start_bt.addEventListener(MouseEvent.CLICK, startPuzzle); }

There could be other little mistiming problems I'm just not noticing. I'm relying on you for testing, so tell me the errors if they happen
sparX is offline   Reply With Quote
Old 05-05-2012, 02:17 AM   #124
jenn_tran
Member
 
Join Date: Apr 2012
Posts: 78
Default

The puzzle is back to working, but it is loading shuffled now. I had it loading complete and the start button would shuffle it. At this point im not picky, but there is not much point of a start button if its loading shuffled already.

Also the drag drop is still working after the puzzle is competed.

correctIndex0
correctIndex1
correctIndex2
correctIndex3
correctIndex4
correctIndex5
correctIndex6
correctIndex7
correctIndex8
correctIndex9
correctIndex10
correctIndex11
correctIndex12
correctIndex13
correctIndex14
correctIndex15
correctIndex16
correctIndex17
correctIndex18
correctIndex19
correctIndex20
correctIndex21
correctIndex22
correctIndex23
correctIndex24
correctIndex25
correctIndex26
correctIndex27
correctIndex28
correctIndex29
correctIndex30
correctIndex31
correctIndex32
correctIndex33
correctIndex34
correctIndex35
yes, I am calling puzzle.dragDrop() from the mainTimeline
number correct= 0 : total pieces= 36
number correct= 0 : total pieces= 36
correctIndex0
correctIndex1
correctIndex2
correctIndex3
correctIndex4
correctIndex5
correctIndex6
correctIndex7
correctIndex8
number correct= 1 : total pieces= 9
yes, I am calling puzzle.dragDrop() from the mainTimeline
number correct= 5 : total pieces= 9
number correct= 6 : total pieces= 9
number correct= 7 : total pieces= 9
number correct= 7 : total pieces= 9
number correct= 9 : total pieces= 9
number correct= 7 : total pieces= 9
number correct= 9 : total pieces= 9
jenn_tran is offline   Reply With Quote
Old 05-05-2012, 02:32 AM   #125
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

jenn, do me a favour?
get rid of that trace for 'correctIndex' in the PieceContainer class

I can't see where it would be doing that, the only call to shufflePieces() should be coming from your mainTimeline, & that call should be in the start button click handler.

Go through your code & find all calls to shufflePieces() & tell me where they are.

In FlashBuilder, there should be some button that says something along the lines of "Find All References", you should be able to select the shufflePieces function name & then it will display everywhere it is being called in your code as well as the function declaration.

edit: sorry misread you, you shouldn't be able to drag any pieces once they have fallen in place.

Last edited by sparX; 05-05-2012 at 02:35 AM.
sparX is offline   Reply With Quote
Old 05-05-2012, 02:35 AM   #126
jenn_tran
Member
 
Join Date: Apr 2012
Posts: 78
Default

Found it. Fixed it. OMG something was easy. Thank you.
jenn_tran is offline   Reply With Quote
Old 05-05-2012, 02:37 AM   #127
jenn_tran
Member
 
Join Date: Apr 2012
Posts: 78
Default

And you still can drag after they have all fallen into place, but i'm going to bed, my head hurts. thank you so much
jenn_tran is offline   Reply With Quote
Old 05-05-2012, 03:00 AM   #128
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

lol... I was just looking for your drag after correct problem & noticed a bug in my own logic... sorry, I'll get off my lazy arse & test it myself...
sparX is offline   Reply With Quote
Old 05-06-2012, 10:04 AM   #129
jenn_tran
Member
 
Join Date: Apr 2012
Posts: 78
Default

Good morning.

I'm sure you will laugh at me, that's ok, i'm cool with it. Is there a way to un-call a function. I'm trying to unload the bitmap of the puzzle and load the bitmap of the preview.

also, I can't figure out why my function calls from the main timeline never work. it's " puzzle.functionname" correct? Thank you Jenn

ActionScript Code:
else             {                 piece1.x = origX;                 piece1.y = origY;                             }                         var numberOfCorrectPieces:int =0;                         for (var i:int; i < numPieces; i++)             {                 var piece:PieceContainer = puzzleObjects[i];                 if (piece.correctIndex == i)                 {                     ++numberOfCorrectPieces;                                         if (numberOfCorrectPieces >= numPieces)                     {                         piece.removeEventListener(MouseEvent.MOUSE_DOWN, drag);                         trace ("Done")                         piece.mouseEnabled = false                         previewImage(event);                         removeChild.(newPuzzlePiece);                     }                                     }             }                         trace("number correct=", numberOfCorrectPieces, ": total pieces=", numPieces);
jenn_tran is offline   Reply With Quote
Old 05-06-2012, 09:33 PM   #130
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

Good morning jenn.
monday, bloody monday...
It's refreshing to meet someone not afraid to be laughed at. The way we are currently headed, human will soon be listed under invertebrate...

What exactly does "un-call" mean?
"Oops, I called a function, function.pleaseStopImmediately()"?
"function.executeInReverse()"?

Perhaps you mean,
"You know the thing that last function I called did? How do I make another function that does the opposite?"?
"How can I pass different parameters to my function to make it do different things?"?

Anyway, you don't need to be doing any "previewing" there, you will do that in a separate function, just finish what you're doing there first, the previewing is easy.

"puzzle.functionName" will just give you a reference to the function.
To call a function, use parentheses, & add a comma seperated list of any parameters that may be req'd by the function between the parens.
puzzle.functionName(parameter1,parameter2,etc)

Give me a look at the whole function you have there now, I have to fix my bug as well, if I can remember what it was...

btw, who put that call to locatePieces() in the middle of the drop function, was that you or me? just delete it, it ain't doing anything useful.
sparX is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:58 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.