[Flashcoders] Coding a circular preloader

68 views
Skip to first unread message

Omar Fouad

unread,
Aug 6, 2007, 5:23:58 AM8/6/07
to Flashcoders mailing list
Folks i was just wondering how to create a circular preloader with
actionscript. I thought about drawing many wedges increasing each time the
angle accodring the percentage loaded, but how can i include an easing
effect to this rotating motion?

Regards....

--
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
_______________________________________________
Flash...@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Ivan Dembicki

unread,
Aug 6, 2007, 6:37:17 AM8/6/07
to flash...@chattyfig.figleaf.com
Hello Omar,

try this:
http://proto.layer51.com/d.aspx?f=388


--
iv

Omar Fouad

unread,
Aug 6, 2007, 6:49:29 AM8/6/07
to flash...@chattyfig.figleaf.com
Woah!!! too complicated...

--

Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.

Omar Fouad

unread,
Aug 6, 2007, 7:06:36 AM8/6/07
to flash...@chattyfig.figleaf.com
that example is not working.,.

Ivan Dembicki

unread,
Aug 6, 2007, 7:23:25 AM8/6/07
to flash...@chattyfig.figleaf.com
Hello Omar,

possible... it's very old example.
try at this:

function drawSegment(target, rx, ry, x, y, sgm, s1, s2) {
var rad = Math.PI/180;
if (!s1 and !s2 or s1 == s2) {
var grad = 360;
var segm = grad/sgm;
var x1 = rx+x;
var y1 = y;
target.moveTo(x1, y1);
} else {
s1>s2 ? s1 -= 360 : "";
var x1 = rx*Math.cos(s1*rad)+x;
var y1 = ry*Math.sin(s1*rad)+y;
var grad = s2-s1;
var segm = grad/sgm;
target.moveTo(x, y);
target.lineTo(x1, y1);
}
for (var s = segm+s1; s<(grad+.1+s1); s += segm) {
var x2 = rx*Math.cos((s-segm/2)*rad)+x;
var y2 = ry*Math.sin((s-segm/2)*rad)+y;
var x3 = rx*Math.cos(s*rad)+x;
var y3 = ry*Math.sin(s*rad)+y;
// begin tnx 2 Robert Penner
var cx = 2*x2-.5*(x1+x3);
var cy = 2*y2-.5*(y1+y3);
target.curveTo(cx, cy, x3, y3);
// end tnx 2 Robert Penner :)
x1 = x3;
y1 = y3;
}
if (grad != 360) {
target.lineTo(x, y);
}
};


_root.onEnterFrame = function() {
_root.clear();
_root.lineStyle(0);
_root.beginFill(0xFF0000);
a= a||0
b=b||0
a>=360 ? a -= 360 : a += 2;
b>=360 ? b -= 360 : b += 3;
drawSegment(_root, 150, 100, 200, 250, 8, a, b);
_root.endFill();
_root.lineStyle(0);
_root.beginFill(0xFF00FF);
drawSegment(_root, 150, 100, 200, 200, 8, a, b);
_root.endFill();
};

Andreas R

unread,
Aug 6, 2007, 9:06:14 AM8/6/07
to flash...@chattyfig.figleaf.com
Out of curiosity, what are the "right" ways to calculate oscillations
like triangle, sawtooth and pulse? Ideally oscillation would work in
parallel with sine, so when sin=1, triangle=1, taking radians as the
frequency parameter.

Any takers?

- Andreas R

Omar Fouad

unread,
Aug 6, 2007, 11:18:15 AM8/6/07
to flash...@chattyfig.figleaf.com
ok i got something better and faster.

I downloaded some methods from
http://www.adobe.com/devnet/flash/articles/adv_draw_methods.html.
in this library there is an .as file wich lets u draw wedges easily (
drawWedges.as) but infortunately it doesnt support easing yet..

I am trying to add an easeOut effect to it, and i tried this way....

#include "drawWedge.as"
d_mc = _root.createEmptyMovieClip("drawing_layer",1);

angle=0
function wedge() {
this.onEnterFrame = function () {

newAngle = angle++

d_mc.clear();
d_mc.beginFill(0xFF0067, 100);
d_mc.drawWedge(200, 200, 90, newAngle, 100);
d_mc.endFill();

if(newAngle >=100) {
delete this.onEnterFrame;
}
}
};

wedge();

this way the wedge grows until the angle reaches 100. how can I add a
simple easing equation to this?

