1

So this is an interesting one, I've poured through the other answers around here and none of them worked. I'm not sure why, or what to do next now.

Okay so my main class is Graph.as (where I take xml elements and use them to build a graph), and RVHost needs to be pulled in (it is a class I am being forced to use in order to substantiate media player information built with proprietary software...yadda yadda).

Anyway I'm just trying to test this at the moment, and it's a big bust.

Graph.as (only the vital info here):

package 
{
////imported nearly every flash item here
import test.*  ////this is the folder where my subclass resides////

public class Graph extends Sprite
    {
private var player:RVHost = new RVHost(); ////RVHost.as is my subclass file

public function Graph():void
            {
  trace("IS IT WORKING?: "+player.testTrace());
       }

    }
}

result: IS IT WORKING?: undefined

RVHost.as (only vital info here as well):

package test
{
    import flash.external.ExternalInterface;

public class RVHost
    {

/////filled with their variables 

public function testTrace() :void
        {
            trace("THIS IS WORKING OMG!");
        }
    }
}

What am I missing here? I have tried this six ways till sunday, they swear by this "api" (eyeroll), and I'm forced to use it as is. I just need a way to use it's functions in my class (graph.as) and have the info it collects passed on into my class. I'm assuming this is something I've overlooked or something so simple that I'll have to laugh but I currently cant figure it out. Any help would be greatly appreciated!

puppies_pidgeons
  • 61
  • 1
  • 2
  • 9
  • I don't think you understand what a subClass is. The subclass of Graph.as is `Sprite` – BadFeelingAboutThis Jul 02 '14 at 16:34
  • I don't see anything wrong with what's posted (consider posting more code). One tip though, instantiate `player` in the constructor, not in the variable definition. – BadFeelingAboutThis Jul 02 '14 at 16:36
  • I do see something wrong with `Graph.as`. Your constructor `public function Graph()` **must not** have a return datatype. Additionally, this is not a function that can be called after calling `new Graph()`. Even further, you should avoid instantiating any non-primitive object in global space, so you should call `new RVHost()` within your constructor. – Josh Jul 02 '14 at 16:40
  • @JoshJanusch - there's nothing wrong with a void return type on a constructor in AS3 - as that's what it implicitly made to anyway when omitted. – BadFeelingAboutThis Jul 02 '14 at 17:43
  • @LDMediaServices I swore having any return type could throw errors. Perhaps it is just a warning some IDEs throw that I am remembering. – Josh Jul 02 '14 at 18:11
  • Sprite is the superclass of Graph of course while Graph is the subclass of Sprite. Graph apparently has no subclass so far. RVHost class doesn't extend anything and so is by default a subclass of Object. – BotMaster Jul 02 '14 at 18:48
  • @JoshJanusch I've had no errors thrown with Graph.as (I was testing it before I tried adding in RVHost). – puppies_pidgeons Jul 02 '14 at 19:01
  • @LEMediaServices you're right, I minced my words on that. – puppies_pidgeons Jul 02 '14 at 19:06

1 Answers1

1

IS IT WORKING?: undefined is expected behavior: testTrace does not return a value, so it is appropriate for it to be converted to undefined. On the other hand, if you are not seeing THIS IS WORKING OMG!, then you may want to consider clearing your class cache. Check out this answer for more information on that process.

Community
  • 1
  • 1
cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • i'm not seeing the THIS IS WORKING... so i'll try clearing the class cache – puppies_pidgeons Jul 02 '14 at 17:23
  • @cwallenpoole - good catch! though he should still have been seeing the trace on the preceeding line – BadFeelingAboutThis Jul 02 '14 at 17:45
  • @cwallenpoole, okay so I looked at that and realized i'm in flash cc, so that aso folder isn't in there. I assume that keep that 'in the cloud' away from the fidgety fingers of their users. Do you think this still applies in CC? – puppies_pidgeons Jul 02 '14 at 18:14
  • player.testTrace() runs first and so not seeing that trace first is not logical class cache problem or not. The user might be confused and not reporting the output correctly. – BotMaster Jul 02 '14 at 18:56