0

I have only recently started to learn ActionScript 3.0 I was practising in Flash and i ran into this problem:

Scene 1, Layer 'Layer 1', Frame 1, Line13 1119: Access of possibly undefined property dosomething through a reference with static type flash.net:SharedObject.

What i am tring to do is use the SharedObject.send method to send a message obviously. I have edited some server side code in my main.asc file. And i am trying to pass in the doSomething function but i get that compile error. Any advice would be appreciated for a novice like myself.

The code is below:

import flash.net.NetConnection;
import flash.net.SharedObject;

var nc:NetConnection = new NetConnection();

nc.connect("rtmp:/exampletest/");

var so:SharedObject = SharedObject.getRemote("foo", nc.uri, true);

so.connect(nc);

so.dosomething = new function(str) {
BadFeelingAboutThis
  • 14,445
  • 2
  • 33
  • 40
  • All functions need to be visible to the compiler at compile time. This approach cannot work. What is it you're trying to do? There is likely another solution. – Atriace Jan 29 '13 at 15:51
  • SharedObject is used to read and store a data. What you mean with "pass in the doSomething function " – Azzy Elvul Jan 29 '13 at 15:51

1 Answers1

0

If you want to pass a function between SWFs, attach the function to the .data member of the SharedObject returned by SharedObject.getLocal/Remote, not the SharedObject itself.

So:

so.data.doSomething = yourFunction

...should work. I'm not exactly sure what you're trying to achieve, does this sound like a solution?

MickMalone1983
  • 1,054
  • 8
  • 17
  • Thanks guys for your advice it worked! I am attemptng to build a small chat application. I basically wanted to see if using the SharedObject.send was a suitable method to use for exchanging messages between clients. – ricky hayden Jan 30 '13 at 00:08
  • No problem, just mark the question as answered, come back if you need any more help! – MickMalone1983 Jan 30 '13 at 10:27