Copy link to clipboard
Copied
Hello I am new to the program and I really do not know much code, I hope you can help me.
I want to make an interactive animation at the beginning there is a selection of characters and backgrounds I want the user to select a character and a background and go to the next scene where only the character that he selected and the animated background are, I understand that this is with code how can I do it?
Copy link to clipboard
Copied
html5/canvas or as3?
Copy link to clipboard
Copied
with as3
Copy link to clipboard
Copied
use:
var selectedCharacter;
var selectedBackground;
var charactersA:Array = [your character instances here];
var backgroundsA:Array = [your background instances here];
// your next movieclip or button listener
yournextobject.addEventListener(MouseEvent.CLICK,nextF);
for(var i:int=0;i<charactersA.length;i++){
charactersA[i].addEventListener(MouseEvent.CLICK,characterF);
}
for(i=0;i<backgroundsA.length;i++){
backgourndsA[i].addEventListener(MouseEvent.CLICK,backgroundF);
}
function characterF(e:MouseEvent):void{
selectedCharacter = e.currentTarget;
}
function backgroundF(e:MouseEvent):void{
selectedBackground = e.currentTarget;
}
function nextF(e:MouseEvent):void{
if(selectedCharacter && selectedBackground){
for(var i:int=0;i<charactersA.length;i++){
charactersA[i].parent.removeChild(charactersA[i]);
}
for(i=0;i<backgroundsA.length;i++){
backgroundsA[i].parent.removeChild(backgroundsA[i]);
}
addChild(selectedBackground);
addChild(selectedCharacter);
// position each per your needs
} else {
// perhaps an info message to select one of each
}
}