I'm working on an application that must work on desktop, android and web browser.
On Desktop and Android I have no problem, everything work fine.
But on the HTML version, the newinstance of a class won't work. I don't understand why.
Here is my code:
public static Node newInstanceGdx(Class<? extends Node> nodeModel) throws ReflectionException {
if (nodeModel != null)
try {
return ClassReflection.newInstance(nodeModel);
} catch (Exception e) {
e.printStackTrace();
Gdx.app.setLogLevel(Application.LOG_DEBUG);
Gdx.app.log("Reflection", "Can't initialize Node class : " + (Node.class).getName());
}
return null
}
And here is myGame.gwt.xml code :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
<module>
<source path="fr/EU/Game" />
<extend-configuration-property name="gdx.reflect.include" value="com.me.reflected.ReflectedClass" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.reflect.ClassReflection"/>
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.reflect.ReflectionException"/>
</module>
It always return "null" for the html version, but on the other version, everything work.
Thanks in advance for your help.
I found out my problem, I hope it will help other !
GWT needs to know the type of the Object it use.
So when you do ClassReflection.newInstance(o) the "o" type must be known by GWT.
To do so, you must import in *.gwx.xml, your class with :
<extend-configuration-property name="gdx.reflect.include" value="path.ClassOfObject"/>
gdx.reflect.include does only help for libGDX' built-in methods like for deserializing objects from jsons. If you want to use this, you have to look into the libGDX sources what kind of statements they are using.
I would recommend you to go away from reflection when not absolutely neccessary. It is a nice solution which looks better than using a factory method implementing new statements, but in my experience you will have problems with ProGuard and GWT sooner or later that can be avoided.
Related
I'm wading through a Flex AIR desktop project that someone else wrote. The original author has used several mx.controls.Image components. Runtime image paths assigned like this:
image.source = "/assets/book.png";
It doesn't work - I just get the broken image icon.
I've never used the above approach in my own code. Personally, I've always used compile-time embedded images or URLLoader/Loader for runtime images.
So, I'd like to learn how to get this image path approach working.
I wrote a simple test program. Here is my .mxml -
<?xml version="1.0" encoding="utf-8"?>
<pf:LearningAS xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:pf="com.powerflasher.*">
<mx:Image id="myImage"/>
</pf:LearningAS>
Here is my connected .as
public class LearningAS extends WindowedApplication {
public var myImage:Image;
public function LearningAS() {
super();
addEventListener(FlexEvent.CREATION_COMPLETE, init);
}
protected function init(event:FlexEvent):void {
myImage.source = '/assets/myimage.png';
}
}
I also added the src/assets folder to AIR package contents. And I added -use-network=false to my compiler directives. (I'm using FDT, and Flex 4.6).
Ok - Cracked it, with some help from the Flex mailing list.
I had to copy my assets folder into my bin folder. So that the paths were relative to the .swf. (Actually, I've done this for previous AS3 projects - but I assumed that packaging assets folder for AIR would cover this.)
Anyway - problem solved.
As per your code you are giving incorrect image path reference instead of myImage.source = '/assets/myimage.png'; try myImage.source = 'assets/myimage.png';
Hope it work for you.
I am using SquishIt MVC framework for bundling and minification of the js and css components present in the application. The code is as mentioned below:
public static class HTMLHelperExtensions
{
public static MvcHtmlString PackageLibs(this HtmlHelper htmlHelper)
{
var client = Bundle.JavaScript()
.Add("~/scripts/jquery-1.7.1.min.js")
.Add("~/scripts/jquery-ui-1.8.17.min.js")
.Render("~/scripts/combined.js");
return new MvcHtmlString(client);
}
}
I am invoking the method : HTMLHelperExtensions from the layout page.
<%= HTMLHelperExtensions() %>
I want to use the defer attribute to boost the JavaScript performance of a web page.
Can anyone help me to know the usage of the defer attribute? I would like to know also is the usage of webworker useful here.
Thanks & Regards,
Santosh Kumar Patro
To render with deferred load, change your bundle setup like so:
var client = Bundle.JavaScript()
.Add("~/scripts/jquery-1.7.1.min.js")
.Add("~/scripts/jquery-ui-1.8.17.min.js")
.WithDeferredLoad()
.Render("~/scripts/combined.js");
Web workers seem like overkill for something as trivial as script loading IMO.
I have tried with AudioRoutingManager class...but i got unauthorizedaccess exception.
here is my code
AudioRoutingManager audioRouting = AudioRoutingManager.GetDefault();
public AudioRoutingEndpoint ChangeAudioRoute()
{
var currentEndPoint= audioRouting.GetAudioEndpoint();
switch (currentEndPoint)
{
case AudioRoutingEndpoint.Earpiece:
case AudioRoutingEndpoint.Default:
return AudioRoutingEndpoint.Speakerphone;
case AudioRoutingEndpoint.Speakerphone:
return AudioRoutingEndpoint.Earpiece;
default:
throw new OperationCanceledException();
}
}
public void SetAudioRoute()
{
audioRouting.SetAudioEndpoint(this.ChangeAudioRoute());
}
The APIs in the Windows.Phone.Media.Devices namespace require the ID_CAP_AUDIOROUTING and the ID_CAP_VOIP capability. (Add this to your manifest)
Also, it's only possible to change the audio routing while in a active VOIP call.
Additionally, you need to do the audio routing in your background VOIP process, and not in the foreground process.
Old question but now I know the answer.
Two things which you need to do:
Tag the audio in question as "communications"
How to do this depends on what API you're using. It could be as simple as . Or you might have to call IAudioClient2::SetClientProperties with an AudioClientProperties structure whose AudioClientProperties.eCategory = AudioCategory_Communications.
Tag your app as either a "voice over IP" app or a "voicemail" app
You should add file called WindowsPhoneReservedAppInfo.xml to your project with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<WindowsPhoneReservedAppInfo xmlns="http://schemas.microsoft.com/phone/2013/windowsphonereservedappinfo">
<SoftwareCapabilities>
<SoftwareCapability Id="ID_CAP_VOIP" />
</SoftwareCapabilities>
</WindowsPhoneReservedAppInfo>
Look for more detailed explanation here:
Playing audio to the earpiece from a Windows Phone 8.1 universal app
I'm using the version of MonoDevelop bundled with Unity game engine. I never used #if/#endif in C# before, so I never noticed that. I checked this on a new empty file. How can I fix that?
I've played around with this a bit and what I've noticed is that conditional code for a
"#if DEBUG" block is commented out. It's probably helpful when you've gotten to the point of building your release code. The "debug" test stuff remains in your code, but looks like a comment. Here is what I was playing with to test that out, ymmv:
using System;
namespace testConditionalCompile
{
class MainClass
{
public static void Main (string[] args)
{
#if RELEASE
Console.WriteLine("Release code");
#endif
#if DEBUG
Console.WriteLine("Debug code");
#endif
}
}
}
I realize that the conditional code block is not the best way to write it, but I thought it might best illustrate my point above.
For those coming to this question dealing with either or both the #if UNITY_IOS ... #elif UNITY_ANDROID preprocessor directives showing as commented out and/or having strange code formating issues, Monodevelop only formats code based on whichever platform you have currently chosen in build settings. So what you see below is intentional, because this code is treated by Monodevelop essentially the same as commented code. The logic is that since it will it not be execute, or even included in the build, that it shouldn't be checked in the editor. Thus the formatting / commented-out treatment. I personally find this annoying, because I should be able to write / view formatted code regardless of the current platform I have chosen in build settings.
I have ActiveX control done in VC++/MFC. It embeds into html web page. Now I need to be able to configure it by providing parameters in html tag. like:
The question is how do I read those parameters during my ActiveX initialization? My research revealed that it has to be done through IPersistPropertyBag interface, but I could really use some code examples to figure that out.
Any examples in VC++ please?
Thanks,
Mike
I will answer my own question...
Basically from ActiveX point of view those HTML parameters are "persistent storage" parameters.
So in your HTML file:
<OBJECT ID="activex1" WIDTH=300 HEIGHT=200
...
<PARAM NAME="ServerAddress" VALUE="192.168.1.1:1234">
...
</OBJECT>
And in your MFC ActiveX control:
void Cubcam_activexCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
PX_String(pPX, _T("ServerAddress"), m_serverAddress, _T(""));
}
Interesting; I will have to try the method you describe. The way that I know of to do this is to implement the IPersistPropertyBag interface and implement the Load method.
I haven't used MFC, just ATL, but I implemented this by hand. I will have to look into the solution you provided to see if there are advantages to the underlying approach used by MFC.