I always used mcTween and for some loadbar preloader i used to ease the
loadbar by adding

loadBar._xscale +=percent - loadBar._xscale/3; /// this way the loadBar
tweens with an easeOut Effect..
I tried to apply the same principle to the wedge but without results..

Any ideas?


--
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.

Cristo @ Cryzto.ch

unread,
Aug 6, 2007, 12:01:08 PM8/6/07
to flash...@chattyfig.figleaf.com
Hi Folks!

I've made a little example where I've got two Accordion- and 3
Button-Instances.

First I load two XMLs, one for each Accordion [navi_acc and model_acc].

When I push the 1.Button [models_btn], the 1. Accordion shows up [navi_acc].

Then when I push on one navi_acc-Element, the 2. Accordion shows up
[model_acc].

Now I've got two language-Buttons [German & English]. When I push on one of
these Buttons, each Accordion-Element is updated to the selected Lang.

The problem is: it works, the model_btn.label, all Button-Labels inside the
Accordions.but..

The labels of the Accordion-headers don't change."visually".but if I make a
trace of the labels'n names, they are!

You can see my example @ <http://www.cryzto.ch/index2.html>
www.cryzto.ch/index2.html !


Can someone helpme?

cryzto


_____

Ich verwende die kostenlose Version von SPAMfighter,
die bei mir bis jetzt 1614 Spammails entfernt hat.
Fur private Anwender ist SPAMfighter vollig kostenlos!
Jetzt gratis testen: hier klicken <http://www.spamfighter.com/lde> .

Palmer, Jim

unread,
Aug 6, 2007, 12:09:25 PM8/6/07
to flash...@chattyfig.figleaf.com

Just another bit of actionscript butchery here for a circular preloader that I use all over the place in my apps and pages...

http://www.overset.com/2006/09/27/flash-wait-animation-ie-browser-throbber/

--
Jim Palmer ! Mammoth Web Operations

Eric Walton

unread,
Aug 6, 2007, 12:30:38 PM8/6/07
to flash...@chattyfig.figleaf.com
you could try this.

http://www.flashkit.com/movies/Animations/Vector_Animations/People/Dancing_-DrF-11618/index.php

On 8/6/07, Omar Fouad <omarfo...@gmail.com> wrote:
>

--
Eric Walton 9 / Edub9

To view more about
The Artwork of Eric Walton 9 / Edub9
please visit the following:
www.hollywoodfineart.com
www.myspace.com/ericwalton9_edub9
Providentia Marketing LLC
754-246-7620 Cel

Omar Fouad

unread,
Aug 6, 2007, 1:10:40 PM8/6/07
to flash...@chattyfig.figleaf.com
Eric and Palmers thanks so much, i found something interesting here..
http://www.styluscanada.com/

Note the white preloader.. This is what i am talking about exactly...

Steven Sacks

unread,
Aug 6, 2007, 1:27:38 PM8/6/07
to flash...@chattyfig.figleaf.com
I jumped on this thread late, but it seems to me that the best/easiest
way to accomplish that circular preloader like you saw on that
photography site is with a 100 frame movieclip that contains a mask that
goes from frame 1-100 revealing a circle underneath. It would probably
take you all of 5 minutes to make.

Sometimes the simplest solution is the best solution.

Omar Fouad

unread,
Aug 6, 2007, 1:42:26 PM8/6/07
to flash...@chattyfig.figleaf.com
This way no there would be no easing... And ma boss say he wants it with
actionscript *GRRRRR^

--

Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.

Steven Sacks

unread,
Aug 6, 2007, 2:38:25 PM8/6/07
to flash...@chattyfig.figleaf.com
Easing? You're showing linear data. A visual representation of a
number from 0-100. I'm not sure how easing fits into this.

Your boss sounds like a real genius because it's absolutely brilliant to
force somebody to spend many hours building something that could be
built in 5 minutes - really smart use of time and money. He should
write a book on how to be successful in business.

Glen Pike

unread,
Aug 6, 2007, 4:22:57 PM8/6/07
to flash...@chattyfig.figleaf.com
Hi,

There are not really any right ways - just the fastest way to get
stuff out...

http://www.flashbrighton.org/wordpress/?p=9

http://www.flashbrighton.org/wordpress/?p=6

Can't find the drum machine article - they built one as part of a
contest with Flash Coders NY - source code here - check out the
ToneGenerator and the specific SawGenerator etc.

