PDA

View Full Version : AS3 Basic actions are a nightmare


sylvainhugues
05-06-2008, 10:59 PM
Hi !
I was a king of AS2, I'm learning AS3 and I have to tell myself : "Don't panic, don't go back to AS2"...
Even the basic action are nightmares to programm.
After reading and viewing a lot of stuff on AS3, I still mostly don't understand this Object principle.

Exemple 1 :
I want to move horizontaly an embed MC into an other MC. (I idon't want to use addChild, I manually put them on Stage)
It would be : container.Mc.x=10;
It doesn't work because Flash thinks Mc is a property.
How the hell could I do that ? Using Class ??!! How ?
(a unique MC works perfectly : container.x=10;)

Example 2 :
I want to change the depth of a MC (animated) manualy added on stage.
swapDepths() is no longer available, so I have to write about ten lines (thanx) with setChildIndex or this kind of method :
////////////////////
import flash.display.MovieClip;
var container:MovieClip = new MovieClip();
container.addChild(Mc);
addChild(container);

function fnChangerProfondeur(paramMc:MovieClip,):void {
var varProfondeur:int
varProfondeur = container.numChildren - 1
container.setChildIndex(paramMc, varProfondeur);
}
fnChangerProfondeur(Mc)
////////////////////////
Depth switching works fine but the manual tween animation of my elements doens't work anymore, even if I force with play()
It appears but does'nt move.

I'm a designer who like to code AS, but I think I'm gonna give up with AS3, I'm not a C++ nerd, I' m sad.
Thank for your responses.

embersyc
05-06-2008, 11:52 PM
I want to move horizontaly an embed MC into an other MC. (I idon't want to use addChild, I manually put them on Stage)
It would be : container.Mc.x=10;

This works perfectly fine for me. The only thing you should know is the Mc will move in relation to the registration point of the containing movie clip and not in relation to the stage.

amarghosh
05-07-2008, 05:27 AM
Exemple 1 :
I want to move horizontaly an embed MC into an other MC. (I idon't want to use addChild, I manually put them on Stage)
It would be : container.Mc.x=10;
It doesn't work because Flash thinks Mc is a property.

set the instance name of the clip to mc in the CS3;
now call mc.x = 10;
Example 2 :
I want to change the depth of a MC (animated) manualy added on stage.
swapDepths() is no longer available


swapChildren and swapChildrenAt are available to you (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html#swapChildren())

no need to panic.... with some effort, u can be a king in AS3 too... all the best

stanmc
05-07-2008, 07:58 PM
Couldn't agree more. I'm lost in AS3. Nothing intuitive about it. The programmers have won.

lordofduct
05-07-2008, 09:58 PM
Couldn't agree more. I'm lost in AS3. Nothing intuitive about it. The programmers have won.

I think OO standards are rather intuitive.

You want to access a properties value and change it, you declare it and set it equal to something else.

You want to listen for an event, you add an event listener.

You want to define a new kind of object, you define an object class. You want an object of that type, you instantiate an object from that object class.

It's pretty direct.

sylvainhugues
05-08-2008, 01:10 PM
Merci guys,

yes indeed, the .x move works, I mistaked.

About the depth stuff, it's still crap,
Just look at www.tapiocadesign.com/_TEST/Tdepth2.fla
I change the depth properly but it delete all other stuff like animation.
And I want to animate this elemet MANUALLY, not by code.
It seems adding the mc to container with addChild() erase the animation.

PS : OO programming is great for programms, not for animations.
All AS3 tutorials show .fla without anything on stage, all added by code.
But when you're building an complex animation manually added on stage, dealing with AS3 is a nightmare.

Anyway, merci à tous.

fitz
05-08-2008, 02:50 PM
I think OO standards are rather intuitive.

You want to access a properties value and change it, you declare it and set it equal to something else.

You want to listen for an event, you add an event listener.

You want to define a new kind of object, you define an object class. You want an object of that type, you instantiate an object from that object class.

It's pretty direct.

agreed, I never used Flash/AS till AS3 mostly because it seemed awfully primitive, but AS3 is perfectly natural to me as a programmer. Love it.