View Full Version : [FMX] Shape Tweening With Ease Via AS
Digitalosophy
July 20th, 2003, 08:55 PM
Hi I have hit a road block yet again. How would I go about tweening a simple square with AS and with ease. Figure a box about 30x30 to about 300x300.
Thanks in advance
ahmed
July 20th, 2003, 09:07 PM
// part 1
box = createEmptyMovieClip("mc", ++depth);
box.beginFill(0xff6600, 70)
box.moveTo(-15, -15)
box.lineTo(-15, 15)
box.lineTo(15, 15)
box.lineTo(15, -15)
box.lineTo(-15, -15)
box._x = (Stage.height/2)-15
box._y = (Stage.width/2)-15
// part 2
box.onEnterFrame = function() {
var diff = Math.round(300-this._width)
this._width += diff/4
this._height += diff/4
}
the first part of the script draws the box and positions it at the middle of the stage.. the second part does the easing :)
Digitalosophy
July 20th, 2003, 09:46 PM
thank you very much, that was an excellent example :)
ahmed
July 20th, 2003, 10:24 PM
in these two lines
this._width += diff/4
this._height += diff/4 try different values instead of 4 :)
Digitalosophy
July 24th, 2003, 12:21 AM
A3, i can't seem to make a border around my mc that i created. i looked up the drawing methods in the reference but can't seem to find what i need. i then thought of creating an addition mc that would be just the border or the box(mc) but i also can't figure out how to take the fill out. when i use endFill() the box dissapears. any ideas?
thanks
ahmed
July 24th, 2003, 12:25 AM
can i have a look at the code (no fla:))
Digitalosophy
July 24th, 2003, 01:08 AM
yes you may
box = createEmptyMovieClip("mc", ++depth);
box.beginFill(0xffffff, 80)
box.moveTo(-5,-5)
box.lineTo(-5,5)
box.lineTo(5,5)
box.lineTo(5,-5)
box.lineTo(-5,-5)
box._x = 160
box._y = 225
box.onEnterFrame = function() {
var diff = Math.round(275-this._width)
this._width += diff/2
this._height += diff/2
}
i have 2 more boxes as well, but i wont post it cuz im sure you'll see what i mean
Digitalosophy
July 24th, 2003, 01:16 AM
oops ahmed i refered to you before as A3, sry about that :)
ahmed
July 24th, 2003, 01:24 AM
the code works fine here.. you're using white for fill color, maybe that's why you don't see it :beam:
Digitalosophy
July 24th, 2003, 01:25 AM
no no, i see it but i want it to have a different color border
ahmed
July 24th, 2003, 01:27 AM
aahh sorry
just use lineStyle(0, 0xff6600); instead of beginFill :)
Digitalosophy
July 24th, 2003, 01:29 AM
sweet i tryed something like that but i couldnt get it to work.
thanks again :)
wilma
July 24th, 2003, 05:33 AM
why not try
onClipEvent(load) {
_x = 0
_y = 0
scaleSpeed = 10
speed = 5
endx = 300
endy = 300
}
onClipEvent(enterFrame) {
this._xscale += (500 - this._xscale) / scaleSpeed; //or try scaleSpeed
this._yscale += (500 - this._yscale) / scaleSpeed;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.