Copy link to clipboard
Copied
How it is possible to save a sound-object in Sharedobject !?
var meinsound1:blablameinsound1 = new blablameinsound1();
var meinsound2:blameinsound2 = new blameinsound2();
var sharedO:SharedObject;
sharedO = SharedObject.getLocal("blabla");
var ktoenezufallarray:Array = new Array(meinsound1,meinsound2);
var ahaktoenezufallarray:Array = new Array();
button.addEventListener(MouseEvent.MOUSE_DOWN, buttonf);
function buttonf(event:MouseEvent):void
{
speicher();
}
if (sharedO.data.kmelodie)
{
ktext.text=sharedO.data.kmelodie[0].toString();
ahaktoenezufallarray=sharedO.data.kmelodie;
ahaktoenezufallarray[0].play(0,1);
sharedO.data.kmelodie[0].play(0,1);
}
function speicher()
{
var savingArr:Array = new Array ;
for (var i:int=0;i<ktoenezufallarray.length;i++)
{
savingArr.push(ktoenezufallarray);
}
sharedO.data.kmelodie= savingArr;
sharedO.flush();
sharedO.data.kmelodie[0].play(0,1);
}
you can save (in your sharedobject) the string name of your sound class and then restore the class name using getDefinitionByName:
...
var meinsound1:blablameinsound1 = new blablameinsound1();
var meinsound2:blameinsound2 = new blameinsound2();
var sharedO:SharedObject;
sharedO = SharedObject.getLocal("blabla");
var ktoenezufallarray:Array = new Array(meinsound1,meinsound2);
var ahaktoenezufallarray:Array = new Array();
button.addEventListener(MouseEvent.MOUSE_DOWN, buttonf);
function buttonf(eve
Copy link to clipboard
Copied
you can save (in your sharedobject) the string name of your sound class and then restore the class name using getDefinitionByName:
var meinsound1:blablameinsound1 = new blablameinsound1();
var meinsound2:blameinsound2 = new blameinsound2();
var sharedO:SharedObject;
sharedO = SharedObject.getLocal("blabla");
var ktoenezufallarray:Array = new Array(meinsound1,meinsound2);
var ahaktoenezufallarray:Array = new Array();
button.addEventListener(MouseEvent.MOUSE_DOWN, buttonf);
function buttonf(event:MouseEvent):void
{
speicher();
}
if (sharedO.data.kmelodie)
{
ktext.text=sharedO.data.kmelodie[0].toString();
ahaktoenezufallarray=sharedO.data.kmelodie;
ahaktoenezufallarray[0].play(0,1);
sharedO.data.kmelodie[0].play(0,1);
}
function speicher()
{
var savingArr:Array = new Array ;
for (var i:int=0;i<ktoenezufallarray.length;i++)
{
savingArr.push(getQualifiedClassName(ktoenezufallarray));
}
sharedO.data.kmelodie= savingArr;
sharedO.flush();
var C:Class=Class(getDefinitionByName(sharedO.data.kmelodie[0]));
var sound:*=new C();
sound.play(0,1);
}
Copy link to clipboard
Copied
the string name of my sound class i get with .toString() too,
but i have no opportunity to start the sound in this section:
if (sharedO.data.kmelodie)
{
...
}
Copy link to clipboard
Copied
use the code i suggested.
Copy link to clipboard
Copied
sorry, but I don't understand how i use your code in my section:
if (sharedO.data.kmelodie)
{
could u please write an example?
Copy link to clipboard
Copied
again, this is the code to play a sound:
var C:Class=Class(getDefinitionByName(sharedO.data.kmelodie[0]));
var sound:*=new C();
sound.play(0,1);
Copy link to clipboard
Copied
yes, it works - thank you!
i wanna to get the whole array... if it is possible...:
for (var i:int=0;i<2;i++) |
{
ahaktoenezufallarray.push(getDefinitionByName(sharedO.data.kmelodie)); | |
} |
Copy link to clipboard
Copied
use;
for (var i:int=0;i<2;i++) {
ahaktoenezufallarray.push(Class(getDefinitionByName(sharedO.data.kmelodie))); }
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
after restart ktext.text shows: [class blablameinsound1]
but why it doesn't worked with "ahaktoenezufallarray[0].play(0,1);" ????
{
ahaktoenezufallarray.push(Class(getDefinitionByName(sharedO.data.kmelodie)));
}
//ahaktoenezufallarray[0].play(0,1);
ktext.text=ahaktoenezufallarray[0];
Copy link to clipboard
Copied
Ok, sorry it works... sometimes I need a little bit longer... for (var i:int=0;i<sharedO.data.kmelodie.length;i++) | |
{ | |
var C:Class=Class(getDefinitionByName(sharedO.data.kmelodie)); | |
var sound:*=new C(); | |
ahaktoenezufallarray.push(sound); |
}
ahaktoenezufallarray[1].play(0,1);
ktext.text=ahaktoenezufallarray.toString();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now