Question about Macromedia Flash MX

2 Answers

Multiple MovieClips in Flash Action Script 2.0

Hi,

I have one problem in my project...

ie) i want know multiple movieclips or objects are moved randomly without hit the hitarea like these shopping game..

http://www.gamebrew.com/game/shopping-mania/play

Posted by on

2 Answers

Hi,

very thanks to fixya team....

but already i solve this probs with help of getbounds...

any way its very usefull to me for future.......

thanks........

regards

ganganpat

Posted on Sep 29, 2008

  • Level 1:

    An expert who has achieved level 1.

    Governor:

    An expert whose answer got voted for 20 times.

    Corporal:

    An expert that has over 10 points.

    Mayor:

    An expert whose answer got voted for 2 times.

  • Contributor
  • 12 Answers

Step:-1 - Start
Step:-2 - Create 15 Movie Clip as Circle on Flash scene.
Step:-3 - Name them [circle0 to circle14].
Step:-4 - Paste the code on keyframe in timeline just above the keyframe where circle movieclips are present.
Code:-
//---------------
import mx.transitions.Tween;


target_mc = ["circle0", "circle1", "circle2", "circle3", "circle4", "circle5","circle6", "circle7", "circle8", "circle9", "circle10",
"circle11", "circle12", "circle13", "circle14", "circle15","circle16", "circle17", "circle18", "circle19", "circle20"];

var myTween:Tween = new Tween(circle0, "_x", mx.transitions.easing.None.easeNone,0, Stage.width, 15, true);
myTween.onMotionFinished = function() {
myTween.yoyo();
};
var myTween1:Tween = new Tween(circle0, "_y", mx.transitions.easing.None.easeNone,0, Stage.height, 20, true);
myTween1.onMotionFinished = function() {
myTween1.yoyo();
};

hitTester = function () {
numCircles = target_mc.length;
for (i=0; i<numCircles; i++) {
circleA = target_mc[i];
for (j=i+1; j<numCircles; j++) {
circleB = target_mc[j];
temp_A = eval(circleA);
temp_B = eval(circleB);
if (temp_A.hitTest(temp_B))
{
// Your code
dirChanger(temp_A, temp_B);
//
}
}
}
};
this.onEnterFrame = function() {
hitTester();
};
//
// In the createMovies function, I am looping through each movieclip in our target_mc array and
// modify some properties and data that I will use later on. The rest of the functions are
// are trivial to moving the circles and adjusting their direction of movement.
//
createMovies = function () {
for (i=1; i<target_mc.length; i++) {
xp = Math.round(Math.random()*300);
yp = Math.round(Math.random()*200);
eval("circle"+i).speed = 4+Math.round(Math.random()*1);
eval("circle"+i).dir = Math.round(Math.random()*1);
eval("circle"+i).dir2 = Math.round(Math.random()*1);
eval("circle"+i).onEnterFrame = function() {
if (this.dir == 0)
{
vertical(this._name, this.speed, this.dir2);
}
else
{
hortical(this._name, this.speed, this.dir2);
}
};
}
};
createMovies();
vertical = function (cname, speed, dir2) {
mY = eval(cname);
this.cy = mY._y;
if (dir2 == 0) {
if ((this.cy<200) || (mY.hit<100)) {
mY._y += speed;
}
else
{
mY._y = -50;
}
}
else
{
if ((this.cy>0) || (mY.hit<100))
{
mY._y -= speed;
}
else
{
mY._y = 250;
// change
}
}
};
hortical = function (cname, speed, dir2) {
mX = eval(cname);
this.cx = mX._x;
if (dir2 == 0) {
if (this.cx<300)
{
mX._x += speed;
}
else
{
mX._x = -50;
}
}
else
{
if (this.cx>0)
{
mX._x -= speed;
}
else
{
mX._x = 350;
//change
}
}
};
dirChanger = function (cname, dname) {
//
if ((cname.dir == 0) && (dname.dir == 0))
{
cname.dir = 1;
dname.dir = 0;
}
else if ((cname.dir == 1) && (dname.dir == 1))
{
cname.dir = 0;
dname.dir = 1;
}
else if ((cname.dir == 0) && (dname.dir == 1))
{
cname.dir = 1;
dname.dir = 0;
}
else if ((cname.dir == 1) && (dname.dir == 0))
{
cname.dir = 0;
dname.dir = 1;
}
//
if (cname.dir2 == 0) {
cname.dir2 = 1;
}
else
{
cname.dir2 = 0;
}

if (dname.dir2 == 0) {
dname.dir2 = 1;
}
else
{
dname.dir2 = 0;
}
};
//--------------------
Step:-5 - Test movie using Ctrl+Enter.
Step:-6 - End