http://svn1.cvsdude.com/osflash/drummachine/PCMAudioLibrary/

Andre-Michelle has done some nice stuff, but not much source.

http://lab.andre-michelle.com/

These are probably okay for simple "one" off sounds, but if you are
building complex waveforms - e.g. adding lots of waves together at a
certain frequency, you may be better off building a wavetable then
reading sample values by interpolating - simple weighted addition of 2
samples indexed from an array. If you want some C++ code, then I can
dig it out for you, but the PCMAudioLibrary looks adequate...

You would have thought that FlashPlayer would have noise generators
built in for sound - they have them for images which have an extra
dimension, so are usually more processor intensive - c'mon Adobe, gimme
some audio tools already.

Hope this helps.

Glen

David Ngo

unread,
Aug 6, 2007, 4:24:32 PM8/6/07
to flash...@chattyfig.figleaf.com
Uh, you could implement easing but I'm of the same opinion as Steve here
where it wouldn't make any sense to kill an ant with a sledgehammer. At any
rate, the easing would be based off a timer instead of frames. Pseudo code
AS2 using the Tween class would be:

var interval:Number = setInterval(this, 'showProgress', 100);

function showProgress():Void
{
new Tween(scope, 'property', Easetype, currentVal, newVal, 0.1,
true);
}


You could change the interval and have the Tween's seconds be either equal
to or less than the interval.

Omar Fouad

unread,
Aug 6, 2007, 5:08:56 PM8/6/07
to flash...@chattyfig.figleaf.com
Hahaha Steven :D that was a good one ;). Thanks david.. but I don't have
it.. i'll try to convince my boss. But i would like to know the same how
that could be achieved like in the website.....

--
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.

David Ngo

unread,
Aug 6, 2007, 7:24:06 PM8/6/07
to flash...@chattyfig.figleaf.com
I'm not sure what you mean. What don't you have? The pseudo code I posted is
fairly easy to implement. If you're using the drawing API to render your
circle or partial circle, just tap into the Tween class' onMotionChanged
event to update your vector shape.

-----Original Message-----
From: flashcode...@chattyfig.figleaf.com
[mailto:flashcode...@chattyfig.figleaf.com] On Behalf Of Omar Fouad
Sent: Monday, August 06, 2007 5:09 PM
To: flash...@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Coding a circular preloader

Jesse Graupmann

unread,
Aug 6, 2007, 7:24:24 PM8/6/07
to flash...@chattyfig.figleaf.com

Using the arc prototype ( AS 1/2 ) from formequalsfunction draw methods;
http://www.formequalsfunction.com/downloads/drawmethods.html and Tweener (
AS 2 ) from http://code.google.com/p/tweener/ I put together a simple tween
version of the circle.

Assuming you have Tweener in the same directory, you can copy and paste this
example.

- JG

/*-------------------------------------------------------------
//
// http://www.formequalsfunction.com/downloads/drawmethods.html
//
mc.drawArc is a method for drawing regular and eliptical
arc segments. This method replaces one I originally
released to the Flash MX beta group titled arcTo and contains
several optimizations based on input from the following
people: Robert Penner, Eric Mueller and Michael Hurwicz.
-------------------------------------------------------------*/
MovieClip.prototype.drawArc = function(x, y, radius, arc, startAngle,
yRadius) {
// ==============
// mc.drawArc() - by Ric Ewing (r...@formequalsfunction.com) -
version 1.5 - 4.7.2002
//
// x, y = This must be the current pen position... other values will
look bad
// radius = radius of Arc. If [optional] yRadius is defined, then r
is the x radius
// arc = sweep of the arc. Negative values draw clockwise.
// startAngle = starting angle in degrees.
// yRadius = [optional] y radius of arc. Thanks to Robert Penner for
the idea.
// ==============
// Thanks to: Robert Penner, Eric Mueller and Michael Hurwicz for
their contributions.
// ==============
if (arguments.length<5) {
return;
}
// if yRadius is undefined, yRadius = radius
if (yRadius == undefined) {
yRadius = radius;
}
// Init vars
var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy;
// no sense in drawing more than is needed :)
if (Math.abs(arc)>360) {
arc = 360;
}
// Flash uses 8 segments per circle, to match that, we draw in a
maximum
// of 45 degree segments. First we calculate how many segments are
needed
// for our arc.
segs = Math.ceil(Math.abs(arc)/45);
// Now calculate the sweep of each segment
segAngle = arc/segs;
// The math requires radians rather than degrees. To convert from
degrees
// use the formula (degrees/180)*Math.PI to get radians.
theta = -(segAngle/180)*Math.PI;
// convert angle startAngle to radians
angle = -(startAngle/180)*Math.PI;
// find our starting points (ax,ay) relative to the secified x,y
ax = x-Math.cos(angle)*radius;
ay = y-Math.sin(angle)*yRadius;
// if our arc is larger than 45 degrees, draw as 45 degree segments
// so that we match Flash's native circle routines.
if (segs>0) {
// Loop for drawing arc segments
for (var i = 0; i<segs; i++) {
// increment our angle
angle += theta;
// find the angle halfway between the last angle and
the new
angleMid = angle-(theta/2);
// calculate our end point
bx = ax+Math.cos(angle)*radius;
by = ay+Math.sin(angle)*yRadius;
// calculate our control point
cx =
ax+Math.cos(angleMid)*(radius/Math.cos(theta/2));
cy =
ay+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
// draw the arc segment
this.curveTo(cx, cy, bx, by);
}
}
// In the native draw methods the user must specify the end point
// which means that they always know where they are ending at, but
// here the endpoint is unknown unless the user calculates it on
their
// own. Lets be nice and let save them the hassle by passing it
back.
return {x:bx, y:by};
};


