corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Dab hand in flash?


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Dab hand in flash?
dna23
Member

Registered: 1st Nov 04
Location: Northamptonshire
User status: Offline
3rd Apr 08 at 19:34   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 19:47   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 20:14   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 20:52   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 21:00   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 21:01   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 21:10   View User's Profile U2U Member Reply With Quote

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
3rd Apr 08 at 21:32   View User's Profile U2U Member Reply With Quote

So I was kind of right

God those VBasic (or whatever they were) lessons from 6yrs ago must of taught me something

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
DAB Radio greengoddess General Chat 3 490
3rd Jun 04 at 18:10
by DanielJ
 
DAB ready stereos greycorsa Help Zone, Modification and ICE Advice 3 404
4th Jul 04 at 18:18
by Trucido
 
headlight problem a_j_mair Help Zone, Modification and ICE Advice 6 380
7th Oct 04 at 16:16
by 1800ed
 
Ye Tamriel Times Steve Geek Day 106 1419
7th Mar 07 at 10:37
by Steve
 
How do you?? lockie2002 General Chat 8 497
30th Mar 08 at 12:08
by Dave A
 

Corsa Sport » Message Board » Off Day » Geek Day » Dab hand in flash? 28 database queries in 0.0069039 seconds