Copy link to clipboard
Copied
1. What role can be attributed to add / remove an object? I believe it is necessary to convert it to MoveClip ... But I have not found an exact function.
I saw some posts where users use "removeChildren" But I do not know if that's what my question is.
Could anyone help me with these little problems? Grateful.
2. How can I be assigning a random selection function? I will give an example, but I do not think that works in actionscript this way.
var luck = random(2);
if(luck == 1) {
action;
}
if(luck == 2) {
action2;
}
...
If the function would be called with the event of a "draw" between the numbers 1 and 2, which are predefined in the random variable.
Could anyone help me? Grateful
Copy link to clipboard
Copied
1. what's your question?
2. again, i'm not sure what you're asking. but if you want to call different functions, you can use:
var luck:int=Math.ceil(2*Math.random());
this['F'+luck]();
function F1():void{
// do whatever
}
function F2():void{
//do whatever else
}
Copy link to clipboard
Copied
The question of the issue one is exactly "What function should I use to add or remove a MoveClip?"
Let's say our moveclip has the name "test" the goal is to make the object appear in one of two random functions ... So I wonder what code can be using for this function.
Copy link to clipboard
Copied
a movieclip doesn't appear in a function. you could create a function to make a movieclip appear.
and you could make the movieclip appear at a random position on stage. eg, for mobieclips with upper left reg point:
function addAtRandomF(mc:MovieClip):void{
addChild(mc);
mc.x=Math.random()*(Stage.stageWidth-mc.width);
mc.y=Math.random()*(Stage.stageHeight-mc.height);
}
Copy link to clipboard
Copied
kglad escreveu:
a movieclip doesn't appear in a function. you could create a function to make a movieclip appear.
and you could make the movieclip appear at a random position on stage. eg, for mobieclips with upper left reg point:
function addAtRandomF(mc:MovieClip):void{
addChild(mc);
mc.x=Math.random()*(Stage.stageWidth-mc.width);
mc.y=Math.random()*(Stage.stageHeight-mc.height);
}
Hello kglad, the request itself was a function that determines the appearance of a moveclip ... I think I may have understood the wrong way, I will try to give an example. Let's say I put the object converted into moveclip in one spot of the stage, and a role in actions that determines its Alpha (increasing its Alpha her to stay visible). The request is that the object appears on the site I want only.
To do something like this ...
var luck:Number = 2;
if (luck == 1) {
// appear object
}
if(luck == 2) {
// No acnion.
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
So if I can add the name in the MovieClip () to add the object?
addChild (moveclipname);
Copy link to clipboard
Copied
no, not the name. it has to be a reference to the movieclip.
so you could use:
addChild(getChildByName(movieclipname));
Find more inspiration, events, and resources on the new Adobe Community
Explore Now