Posted on Sep 26, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

2 Answers

ACTIONSCRIPT 3.0 BUILDING SIMPLE WEBSITE FLASH CS4


you can try this site http://www.xnynz.com/.
I built my own website from this site.
It provides best features.

Oct 12, 2009 | Adobe Flash Pro CS4 for PC

2 Answers

Flash script


You should know programming. If you know it, you could write scripts in Action Pan in Flash or other editors.
I suggest you this website:
http://www.flashkit.net/
you can find all your answers here. Enjoy it.
Good luck

Feb 04, 2009 | Graphics Publishing, Design & Multimedia...

1 Answer

CS3 Action Scripting - How do i get buttons to link to scenes?


it looks crazy but AS 3.0 is too easy and takes half of the time what you took to learn flash AS 2.0 . Button Script in AS 2.0 is like below and you were able to put the script in buttons/movieClip
on(release){
whatTodo();
}
but in as3.0 only you can use frames to add script and must use listeners for buttons. like
buttonName.addEventListener(MouseEvent.CLICK,dothis);
function dothis(evt:Event){
do_this_function();
}
evt:Event is must. it is passing the event object when u click on button.

Nov 19, 2008 | Macromedia Flash MX

1 Answer

Loading movie


var loadListener:Object = new Object();
loadListener.onLoadInit = function(target_mc:MovieClip):Void {
target_mc.play();
}
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("ani.swf", mc);

Sep 18, 2008 | Macromedia Flash MX

1 Answer

Uploading of a swf file into another swf file in a specific locoation


step-1: take rectangle shape
step-2: convert it to movieclip by pressing right mouse button the choose convert to symbol.
step-3: during convert choose the [Registration] as left corner.
step-4: place the movieclip where u need to place in scene and resize it as your requirement.
step-5: this open the movieclip.
step-6: Add new layer in timeline.
step-7: write this code.
this.loadMovie("file_name.swf", get);
step-8: Then test (Run) your movie.

Feb 13, 2008 | Macromedia Flash MX

2 Answers

Skip intro button action script


Dear nic_hk, in macromedia there is an option of removing the intro by checking the skip this box or by checking the box that says 'dont show me this screen again'

About flash action script this is a complete resource for learning it along with embedded java scripting.

If that has helped you please press 'fixya'

Nov 27, 2007 | Adobe Photoshop 7.0 for PC

1 Answer

DuplicateMovieClip command


Don't write the code inside the movie clip. Also use the following code. I've added one more line which will move your duplicated movie clip 100 pixels right so that you can view both.

duplicateMovieClip("_root.one_mc","one1_mc",2);
setProperty("_root.one1_mc", _xscale, "30");
setProperty("_root.one1_mc", _x, getProperty("_root.one1_mc",_x)+100);

Oct 12, 2007 | Macromedia Flash MX

2 Answers

Movie clip script problem


hi rananjay is here the link is given bellow ,where you find your solution http://www.actionscript.org/resources/articles/538/1/Creating-a-Scrolling-menu/Page1.html

Sep 16, 2007 | Macromedia Flash MX

1 Answer

Action script


first u create a movieclip then rightclick then "edit in place".then u select that object then convert it to button it is very easy one try it

Sep 03, 2007 | Macromedia Flash MX

9 Answers

Action script


I tried your script and it all checked out fine when I ran it. Make sure you click on the first frame of layer action and open the Action Script Panel (F9). Once this is accomplished. Click on the second frame of layer action and press F6 key. Like I said everything worked out when I tried using the script you posted so, if anything I would suggest starting from scratch.

Aug 24, 2007 | Macromedia Flash MX

Not finding what you are looking for?
Macromedia Flash MX Logo

Related Topics:

541 people viewed this question

Ask a Question

Usually answered in minutes!

Top Macromedia Graphics Publishing, Design & Multimedia Software Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18298 Answers

Tony

Level 3 Expert

2598 Answers

Sunny Solanki
Sunny Solanki

Level 2 Expert

261 Answers

Are you a Macromedia Graphics Publishing, Design and Multimedia Software Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...