dna23
Member
Registered: 1st Nov 04
Location: Northamptonshire
User status: Offline
|
Been looking through: http://laco.wz.cz/tween/
Fancied doing something like this:
http://laco.wz.cz/tween/swf/showswf.php?swf=zooming_icons&w=700&h=300
.fla download: http://laco.wz.cz/tween/down.php?f=fla/zooming_icons.fla
But I have no idea within the .fla how to make each one linked to something, it's all written in ActionScript with one movieclip for the button.
code: #include "lmc_tween_as1.as"
//
init();
function init() {
timeline = _root;
iconlinkage = "smallIcon_mc";
squarecount = 8;
maxcolumns = 4;
//
x_border = 2;
y_border = 22;
//
leftbound = 50;
topbound = 50;
//
maxScale = 300;
normalScale = 100;
//
icons = [];
for (var i = 0; i<squarecount; i++) {
var ico = timeline.attachMovie(iconlinkage, "ico_"+i, i);
var idx = i%maxcolumns;
var idy = Math.floor(i/maxcolumns);
//
ico.sx = ico._x=leftbound+(idx)*(ico._width+x_border);
ico.sy = ico._y=topbound+(idy)*(ico._height+y_border);
//
if (icons[idy] == undefined) {
icons[idy] = [];
}
ico.idx = idx;
ico.idy = idy;
ico.label = i
ico.onRollOver = function() {
scaleIcon(this, maxscale);
};
ico.onRollOut = function() {
scaleIcon(this, normalscale);
};
//
icons[idy][idx] = ico;
}
}
//
function moverows(idx, idy, mc) {
var i = 0;
while (i+idx<maxcolumns) {
i++;
icons[idy][idx+i]._x = mc._x+x_border+mc._width+(i-1)*(icons[idy][idx+i]._width+x_border);
}
}
function scaleIcon(mc, endScale) {
mc.scaleTo(endScale, .3, "easeoutback", 0, {updfunc:moverows, updscope:_root, updargs:[mc.idx, mc.idy, mc]});
}
|
Cosmo
Member
Registered: 29th Mar 01
Location: Im the real one!
User status: Offline
|
I have no idea what Im on about really, but would you not need some sort of onClick(or whatever) function?
|
dna23
Member
Registered: 1st Nov 04
Location: Northamptonshire
User status: Offline
|
yes I would Cosmo, but like you this is my first time using flash and i'm perplexed.
It seems to create the layout by using mathematical equations based on rows, columns and total number. I'm therefore unsure how I apply a certain OnClick function to a certain movie clip.
|
Paul_J
Member
Registered: 6th Jun 02
Location: London
User status: Offline
|
you just need to step through it all... (p.s. I don't know flash actionscript, but i know other languages).
for example...
it looks like there's an array of icons set by icons []
It goes into a loop (of i) so i = 0 incrementing to i = square count.
each time it's in that loop
it does things to do with ico
var ico = timeline.attachMovie(iconlinkage, "ico_"+i, i);
which are actually gathering the information for the icon and getting it ready to be displayed.
at the same time it sets up
var idx = i%maxcolumns;
var idy = Math.floor(i/maxcolumns);
idx = id of the column and idy = id of the row.
So i = normal increment...
So as they go through, you'll get
0,1,2,3,4,5,6,7,8,9 etc
now max column = 4
so as i goes through the value of idy = i / max column.
so i = 0 idy = 0, i = 1 idy = 0, i = 2 idy = 0, i = 3 idy = 0, i = 4 idy = 1, i = 5 idy = 1, i = 6 idy = 1, i = 7 idy = 1, i = 8 idy = 2, i = 9 idy = 2 etc
So basically it's getting the value of i dividing it by max columns and then 'floor'ing it down to the next whole number downwards.
at same time similar is being worked out for idx, except its i%maxcolumns - not sure what % equals in actionscript, maybe a div or mod or something?
but probably just ends up with like
idx = 0,1,2,3 - 0,1,2,3 - 0,1,2,3. - 0,1,2,3
i ... = 0,1,2,3 - 4,5,6,7 - 8,9,10 etc
it sets up all this info on ico. like actions for ico.
and then finally binds it to a icon array.
icons[idy][idx] = ico;
^ so this is giving a co-ordinate of where it is, idy, idx.
using the math from before the 3rd down and 2nd across would probably be icon[2,1] (in real terms).
So... anyway...
after these two (but before it gets assigned to icon array)
ico.onRollOver = function() {
scaleIcon(this, maxscale);
};
ico.onRollOut = function() {
scaleIcon(this, normalscale);
};
Just add a ico.onClick or mouse down event or something to trigger your movie.
if you need to do something like (change the value inside one of the icons, you use the co-ordinates of the icon[idy,idx].
|
Paul_J
Member
Registered: 6th Jun 02
Location: London
User status: Offline
|
so... put something like this after those 'onrollout' events but before it assigns it to Icon[idx,idy]
ico.onRelease = function() {
//code to do the activation of the movie..
// or call a function to do what you want
};
thing is, I don't think the examples you've shown the links to work properly on my screen, as they don't play movies or anything, they just show numbers that appear bigger and smaller.
|
Paul_J
Member
Registered: 6th Jun 02
Location: London
User status: Offline
|
and in the above, it actually goes to 8 on each row hah... but i wasn't really looking. so 0,1,2,3,4,5,6,7 for idx values.
[Edited on 03-04-2008 by Paul_J]
|
dna23
Member
Registered: 1st Nov 04
Location: Northamptonshire
User status: Offline
|
Thanks Paul, very helpful analysis... i'll have a play about tomorrow and post back the results 
As you say, when you break it down like that you can start to see whats being done.
|
Cosmo
Member
Registered: 29th Mar 01
Location: Im the real one!
User status: Offline
|
So I was kind of right 
God those VBasic (or whatever they were) lessons from 6yrs ago must of taught me something
|
|