0
votes

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) {
1
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
SharedObject is used to read and store a data. What you mean with "pass in the doSomething function " - Azzy Elvul

1 Answers

0
votes

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?