Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by SpennyDubz · Jul 30, 2012 at 04:47 PM · flashactionscript

Actionscript example does not work.

I'm trying to get the [ActionScript example from the script reference][1] to work. However, when I run it I get an error:

InvalidOperationException: Operation is not valid due to the current state of the object

UnityEngine.Flash.ActionScript.Expression[Int32] (System.String formatString, System.Object[] arguments) GameController.Start () (at Assets/Scripts/GameController.cs:14) My calling script looks like this: using UnityEngine; using UnityEngine.Flash; using System.Collections;
public class GameController : MonoBehaviour {
// Use this for initialization void Start () {
#if UNITY_FLASH print ("Yup, Unity Flash"); ActionScript.Import("com.mycompany.mytool"); string name = "Lerpz"; int protocolversion = ActionScript.Expression("com.mycompany.mytool.GetProtocolVersionFromServer({0})", name); print (protocolversion); #endif } // Update is called once per frame void Update () { } } That script is attached to the main camera. My ActionScript looks like this: package com.mycompany { public final class mytool { public static function GetProtocolVersionFromServer(name: String): int { //talk the the flash api here. return 18; } } } It is named mytool.as and is placed in a folder call ActionScript at the root of the project hierarchy. I feel I've followed the example to the tee, but it's not working. What can I do to make it work? [1]: http://docs.unity3d.com/Documentation/ScriptReference/ActionScript.html
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by catburton · Aug 08, 2012 at 03:49 PM

Hi,

You'll get that error if you try to run the example in editor when your current target platform is set to Flash export. This is because the UNITY_FLASH check will be true in this case. If you do not want the code to run in editor you can do one of the following:

  • Add an extra check to ensure this code isn't run in editor: #if UNITY_FLASH && !UNITY_EDITOR

  • Or, only run the code if the application is running in the flash player: if (Application.platform == RuntimePlatform.FlashPlayer)

As a side note, if you do want your code to work in editor (or for other platforms), you'll need to create a C# or JS version of your ActionScript class. This will then be used in place of your ActionScript for all export options other than Flash. There are some examples of how you can do this on the Unity manual: http://docs.unity3d.com/Documentation/Manual/flashexamples-callingflashfunctions.html http://docs.unity3d.com/Documentation/Manual/flashexamples-supplyingdata.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 3.5 with AS3 1 Answer

Call javascript function from actionscript(flash) 0 Answers

How to call AS from Unity 0 Answers

Help with networking in flash 3 Answers

How to create a file (png) using Unity Flash? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges