How can I pass parameters to a loaded swf application? - swfloader

When I load an swf application using SWFLoader in Flex 4, how can I pass parameters to that application?

I've never tried this, but it looks like you can append them directly to the SWFLoader's source as a query string:
<mx:SWFLoader source = "map/us.swf?data_file=map/senate.xml" id="mapLoader" width="300" height="100" />
And retrieve them in the loaded SWF with:
var your_param:String = this.loaderInfo.parameters.data_file;
trace(your_param);
Source

Related

How to write Source for image from Resources/Images subfolder

I have two PNG-files:
Resoucres/Images/image1.png and Resoucres/Images/subfolder/image2.png
so, I want to set they as Source for Image:
when I set 1st image:
<Image ... Source="image1.png" />
all working correctly, but when I try to set 2nd image:
<Image ... Source="subfolder.image2.png" />
image isn't displaying.
So, how I need to write the path of the 2nd image?
An image can be added to your app project by dragging it into the Resources\Images folder of the project, where its build action will automatically be set to MauiImage.
Images can also be added to other folders of your app project. However, in this scenario their build action must be manually set to MauiImage in the Properties window.
So you can right click the image2.png file select the properties then change the Build Action to MauiImage and you can use the image directly.
<Image ... Source="image2.png" />

How can I render two variables in src attribute of razor view?

The framework I am using is .NET 6.
Previously, the src attribute of the image element like this:
<img src="#ImageServer/images/BG.png" />
The variable of ImageServer stores the URL of the image server.
Recently, I need to add a token in it for anti-theft chain.
I tried it like this:
<img src="#ImageServer/images/BG.png#GetToken()" />
However, after the program is run, the src turns out to be this:
<img src="https://www.aaa.com/images/BG.png#GetToken()" />
What's wrong with my code and how can I render two variables in src attribute? Thank you.
The text just before the # is causing the render engine to not parse the # as a server-side code indicator.
Make the whole value server-side calculated, instead of outputting small pieces of server-side values into client-side values. For example:
<img src="#(ImageServer + "/images/BG.png" + GetToken())" />
This way the view engine sees everything within the #() as a server-side expression and outputs the result of that expression.
Similarly, with string interpolation:
<img src="#($"{ImageServer}/images/BG.png{GetToken()}")" />

JSF2 custom component, parameter autocompletion with a local file path

My First Question, after years, thank you all and stackoverflow ;-)
I code a new Component for JSF2 and use it to include other templates.
It works perfectly for me.
<cc:interface>
<cc:attribute name="src" type="java.lang.String" required="true"/>
<cc:attribute name="addOption" type="java.util.List"/>
</cc:interface>
<cc:implementation>
<cc:insertChildren />
<ui:include src="#{BeanAnything.convert(cc.attrs.src, cc.attrs.addOption)}" />
</cc:implementation>
But i cant complete the Parameter src via auto completion in intellij or netbeans with "strg + space" or whatever other will use.
It should be used like the ui:include on src parameter.
Any Ideas ?
That's what I want to achieve only with my own componente gg:include
See Example

C# Windows Store App - Find resource on xaml

If i have 9 TextBlock declared on the XAML file like this:
<TextBlock Name="cellText_00" Tag="0"/>
<TextBlock Name="cellText_01" Tag="1"/>
<TextBlock Name="cellText_02" Tag="2"/>
<TextBlock Name="cellText_20" Tag="3"/>
...
<TextBlock Name="cellText_22" Tag="8"/>
There is a way to interact with it from the .cs getting exactly the desired tag element?
For instance is it possible to give all the same name and get it in this way:
TextBlock tb = get(cellText,0);
where the first field is the name and the second one is the tag?
No, you can't use the same name for many controls.
However there is a workaround: using the FindName method:
http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname(v=vs.95).aspx
There Why can't I access a TextBox by Name with FindName()?
you can find an example and a solution related to namespaces issues.
FindName uses a string to retrieve the control. So you can do something like this: FindName("cellText_" + identifier); and take the element you need.
#Sandrouos, I don't think he's using the same name.
This blogpost explains it perfectly:
http://blog.jerrynixon.com/2012/09/how-to-access-named-control-inside-xaml.html

What is the suitable replacement for this.__LZtextclip.text in Open laszlo 5.0

I want to know what is the suitable replacement for this line.
this.__LZtextclip.text
I am using this to get the string present in the text node. This works fine in Openlaszlo 3.3 but in 4.9 and 5.0 it's giving a problem
I tried updating it to
this.sprite.__LZtextclip.text
And i am getting an error:
79: Error: Access of possibly undefined property __LZtextclip through a reference with static type LzSprite, in line: Debug.write(this.sprite.__LZtextclip.text);
Any idea why this problem is happening?
If you are trying to access the text content of a text field, why don't you just access the attribute text?
<canvas>
<text name="sample" id="gRead" />
<handler name="oninit">
gRead.setAttribute('text',"HI");
Debug.info(gRead.text);
</handler>
</canvas>
In OpenLaszlo 3.3 there is method getText(), which gives you the same value. Accessing mx.textfield in your code does not work for the DHTML runtime.
Edit: Added information regarding the stripping of HTML tags
The Flash Textfield class flash.text.Textfield provides an API to enable HTML tag content in a Textfield instance. There are two different properties, one called text, the other one htmlText. If you want to directly access the Flash Textfield object of an lz.text instance, it's a property of the display object of the lz.text instance:
// Flash Textfield instance
gRead.getDisplayObject().textfield
// Pure text content
gRead.getDisplayObject().textfield.text
// Formatted text
gRead.getDisplayObject().textfield.htmlText
You should be aware of the fact that Flash automatically adds HTML format to any textstring you set as content. When you do
gRead.setAttribute('text',"HI");
the textfield.htmlText value is
<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="11" COLOR="#000000" LETTERSPACING="0" KERNING="1">HI</FONT></P>
For the DHTML runtime, the text content is added as the innerHTML of a <div> tag, and there is no standardized API to retrieve the pure text content of a DOM structure for a tag with content. You could write your own function to extract the text content, or use JavaScript functions from existing frameworks - like the jQuery text() function - to achieve the same result for the DHTML runtime.
I guess the reason is that Laszlo started using the Dojo based rich text editor for text input with HTML formatting since OpenLaszlo 4.0 or 4.1.
The best approach to have consistent behavior across runtimes when stripping tags is to do the conversion on the server-side. That's especially needed if you wan to have consistent whitespace treatment in multiline text, since there differences in how browsers treat whitespace. The question how to best strip tags from strings in JavaScript has been answered before on Stackoverflow, e.g. JavaScript: How to strip HTML tags from string?
Here is a cross-runtime example which works in DHTML with Firefox, Chrome, and it should work with IE9+:
<canvas>
<text name="sample" id="gRead" />
<handler name="oninit"><![CDATA[
gRead.setAttribute("text", 'Hello <b>World</b> OL');
Debug.info("gRead.text=" + gRead.text);
if ($dhtml) {
Debug.info(gRead.getDisplayObject().textContent);
} else {
Debug.info(gRead.getDisplayObject().textfield.text);
}
]]></handler>
</canvas>
I found what is the problem. The problem is that i have to declare a variable and have to refer the property from that.
<canvas>
<library>
<text name="sample" id="gRead">
<method name="getTextFrom">
Debug.write("this.text" , this.sprite);
var mx = this.sprite;
Debug.write("this.text" , mx.textfield.text);
</method>
</text>
</library>
<handler name="oninit">
gRead.setAttribute('text',"HI");
gRead.getTextFrom();
</handler>
</canvas>