Announcement

Collapse
No announcement yet.

Can't get ActionScriptVoid to work

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can't get ActionScriptVoid to work

    Hello!

    I'm trying to get ActionScriptVoid to work so I can call an actionscript function from unrealscript, but it's not working.
    Currently it looks like this:

    From my HUD-class
    Code:
    `log("Before HudMovie.CallAddItem");
    HudMovie.CallAddItem();
    `log("Woho");
    In my HudMovie-class
    Code:
    function CallAddItem()
    {
    
    	ActionScriptVoid("AddNewItem2");
    
    }
    
    function InventoryItemNotAdded()
    {
    
    	`log("InventoryItem not added");
    
    }
    In my actionscript
    Code:
    public function AddNewItem2():void
    {
    			
    	ExternalInterface.call("InventoryItemNotAdded");
    			
    }
    It prints out
    Before HudMovie.CallAddItem
    Woho
    but not the
    InventoryItem not added
    so I'm not sure what's going on and why it's not working.
    I've set the actionscript-class as my "document class" in the flash-file so it should work.

    #2
    Try
    ActionScriptVoid("_root.AddNewItem2");
    Think of _root as the main timeline.
    If you're using ActionScript 3, try 'root' rather than '_root'.

    If the function you're calling is inside a MovieClip, then you'll need to do
    ActionScriptVoid("_root.myMovieClip.AddNewItem2");
    where 'myMovieClip' is the 'instance name' you've given it.

    and if it's in a MovieClip within a MovieClip try
    ActionScriptVoid("_root.myMovieClip.myOtherMovieClip.AddNewItem2");
    et cetera...

    Comment


      #3
      Originally posted by Captain Zazz View Post
      Try
      ActionScriptVoid("_root.AddNewItem2");
      Think of _root as the main timeline.
      If you're using ActionScript 3, try 'root' rather than '_root'.

      If the function you're calling is inside a MovieClip, then you'll need to do
      ActionScriptVoid("_root.myMovieClip.AddNewItem2");
      where 'myMovieClip' is the 'instance name' you've given it.

      and if it's in a MovieClip within a MovieClip try
      ActionScriptVoid("_root.myMovieClip.myOtherMovieClip.AddNewItem2");
      et cetera...
      This did not work. Tried both "_root" and "root".
      I should perhaps mention that the Actionscript is located within a separate .as file which is set as the "Document Class" in the .fla file.

      Comment


        #4
        Solved it!

        I knew it had to be some other problems with this other than how I accessed it since I received a "None" when fetching "root".
        I forgot to put in
        Code:
        HudMovie.Advance(0.f);
        Cheers for the help guys

        Comment


          #5
          i should thank you guys too

          Comment

          Working...
          X