Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
- = v i p e r = - webforumsuser@macromedia.com #1
Is there a way to + number in a shared object?
If you have a textfield like a scoreboard with the number 10 you can use:
btn1.onPress = function() {
_root.scoreboard += 5;
};
to add 10 points to the scoreboard.
Is there a way to do the same if you have a shared object?
Thanks.
/Andy
- = v i p e r = - webforumsuser@macromedia.com Guest
-
Flash Shared Object
Hi There, Is it possible that edit or delete specific data from .fso file. I know we can delete all of data from clear(); but can we view .fso... -
Shared Object
Hi there all, Just a quick question on the uses of the Shared Object to store data locally, if I was to save a series of the same field locally... -
Shared object limits???
Hi, I?m using the whiteboard component in a virtual classroom application. The drawings on the whiteboard are stored in one shared object. After... -
Shared Object Definition
I have a class (UserType) that is used in multiple web services. How do I get my client and/or web services to recognize it as the same class?... -
Shared object name??
Is there a way to make flash name the shared object .sol file? I whant it to create a new file instead of overwright the existing one. Like: my_so =... -
MOLOKO #2
Re: Is there a way to + number in a shared object?
"- = v i p e r = -" [email]webforumsuser@macromedia.com[/email] wrote:
yes, same sort of thing> If you have a textfield like a scoreboard with the number 10 you can use:
>
> btn1.onPress = function() {
> _root.scoreboard += 5;
> };
>
> to add 10 points to the scoreboard.
>
> Is there a way to do the same if you have a shared object?
>
> Thanks.
>
> /Andy
>
_global.sharedObjRef = SharedObject.getLocal("scoreboarddata");
btn1.onPress = function()
{
_global.sharedObjRef.data.score += 5;
_global.sharedObjRef.flush();
}
--
MOLOKO
------------------------------------------------
::remove _underwear_ to reply::
'God saves but Buddha makes incremental backups'
------------------------------------------------
GCM/CS/IT/MC d-- S++:- a- C++ U--- P+ L++ !E W+++$ N++ O? K+ w+++$ !O M+
VMS? PS+++ PE- Y PGP+ t+ 5-- X-- R* tv++ b++++ DI++++ D+ G e h-- r+ y++
see [url]www.geekcode.com[/url] to translate the above!
MOLOKO Guest
-
PierreAlain #3
Re: Is there a way to + number in a shared object?
sure.
Z = SharedObject.getLocal("myFile");
Z.data.scoreboard = 0;
.....
Z.data.scoreboard++;
--
Pierre Alain
[email]pie@lifnet.com[/email]
"- = v i p e r = -" <webforumsuser@macromedia.com> a écrit dans le message
de news:bu2von$jp6$1@forums.macromedia.com...> If you have a textfield like a scoreboard with the number 10 you can use:
>
> btn1.onPress = function() {
> _root.scoreboard += 5;
> };
>
> to add 10 points to the scoreboard.
>
> Is there a way to do the same if you have a shared object?
>
> Thanks.
>
> /Andy
>
>
PierreAlain Guest
-
sneakyimp webforumsuser@macromedia.com #4
Re: Is there a way to + number in a shared object?
by shared object, do you mean one imported from a shared library, or a 'shared object' meaning a flash object that is communicated with through some kind of inter-movie communication? if the object is imported from a shared library by using attachMovie or something like that, you just have to know which ID you used as an arg...that would allow you to create the correct path to the object where you can increment its internal values (i *think* this is how it works).
sneakyimp webforumsuser@macromedia.com Guest
-
- = v i p e r = - webforumsuser@macromedia.com #5
Re: Is there a way to + number in a shared object?
yes, same sort of thing
_global.sharedObjRef = SharedObject.getLocal("scoreboarddata");
btn1.onPress = function()
{
_global.sharedObjRef.data.score += 5;
_global.sharedObjRef.flush();
}
Thanks for the reply!
I have a flashcom server. I store all shared objects there. If I have a shared object with the number
10 and try to use this code, all it does is wright 105 to the shared object. Why? I whant the shared object to say 15 not 105.
Please help im going nuts!!
/Andy
- = v i p e r = - webforumsuser@macromedia.com Guest
-
MOLOKO #6
Re: Is there a way to + number in a shared object?
"- = v i p e r = -" [email]webforumsuser@macromedia.com[/email] wrote:
a-ha - probably because one of them is a string, not a number, so it's> yes, same sort of thing
>
> _global.sharedObjRef = SharedObject.getLocal("scoreboarddata");
> btn1.onPress = function()
> {
> _global.sharedObjRef.data.score += 5;
> _global.sharedObjRef.flush();
> }
>
>
> Thanks for the reply!
>
> I have a flashcom server. I store all shared objects there. If I have a shared object with the number
> 10 and try to use this code, all it does is wright 105 to the shared object. Why? I whant the shared object to say 15 not 105.
>
> Please help im going nuts!!
>
> /Andy
>
concatenating them instead of adding (in AS the '+' operator means both
'concatenate' and 'add'. Therefore this code:
var numa = "10";
var numb = "5";
trace(numa + numb); //would return '105'
Although flash should try an convert strings to numbers when required,
it doesn't. To ensure your variable actually contains a number, multiply
it by one:
var numa = "10" * 1;
var numb = "5" * 1;
trace(numa + numb); //now returns '15'
--
MOLOKO
------------------------------------------------
::remove _underwear_ to reply::
'God saves but Buddha makes incremental backups'
------------------------------------------------
GCM/CS/IT/MC d-- S++:- a- C++ U--- P+ L++ !E W+++$ N++ O? K+ w+++$ !O M+
VMS? PS+++ PE- Y PGP+ t+ 5-- X-- R* tv++ b++++ DI++++ D+ G e h-- r+ y++
see [url]www.geekcode.com[/url] to translate the above!
MOLOKO Guest
-
MOLOKO #7
Re: Is there a way to + number in a shared object?
oops... replied to wrong post. try again!
"- = v i p e r = -" [email]webforumsuser@macromedia.com[/email] wrote:>a-ha - probably because one of them is a string, not a number, so it's> Thanks for the reply!
>
> I have a flashcom server. I store all shared objects there. If I have a shared object with the number
> 10 and try to use this code, all it does is wright 105 to the shared object. Why? I whant the shared object to say 15 not 105.
concatenating them instead of adding (in AS the '+' operator means both
'concatenate' and 'add'. Therefore this code:
var numa = "10";
var numb = "5";
trace(numa + numb); //would return '105'
Although flash should try an convert strings to numbers when required,
it doesn't. To ensure your variable actually contains a number, multiply
it by one:
var numa = "10" * 1;
var numb = "5" * 1;
trace(numa + numb); //now returns '15'
--
MOLOKO
------------------------------------------------
::remove _underwear_ to reply::
'God saves but Buddha makes incremental backups'
------------------------------------------------
GCM/CS/IT/MC d-- S++:- a- C++ U--- P+ L++ !E W+++$ N++ O? K+ w+++$ !O M+
VMS? PS+++ PE- Y PGP+ t+ 5-- X-- R* tv++ b++++ DI++++ D+ G e h-- r+ y++
see [url]www.geekcode.com[/url] to translate the above!
MOLOKO Guest
-
- = v i p e r = - webforumsuser@macromedia.com #8
Re: Is there a way to + number in a shared object?
You are the man!
That thing with *1 to make it a number and not a string! Great stuff!!
Thanks!!!
/Andy
- = v i p e r = - webforumsuser@macromedia.com Guest



Reply With Quote