//
// DRAW CIRCLE FROM OBJECT
//

function circle_draw ( obj:Object )
{
var mc = obj.mc;
mc.clear();
mc.moveTo ( obj.x, obj.y );
mc.beginFill.apply ( mc, obj.fillStyle );
mc.lineStyle.apply ( mc, obj.lineStyle );
mc.drawArc ( obj.x, obj.y, obj.radius, obj.arc, obj.startAngle,
obj.yRadius )
}


//
// CENTER AND REDRAW CIRCLES
//

function updateCircle ( top_obj, bottom_obj )
{
// redraw
if ( arguments.length > 0 )
{
// center
var X = (Stage.width >> 1);
var Y = (Stage.height >> 1) - top_obj.yRadius ||
top_obj.radius;

top_obj.x = X;
top_obj.y = Y;
circle_draw ( top_obj );

if ( arguments.length > 1 )
{
bottom_obj.x = X;
bottom_obj.y = Y;
circle_draw ( bottom_obj );
}
}
}

//
// CREATE
//

import caurina.transitions.Tweener
import flash.filters.GlowFilter;

function INIT ()
{
INIT_create ( );
INIT_stage ( );
INIT_glow ( );
INIT_tween ( );
onMouseDown = INIT; // resets on mouse press
}

function INIT_stage ()
{
Stage.scaleMode = 'noScale';
Stage.align = 'TL';
Stage.addListener( this );
bg = this.createEmptyMovieClip("bg", 1);
onResize = function()
{
var W = Stage.width;
var H = Stage.height;
bg.clear();
bg.beginFill(0x333333, 100);
bg.moveTo(0, 0);
bg.lineTo(W, 0);
bg.lineTo(W, H);
bg.lineTo(0, H);
bg.lineTo(0, 0);
bg.endFill();
updateCircle ( circle_obj, obj_base );
}
onResize();
}

function INIT_create ()
{
// top
circle_obj = {
mc: this.createEmptyMovieClip( "mc", 30 ),
x:0,
y:0,
radius:50,
arc: 0,
startAngle: 90,
yRadius:50,
lineStyle: [ 15, 0xFFFFFF, 100 ],
fillStyle: [ ]
};

// bottom
obj_base = {
mc: this.createEmptyMovieClip( "mc2", 20 ),
arc: 360,
x: circle_obj.x,
y: circle_obj.y,
radius: circle_obj.radius,
startAngle: circle_obj.startAngle,
yRadius: circle_obj.yRadius,
lineStyle: [ 13, 0xFFFFFF, 20 ],
fillStyle: circle_obj.fillStyle
};

// draw base
circle_draw ( obj_base );

}

function INIT_glow ()
{
// add top glow
var color:Number = 0xFFFFFF;
var alpha:Number = .8;
var blurX:Number = 15;
var blurY:Number = 15;
var strength:Number = 2;
var quality:Number = 3;
var inner:Boolean = false;
var knockout:Boolean = false;
var glow_filter:GlowFilter = new GlowFilter(color,
alpha,
blurX,
blurY,
strength,
quality,
inner,
knockout);
circle_obj.mc.filters = [ glow_filter ];
}

