I need some tips and help

  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

Let say, I got an object A (sheep.gif) which I convert to Movie Clip. I want to assign a value (a coordinate that indicate the postion of the sheep) to it such that x = 32 and y = 12.

Then there is a textbox. When I type 3212 in the textbox, the sheep.gif will appear on field.gif (also convert to Movie Clip). However, when it appear on field.gif, I want the size of the sheep to be resized 10 times smaller.

If I type anything else on the textbox other than 3212, then a popup box saying "Wrong! Please try again." will appear.

Anyone can help me?
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

You need to assign a var name to the text field, then do some AS to test for the value of that field

Something along the lines of :

Code: [ Select ]
on(release) {
if(_root.yourTextFieldVarName = 3212) {
_root.mcName._alpha = 100;
} else {
_root.aHiddenTextFieldVarName = "Wrong!";
}
}
  1. on(release) {
  2. if(_root.yourTextFieldVarName = 3212) {
  3. _root.mcName._alpha = 100;
  4. } else {
  5. _root.aHiddenTextFieldVarName = "Wrong!";
  6. }
  7. }
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

Hmm, then how do I assign x = 32 and y = 12 to the sheep????
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

Sorry about that, i think it'll be better if I assign 3212 to the sheep. One value enough. :D
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Place the following code on your sheep mc :

Code: [ Select ]
onClipEvent(load) {
_root.yourSheepMcName._x = 32;
_root.yourSheepMcName._y = 12;
_root.yourSheepMcName._alpha = 0;
}
  1. onClipEvent(load) {
  2. _root.yourSheepMcName._x = 32;
  3. _root.yourSheepMcName._y = 12;
  4. _root.yourSheepMcName._alpha = 0;
  5. }
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

hmm quite tedious..

Let say i have game.swf.

Each time I open the file, the sheep will be randomly position on the field.jpg (Movie Clip).

See pic below for screenshot of how I would like it to look like.

First time enter
Image.

Second time
Image



Then let say one of the sheep is position at 526, 211. So I stype 526211 at the textbox and if it's correct, the sheep will disappear. If wrong, an error message will pop up.


Any kind souls willing to assist me? Really bad in programming.
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Random Position :

Code: [ Select ]
Movieclip.prototype.randomPos=function(width,height){
    _x=Math.floor(Math.random()*width)
    _y=Math.floor(Math.random()*height)
}
  1. Movieclip.prototype.randomPos=function(width,height){
  2.     _x=Math.floor(Math.random()*width)
  3.     _y=Math.floor(Math.random()*height)
  4. }



Textbox :

Textbox VAR Name = myBox

Code: [ Select ]
on(release) {
if(_root.myBox = 3212) {
_root.mcName.removeMovieClip();
} else {
_root.aHiddenTextFieldVarName = "Wrong!";
}
}
  1. on(release) {
  2. if(_root.myBox = 3212) {
  3. _root.mcName.removeMovieClip();
  4. } else {
  5. _root.aHiddenTextFieldVarName = "Wrong!";
  6. }
  7. }
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

hmm where do i put the

Code: [ Select ]
Movieclip.prototype.randomPos=function(width,height){
    _x=Math.floor(Math.random()*width)
    _y=Math.floor(Math.random()*height)
}
  1. Movieclip.prototype.randomPos=function(width,height){
  2.     _x=Math.floor(Math.random()*width)
  3.     _y=Math.floor(Math.random()*height)
  4. }


???

How to make sure they appear within the green field provided??
Also notice the 21 22 23 and 52 53 54 around the boundaries of the green field.

Eg. Position of sheep: 211521
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Take the following code :

Code: [ Select ]
onClipEvent(load) {
    _x=Math.floor(Math.random()*width) //where width is the width of your stage
    _y=Math.floor(Math.random()*height) //where height is the height of your stage
}
  1. onClipEvent(load) {
  2.     _x=Math.floor(Math.random()*width) //where width is the width of your stage
  3.     _y=Math.floor(Math.random()*height) //where height is the height of your stage
  4. }
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

hmmm where do i place it? :(
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Place it in the actions panel of your mc
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

ok i type that and yes it appear randomly but how to make it appear within the green field only? the whole size of the flash file is 800px by 540px.
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

Replace the text width and height with your parameters and jobs a goodun.
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

How to know the parameters in the first place? I replace it with 300 for width and 300 for height and it appear only on the left hand side of the flash file. :cry:
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

The width & height parameters are the width and height of your stage. Remeber that point 0,0 is the top left corner of your stage not the centre of it !
  • adiboy
  • Newbie
  • Newbie
  • adiboy
  • Posts: 14

Post 3+ Months Ago

Attach is the whole stage. What do you think is the parameters? :?

onClipEvent(load) {
_x=Math.floor(Math.random()*width) //where width is the width of your stage
_y=Math.floor(Math.random()*height) //where height is the height of your stage
}

Size of stage: 800px by 540px

Image
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

If you only want the sheep to appear in the green area then you need to find out what the height and width dimensions of that area are.

Simply clicking on it and looking in the properties panel should tell you this [ thats assuming that the geen area is a seperate object ].

Post Information

  • Total Posts in this topic: 17 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.