Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating random words using movie clips?

Status
Not open for further replies.

pmoorey

Technical User
Mar 19, 2007
144
GB
Hi

I have been making a memory game, where words are shown to the user. Once they have memorised the words they go to the next screen where the words that they have memorised are shown. They then have to drag each word into a "correct" place and a "wrong" place. I now want to edit it so that I can use two arrays one for correct words and one for wrong words. I want to generate random words from each of these arrays. I have sort of worked out how this is possible to do but using dynamic text, but am I correct in thinking that the whole dragging the words thing is not possible with dynamic text. (I may be wrong though, I am quite new to flash). Are you able to do this with movie clips, or can anyone advise me on how it would be possible to do this?

Thanks


Peter
CCNA, Cisco Qualified Specialist
 
It's yes and no.

TextFields do not have [tt]startDrag()[/tt] and [tt]stopDrag()[/tt] functions, however, you can still make them drag-able using a combination of [tt]MOUSE_DOWN[/tt], [tt]MOUSE_UP[/tt], and [tt]MOUSE_MOVE[/tt] events.

Of course using [tt]startDrag()[/tt] and [tt]stopDrag()[/tt] is far easier and less time-consuming though, so I would place the TextField in a Sprite and make the Sprite drag-able.

Kenneth Kawamoto
 
Thanks for the reply

I am using actionscript 2 is sprite an actionscript 3 class? I have made an array of movie clips, when the button is pressed one mc appears. If you press the button again the next one appears but on top of the previous one. Is there away to solve this? Also is there a way to make more than just the one mc appear when the button is pressed?

Thanks

Peter
CCNA, Cisco Qualified Specialist
 
AS2 [tt]attachMovie()[/tt] takes an Object as parameter and you can use it to specify the location.
e.g. [tt]this.attachMovie("mc", "mc1", this.getNextHighestDepth(), {_x:100, _y:100});[/tt]


Kenneth Kawamoto
 
That worked great thanks! Do you know how I can get more than just the one mc to show up when the button is pressed? I have tried a few things but can't seen to get anything to work.

Thanks Again!

Peter
CCNA, Cisco Qualified Specialist
 
Thanks for the help. I have just realised that if I make the movie clips appear once the button has been pressed that they do not appear on the selection menu in the action section for me to be able to enable them to be dragged, is there a way I can get around this?

Thanks

Peter
CCNA, Cisco Qualified Specialist
 
In the eariler version of the game (which did not use arrays) each word movieclip was able to be dragged by the user, this is the code I used for each of the movieclips


Code:
on (press) {
	startDrag(this);
	_root.correct._visible = false;
	_root.wrong._visible = false;
	
}
on (release) {
	stopDrag();
	if ((this._x>=810) & (this._x<=970) & (this._y>=460) & (this._y<=700)) {
		_root.correct._visible = true;
		_root.went._visible = false;
		_root.bin.play();
	}else if ((this._x>=50) & (this._x<=270) & (this._y>=460) & (this._y<=700)) {
		_root.wrong._visible = true;
	} else {
		_root.choose._visible = true;
	}
}

but because the movieclips now are created by the press of a button they are not on the stage, I can not assign the above code to the movieclips.

Thanks for your help


Peter
CCNA, Cisco Qualified Specialist
 
There are more than one way to do this, but if I to keep things closer to as they are now, I'd create a transparent MovieClip and place on the top layer of your word MovieClip. Then you can attach your script to the invisible MovieClip. The script has to be:
Code:
on (press) {
   startDrag(_parent);
   [i]...etc[/i]    
}
Because you are now dragging the _parent of the invisible MovieClip = the word MovieClip.

Kenneth Kawamoto
 
Thanks, I am not too sure how to go about this. I dont have the movie clips on the stage to asign the code to or do I put them on the stage to be able to do this? Sorry for being a pain.

Thanks

Peter
CCNA, Cisco Qualified Specialist
 
Oh right of course sorry I was confused. That has worked thanks. I am now just trying to fix it so that the movieclips are not visible after they have been placed. Thats what I had them do before but it doesn't seem to to it now, must have something wrong with my _.visible statement do I need to edit this in anyway?

Thanks a lot for all your help

Peter
CCNA, Cisco Qualified Specialist
 
The movieclip in that particular part of code was named "went". ( _root.went._visible = false;)

Thanks

Peter
CCNA, Cisco Qualified Specialist
 
It is returning that it is undefined

Peter
CCNA, Cisco Qualified Specialist
 
It is returning that it is undefined

Peter
CCNA, Cisco Qualified Specialist
 
I have given both the actual word and the shape over the top to make it dragable instance names?

Peter
CCNA, Cisco Qualified Specialist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top