function INIT_tween ( )
{
// tween top - alpha
circle_obj.mc._alpha = 0;
Tweener.addTween ( circle_obj.mc, {
_alpha:100,
time:1,
delay:.5,
transition:'easeOutCubic'

})

// tween top - arc
Tweener.addTween ( circle_obj, {
arc:-360,
time:4,
delay:.2,
transition:'easeInOutCubic',
onUpdate: mx.utils.Delegate.create ( this, updateCircle ),
onUpdateParams:[ circle_obj ]
});
}

// starts draw and tween
INIT();

_____________________________

Jesse Graupmann
www.jessegraupmann.com
www.justgooddesign.com/blog/
_____________________________

-----Original Message-----
From: flashcode...@chattyfig.figleaf.com
[mailto:flashcode...@chattyfig.figleaf.com] On Behalf Of Omar Fouad
Sent: Monday, August 06, 2007 2:09 PM
To: flash...@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Coding a circular preloader

Hahaha Steven :D that was a good one ;). Thanks david.. but I don't have
it.. i'll try to convince my boss. But i would like to know the same how
that could be achieved like in the website.....

--
Omar M. Fouad

_______________________________________________

Muzak

unread,
Aug 6, 2007, 7:55:34 PM8/6/07
to flash...@chattyfig.figleaf.com

----- Original Message -----
From: "Steven Sacks" <flas...@stevensacks.net>
To: <flash...@chattyfig.figleaf.com>
Sent: Monday, August 06, 2007 8:38 PM
Subject: Re: [Flashcoders] Coding a circular preloader

> Easing? You're showing linear data. A visual representation of a number from 0-100. I'm not sure how easing fits into this.
>
> Your boss sounds like a real genius because it's absolutely brilliant to force somebody to spend many hours building something
> that could be built in 5 minutes - really smart use of time and money. He should write a book on how to be successful in
> business.

+10 ;-)

when I visited the site mentioned I didn't see any easing at all (I'm on a 20mbit conn).

Jesse Graupmann

unread,
Aug 6, 2007, 10:52:35 PM8/6/07
to flash...@chattyfig.figleaf.com
Another version using _xmouse to get a Stage.width factor so you can see
easing via onMouseMove.

Nothing extra needed in this example - just copy/paste.

- JG

function drawArc ( mc, x, y, radius, arc, startAngle, yRadius)
{
// http://www.formequalsfunction.com/downloads/drawmethods.html

if (arguments.length<5) return;


if (yRadius == undefined) yRadius = radius;

var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy;

if (Math.abs(arc)>360) arc = 360;

segs = Math.ceil(Math.abs(arc)/45);
segAngle = arc/segs;
theta = -(segAngle/180)*Math.PI;
angle = -(startAngle/180)*Math.PI;


ax = x-Math.cos(angle)*radius;
ay = y-Math.sin(angle)*yRadius;

if (segs>0) {


for (var i = 0; i<segs; i++) {

angle += theta;
angleMid = angle-(theta/2);


bx = ax+Math.cos(angle)*radius;
by = ay+Math.sin(angle)*yRadius;

cx =
ax+Math.cos(angleMid)*(radius/Math.cos(theta/2));
cy =
ay+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));

mc.curveTo(cx, cy, bx, by);


}
}
return {x:bx, y:by};
};

//
// DRAW CIRCLE FROM OBJECT
//

function circle_draw ( obj:Object ):Void


{
var mc = obj.mc;
mc.clear();
mc.moveTo ( obj.x, obj.y );
mc.beginFill.apply ( mc, obj.fillStyle );
mc.lineStyle.apply ( mc, obj.lineStyle );

drawArc ( mc, obj.x, obj.y, obj.radius, obj.arc, obj.startAngle,
obj.yRadius )
}

//
// SHOW PERCENTAGE IN TEXT
//

function setPer ( per ):Void
{
txt.text = per + ' %';
txt.setTextFormat(txt_fmt);
txt._x = Math.round(circle_holder._x - (txt._width>>1));
txt._y = Math.round(circle_holder._y + (circle_top.radius*2) +
circle_top.lineStyle[0]);
}

//
// ADJUST TO NEW PERCENTAGE
//

