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

How can I associate unique information/ variables with different instances of attachMovie when creat

Explorer ,
Jun 10, 2013 Jun 10, 2013

I'm creating an interactive animation of an experiment, whereby the user has to detect if there is an oil well lying beneath the surface by selecting and drilling a series of coordination points on a map.

I've done the first stage by setting up a background image containing a grid of 20 x 20 coordinate points, eg columns 1 - 20 and rows A - T. Over the top of this, I've created a dynamic array of clickable objects (open circles) and the centre of each one is  placed over a coordinate point, so when you mouseover a coordinate point, eg C3,  an open circle becomes visible and when you rollout, it becomes invisible again.

However, I'm stuck on the next stage. I need to be able to assign unique variables to one or more clickable objects (open circles). Is it possible to do that? For example:

a)give grid point coordinates to each object (open circle), so for example if someone rolls over the C3 coordinate, the open circle (object) associated with that coordinate, a message will display: "Click on the grid point to drill at C3"

b)assign a variable to one or more objects, so that when an open circle is clicked, the animation associated with that coordination point will be triggered. There will be different animations, depending upon which object (point is clicked)

There are other variables that will need to be setup, but if I know how to assign variables to one or more objects, I can probably figure out the rest.

Here's a copy of my code so far:-

//set up grid for solid array

spacing = 5.75;

cols = 20; // number of columns in grid

rows = 20; // number of rows in grid

leftMargin = 154;

topMargin = 169;

depth = 100; // starting point for depth

for (i=1; i<=rows; i++) {                                                                                                       

for (j=1; j<=cols; j++) {                                                                                                        

current = attachMovie("openCircle_mc", "openCircle_mc"+i+"_"+j, depth++);

current._x = leftMargin + ((i-1) * (spacing + current._width));

current._y = topMargin + ((j-1) * (spacing + current._height));

//open circle initially invisible, visible on rollOver

current._alpha = 0;

current.onRollOver = function() {

           this._alpha = 100;

          }

current.onRollOut = function() {

           this._alpha = 0;

          }

}

}

Below is the background and a rolled over instance of the 'openCircle' object at 'C3'.

Screen shot 2013-06-10 at 16.20.07.png

I'd very much appreciate some help. Thanks very much.

Pippa

TOPICS
ActionScript
676
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 , Jun 10, 2013 Jun 10, 2013

you can assign properties (and methods) to movieclips:

//set up grid for solid array

spacing = 5.75;

cols = 20; // number of columns in grid

rows = 20; // number of rows in grid

leftMargin = 154;

topMargin = 169;

depth = 100; // starting point for depth

for (i=1; i<=rows; i++) {                                                                                                        

for (j=1; j<=cols; j++) {                                                                                                   

...
Translate
Community Expert ,
Jun 10, 2013 Jun 10, 2013

you can assign properties (and methods) to movieclips:

//set up grid for solid array

spacing = 5.75;

cols = 20; // number of columns in grid

rows = 20; // number of rows in grid

leftMargin = 154;

topMargin = 169;

depth = 100; // starting point for depth

for (i=1; i<=rows; i++) {                                                                                                        

for (j=1; j<=cols; j++) {                                                                                                         

current = attachMovie("openCircle_mc", "openCircle_mc"+i+"_"+j, depth++);

current._x = leftMargin + ((i-1) * (spacing + current._width));

current._y = topMargin + ((j-1) * (spacing + current._height));

current.row=i;

current.col=j;

current.oil = Math.floor(Math.random()*1.1);  // about 1/10 objects have oil=1, 9/10 oil=0

//open circle initially invisible, visible on rollOver

current._alpha = 0;

current.onRelease=function(){

trace(this.row+" "+this.col+" "+this.oil);

}

current.onRollOver = function() {

           this._alpha = 100;

          }

current.onRollOut = function() {

           this._alpha = 0;

          }

}

}

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
Explorer ,
Jun 10, 2013 Jun 10, 2013

Thanks very much. I'll have a good look at it in the morning.

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 ,
Jun 10, 2013 Jun 10, 2013

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
Explorer ,
Jun 11, 2013 Jun 11, 2013

That's great and works very well. Much appreciated. Onto the next stage now!

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 ,
Jun 11, 2013 Jun 11, 2013
LATEST

great!  good luck with the next stage..

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