function adjust_view ()
{
// per
var margin = 20;
var per = Math.max( 0 , Math.min ( 1, (this._xmouse - margin) /
(Stage.width-(margin*2))));
var new_arc = Math.round( -360 * per );

// update
if ( new_arc != dest_arc )
{
dest_arc = new_arc;
circle_holder.onEnterFrame = function()
{
cur_arc += (dest_arc - cur_arc) * .1 ;
circle_top.arc = cur_arc;
circle_draw ( circle_top ); // circle
setPer (
Math.round(Math.abs(circle_top.arc)/360*100) ); // txt
if ( cur_arc == dest_arc ) delete
circle_holder.onEnterFrame;
}
}
}


//
// CREATE
//

function INIT()
{

// circle
circle_holder = this.createEmptyMovieClip( "circle_holder", 20 );
cur_arc = 0;
dest_arc = 0;

// top circle
circle_top = {
mc: circle_holder.createEmptyMovieClip( "mc", 40 ),


x:0,
y:0,
radius:50,
arc: 0,
startAngle: 90,
yRadius: 50,
lineStyle: [ 15, 0xFFFFFF, 100 ],
fillStyle: [ ]
};

// add top glow
circle_top.mc.filters = [ new flash.filters.GlowFilter(0xFFFFFF, .8,
15, 15, 2, 3, false, false ) ];
// bottom circle
circle_bottom = {
mc: circle_holder.createEmptyMovieClip( "mc2", 30 ),
arc: 360,
x: circle_top.x,
y: circle_top.y,
radius: circle_top.radius,
startAngle: circle_top.startAngle,
yRadius: circle_top.yRadius,


lineStyle: [ 13, 0xFFFFFF, 20 ],

fillStyle: circle_top.fillStyle
};

// txt
txt = this.createTextField("txt", 100, 100, 100, 300, 100);
txt.multiline = false;
txt.autoSize= true;
txt.wordWrap = false;
txt_fmt = new TextFormat();
txt_fmt.color = 0xFFFFFF;


// stage


Stage.scaleMode = 'noScale';
Stage.align = 'TL';
Stage.addListener( this );

bg = this.createEmptyMovieClip("bg", 10 );
onResize = function ()


{
var W = Stage.width;
var H = Stage.height;
bg.clear();
bg.beginFill(0x333333, 100);
bg.moveTo(0, 0);
bg.lineTo(W, 0);
bg.lineTo(W, H);
bg.lineTo(0, H);
bg.lineTo(0, 0);
bg.endFill();

circle_holder._x = (W>>1);
circle_holder._y = (H>>1)- circle_top.radius;
}
circle_draw ( circle_top );
circle_draw ( circle_bottom );

onMouseMove = adjust_view;
onResize();
setPer ( 0 );
}

INIT();

_____________________________

- JG

-----Original Message-----

Omar Fouad

unread,
Aug 7, 2007, 6:51:52 AM8/7/07
to flash...@chattyfig.figleaf.com
Thanks Jesse, this was a very good idea.....

--

Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.

Andreas R

unread,
Aug 7, 2007, 9:10:27 AM8/7/07
to flash...@chattyfig.figleaf.com
Been using CS3 for a bit now, getting to grips with AS3, and what feels
like excessive handholding at first is now flowing naturally, and i feel
far less prone to silent failures than before. To me this is entirely
excellent, good show!

The IDE however, i am less impressed with, and i am hoping to be wrong
or ignorant so some of you can correct me in my ridiculous ways.

Overall, i feel as though AS3 integration in the Flash 9 IDE appears
tacked on, or retrofitted. Experimenting with AS3 early on in flex and
with apollo gave a far, far stronger impression of the strengths of the
language than how it appears when used in tandem with the IDE,
particularly in how AS3 handles sound and the library.

AS3's substitution of attachMovie for the movieclip constructor is,
while logical on the surface, somewhat baffling to me in practise. In
AS2, extending MovieClip required you to declare variables to gain
references to clips already instanced in the library movieclip. For
instance, extending a movieclip containing a textfield with instance
name "nameField" would require var nameField:TextField to gain control
of that field in the class. What this gives you on script level is an
overview of relevant movieclip members, as well as code completion. In
AS3, declaring variables to refer to hand placed movieclip members
throws an error:

1151: A conflict exists with definition x in namespace internal.

This effectively forces us to write notes about movieclip members in
comments or the like, and denies us code completion. I'm not sure how
i'd deal with this more effectively, but i do sorely miss being able to
do this in the old fashioned way. If there is a faster, more convenient
workflow, please inform me :)

Secondly, where the Timer class allows us a "safe" way to
programmatically trigger callbacks without the setInterval danger of
orphaned intervals, the new Sound/SoundChannel symbiose allows us to
freely orphan sounds, while forcing us to keep track of separate class
instances to have specific control of individual sounds, easily lost
should the reference to the relevant SoundChannel be overwritten.

The current sound toolkit appears eclectic, almost chaotic, and in my
opinion performs even worse than its previous incarnation

Sound: Loads and plays streamed audio, provides close() method to stop
streaming sound, dispatches events to keep track of load progress, takes
a soundtransform instance
SoundChannel: gives playback and level information and an event when
sound playback ends. Contains another method to stop sound, which
DOESN'T work for streamed sound, yet a SoundChannel instance is
nonetheless required to alter properties of streaming sound during playback.
SoundTransform: Encapsulates all pan and volume properties previously
associated with the Sound class.
SoundMixer: static class containing global methods and properties for
all sounds.

Out of these 4, the Sound/SoundChannel relationship with their dual stop
methods makes me wonder what the rationale behind it all really was. The
SoundChannel class in my opinion has no logical place in the hierarchy
given that it doesn't actually give us any real control of the channel
in question. Were we able to declare a SoundChannel and pass it Sounds
to play it'd be a different matter. In addition, the name SoundMixer is
a complete misnomer, as the class offers absolutely no channel-specific
controls, nor does it keep track of currently playing channels.

I applaud being able to source audio externally, but i'm bewildered by
the choices of terminology and the weird sound/channel symbiose. The
docs insist the API is powerful, but i don't see how it is, aside from
external sourcing of audio.

So overall, i enjoy AS3, but its integration with IDE workflow seems
unfinished and awkward.

Anyone want to correct me? Please? :)

--
mvh

Andreas Rønning
Senior Flash developer
-----------------------------
Rayon Visual Concepts

Zeh Fernando

unread,
Aug 7, 2007, 9:38:16 AM8/7/07
to flash...@chattyfig.figleaf.com

> AS3's substitution of attachMovie for the movieclip constructor is,
> while logical on the surface, somewhat baffling to me in practise. In
> AS2, extending MovieClip required you to declare variables to gain
> references to clips already instanced in the library movieclip. For
> instance, extending a movieclip containing a textfield with instance
> name "nameField" would require var nameField:TextField to gain control
> of that field in the class. What this gives you on script level is an
> overview of relevant movieclip members, as well as code completion. In
> AS3, declaring variables to refer to hand placed movieclip members
> throws an error:
>
> 1151: A conflict exists with definition x in namespace internal.

When using classes, go to your publish settings, actionscript, and turn
off "automatically declare stage instances" and it should behave as it
did before -- you'll need to declare stage instances yourself. I agree
that's odd, I use it off, but I guess they decided to add it on by
default is so beginners wouldn't have trouble dealing with elements when
coding 'on the timeline'.


Zeh

Andreas R

unread,
Aug 7, 2007, 10:45:50 AM8/7/07
to flash...@chattyfig.figleaf.com
my god, thank you so much :)

--
mvh

Andreas Rønning
Senior Flash developer
-----------------------------
Rayon Visual Concepts

Karenslyst allè 16f
0214 Oslo, Norway
t: +47 22 13 52 50
f: +47 22 13 52 60
www.rayon.no

Folkert Hielema

unread,
Aug 12, 2007, 11:37:00 AM8/12/07
to flash...@chattyfig.figleaf.com
<snip>

SoundChannel: gives playback and level information and an event when
> sound playback ends. Contains another method to stop sound, which
> DOESN'T work for streamed sound,


You really can do ;) not like channel.stop() but like
if(channel){ channel.stop(); }

>
> --
> mvh
>
> Andreas Rønning
> Senior Flash developer
> -----------------------------
> Rayon Visual Concepts
>

> Folkert

Yotam Laufer

unread,
Aug 12, 2007, 12:01:39 PM8/12/07
to flash...@chattyfig.figleaf.com
I don't really know what is the exact issue, but I find exception
handling very useful in AS3.

This should work too:

try
{
channel.stop();
}
catch (err:Error)
{
}

Yotam.

<snip>

_______________________________________________

Reply all
Reply to author
Forward
0 new messages