Setting path of swfobject - swfobject

I am facing trouble to set the path of swfobject. In my project directory structure I put the swfobject.js and loadmovie.js files in the "Project/src/main/webapp/resources" directory. In same directory I placed the test.swf file. The content of loadmovie.js is:
var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
var params = {};
params.wmode = "transparent";
params.quality = "high";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "test";
attributes.name = "test";
attributes.align = "left";
swfobject.embedSWF("test.swf", "movieDiv", "202", "380", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
But the test.swf is not loading the web page. If I view the source of the webpage after rendering the swfobject is transforming as :
<object type="application/x-shockwave-flash" id="test" name="test" align="left" data="test.swf" width="202" height="380">
<param name="wmode" value="transparent">
<param name="quality" value="high">
<param name="allowscriptaccess" value="sameDomain">
<param name="allowfullscreen" value="true">
</object>
And if I replace the data="test.swf" by data="http://localhost/project/resources/test.swf" then swf is visible. Please help. How can I set the path? Thank you

Use absolute paths:
data="/project/resources/test.swf"

Related

How to pass a variable to css in AngularJS

I'm trying to make a virtual scroll and whenever the user scrolls down I need to add a negative top equal to the container height to each row. But of course this top property can vary depending of some factors like the user's screen resolution or browser window size.
So far this is what I got:
<div class="container" id="my-container">
<!--If it has the class row-scrolled the top property is applied-->
<div ng-repeat="(row) in virtualCollection"
ng-class="{'row-scrolled': controller.isScrolled}">
<!-- row properties -->
</div>
</div>
I have also thought about the idea of using ng-style but would override any style from my .css file.
Is there anyway to get the size/property of a DOM element...
// controller
var containerHeight = angular.element('#my-container')[0].clientHeight;
var cssProperty = '-' + containerHeight + 'px';
And then use it in an css?
// css
.row-scrolled {
top: cssProperty;
}
You can't pass variables from javascript to CSS since CSS is not a programming language but a style sheet language.
What you can do is manipulating specific elements with javascript.
Based on your code here is an example:
// controller
var containerHeight = angular.element('#my-container')[0].clientHeight;
var cssProperty = '-' + containerHeight + 'px';
var $$rowScrolled = document.querySelectorAll(".row-scrolled");
if ($$rowScrolled && $$rowScrolled.length > 0) {
for (var i = 0; i < $$rowScrolled.length; i++) {
var $rowScrolled = $$rowScrolled[i];
$rowScrolled.style.top = cssProperty;
}
}
With jQuery:
// controller
var containerHeight = angular.element('#my-container')[0].clientHeight;
var cssProperty = '-' + containerHeight + 'px';
var $rowScrolled = $(".row-scrolled");
if ($rowScrolled && $rowScrolled.length > 0) {
$rowScrolled.css("top", cssProperty);
}
You can not pass a variable to the CSS.
What you can do though is add the property directly using the ng-style tag:
<div class="container" id="my-container">
<!--If it has the class row-scrolled the top property is applied-->
<div ng-repeat="(row) in virtualCollection"
ng-style="{'top': controller.cssProperty}">
<!-- row properties -->
</div>

how to send base64 string as response in $http in angularjs

I am trying to send an image as base64 string in response in angularjs but the controller is moving to the error function.
The controller of angularjs is like this
angular.module('app', []).controller('showimageCtrl', showcustomimagecontroller);
showcustomimagecontroller.$inject = ['$scope', '$http'];
function showcustomimagecontroller($scope, $http) {
$http({
url: '/Home/showimage',
method: 'post'
}).then(function (response) {
$scope.image = response.data;
}, function (response) {
alert('error');
});
}
The .cshtml view is like this
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>textonimage</title>
<script src="~/scripts/jquery-3.1.1.min.js"></script>
<script src="~/scripts/angular.min.js"></script>
<script src="~/app/controller/myimagectrl.js"></script>
</head>
<body ng-app="app">
<div ng-controller="showimageCtrl">
<img width="1000" id="y" src="data:image/png;base64,{{image}}" />
</div>
</body>
</html>
The jsonresult showimage() in Home controller is like this
public JsonResult showimage()
{
//creating a image object
System.Drawing.Image bitmap = (System.Drawing.Image)Bitmap.FromFile(Server.MapPath("/images/DSC06528.JPG")); // set image
//draw the image object using a Graphics object
Graphics graphicsImage = Graphics.FromImage(bitmap);
//Set the alignment based on the coordinates
StringFormat stringformat = new StringFormat();
stringformat.Alignment = StringAlignment.Far;
stringformat.LineAlignment = StringAlignment.Far;
StringFormat stringformat2 = new StringFormat();
stringformat2.Alignment = StringAlignment.Far;
stringformat2.LineAlignment = StringAlignment.Far;
//Set the font color/format/size etc..
Color StringColor = System.Drawing.ColorTranslator.FromHtml("#933eea");//direct color adding
Color StringColor2 = System.Drawing.ColorTranslator.FromHtml("#e80c88");//customise color adding
string Str_TextOnImage = "Happy";//Your Text On Image
string Str_TextOnImage2 = "Onam";//Your Text On Image
graphicsImage.DrawString(Str_TextOnImage, new Font("arial", 400,
FontStyle.Regular), new SolidBrush(StringColor), new Point(3000, 545),
stringformat); Response.ContentType = "image/jpeg";
graphicsImage.DrawString(Str_TextOnImage2, new Font("Edwardian Script ITC", 401,
FontStyle.Bold), new SolidBrush(StringColor2), new Point(4000, 545),
stringformat2); Response.ContentType = "image/jpeg";
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
ImageConverter converter = new ImageConverter();
byte[] j= (byte[])converter.ConvertTo(bitmap, typeof(byte[]));
string base64String = Convert.ToBase64String(j, 0, j.Length);
return Json(base64String);
}
I want the angularjs to hit success function and display the image.
Thanks in advance.
I am assuming that response.data contains the base64 code of the image. (please comment if otherwise)
You should be using ng-src probably
<img width="1000" id="y" ng-src="data:image/png;base64,{{image}}" />
Otherwise the {{image}} expression will not get bound with $scope.image and evaluated by Angular.
The problem is that you're returning the base64-encoded image data directly as a JSON response. It is not JSON and can't be decoded as such, hence your error. Instead, you should return something like:
return Json(new { image = base64string });
This will result in an actual JSON document like:
{ "image": "[base64 encoded data]" }
You can then access the image member of your response data object:
$scope.image = response.data.image;

Get local file while in Fullscreen mode

I have swf that expands to fullscreen:
stage.displayState = StageDisplayState.FULL_SCREEN;
The second I try to select local file, it's collapsing to NORMAL_SCREEN
file_mask = new FileFilter("Images: (*.jpeg, *.jpg, *.png, *.JPG)","*.jpeg; *.jpg; *.png; *.JPG");
local_file.browse([file_mask]);
Is it bug, or feature, or the way it used to be ???
import flash.net.*;
import flash.events.*;
import flash.display.*;
expand_btn.addEventListener(MouseEvent.CLICK, openApp)
function openApp(e:MouseEvent) {
stage.displayState = StageDisplayState.FULL_SCREEN;
}
file_btn.addEventListener(MouseEvent.CLICK, openApp2)
function openApp2(e:MouseEvent) {
var local_file:FileReference = new FileReference();
var file_mask:FileFilter = new FileFilter("Images: (*.jpeg, *.jpg, *.png, *.JPG)","*.jpeg; *.jpg; *.png; *.JPG");
local_file.browse([file_mask]);
}
Use fullscreen interactive.
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
//Align top left of the stage.
stage.align = StageAlign.TOP_LEFT;
//align swf contents without scale.
stage.scaleMode = StageScaleMode.NO_SCALE;
and if you are embeding in browser add the below parameters.
<param name="allowFullScreenInteractive" value="true" />
Ref

wix bootstrapper application - install multiple packages on checkboxes

I'm a newbie to Wix burn. I'm making a wix Bootstrapper Application (BA) with multiple msi to install and an UI consisting of one panel with checkboxes and a button install. Each checkbox invites the user to select/unselect a msi, then the user presses "Install" and my BA should install the checked msi.
In my Chain element in the main .wxs file, I plan to use MsiPackage elements with a condition attribute to determine whether yes or no the user has selected it.
Now my question is : how to interface these condition attributes with the checkboxes ? Or in other words: how to get the checkbox information into the Wix .wxs file ?
I can explain how I do it. May there's a better way.
My checkBoxes are bound to properties in a ViewModel class. When a checkBox value is changed in the setter of the property I set the value of a variable
defined in the Bundle.wxs file.
private bool _installApp1Checked;
public bool InstallApp1Checked
{
get { return _installApp1Checked; }
set
{
_installApp1Checked = value;
if (value == true)
{
Bootstrapper.Engine.StringVariables["InstallApp1"] = "1";
}
else
{
Bootstrapper.Engine.StringVariables["InstallApp1"] = string.Empty;
}
RaisePropertyChanged("InstallApp1Checked");
}
}
private bool _installApp2Checked;
public bool InstallApp2Checked
{
get { return InstallApp2Checked; }
set
{
_installApp2Checked = value;
if (value == true)
{
Bootstrapper.Engine.StringVariables["InstallApp2"] = "1";
}
else
{
Bootstrapper.Engine.StringVariables["InstallApp2"] = string.Empty;
}
RaisePropertyChanged("InstallApp2Checked");
}
}
private bool _installApp3Checked;
public bool InstallApp3Checked
{
get { return _installApp3Checked; }
set
{
_installApp3Checked = value;
if (value == true)
{
Bootstrapper.Engine.StringVariables["InstallApp3"] = "1";
}
else
{
Bootstrapper.Engine.StringVariables["InstallApp3"] = string.Empty;
}
RaisePropertyChanged("InstallApp3Checked");
}
}
And in the Bundle.wxs I have:
<Wix ...>
<Bundle ...>
...
<Chain>
...
<MsiPackage>
...
<MsiProperty Name="InstallApp1" Value="[InstallApp1]"/>
<MsiProperty Name="InstallApp2" Value="[InstallApp2]"/>
<MsiProperty Name="InstallApp3" Value="[InstallApp3]"/>
...
</MsiPackage>
</Chain>
</Bundle>
</Wix>
By using the tag the properties of the ViewModel class are available in the wsx file.
Then these values are available at the moment of the installation in my product.wxs:
<Product >
...
<Property Id="InstallApp1">
</Property>
<Property Id="InstallApp2">
</Property>
<Property Id="InstallApp3">
</Property>
<Feature Id="ProductFeature" Title="Alvenos" Level="0">
<ComponentRef Id="ProductComponents" />
<Condition Level="1">InstallApp1</Condition>
</Feature>
<Feature Id="AlvenosVSIXFeature" Title="Alvenos" Level="0">
<ComponentRef Id="AlvenosVsix" />
<Condition Level="1">InstallApp2</Condition>
</Feature>
<Feature Id="AlvenosServerVSIXFeature" Title="Alvenos" Level="0">
<ComponentRef Id="AlvenosServerVsix" />
<Condition Level="1">InstallApp3</Condition>
</Feature>
...
</Product>
You can see the the default value of the Level attribute of the Feature tag is set to 0. That means that the app will not be istalled.
But if in the Condition tag InstallApp[1],[2] or [3] is set 1 the Level is set to 1 and the app is installed.
Use ComponentRef to refernce a Component tag that will contain information about the destination folder of the app that you will install.
<Fragment>
<ComponentGroup Id="InstallApp1" Directory="[target directory id]>
<Component Id="ProductComponent">
<File Source="[your app part of the installer]" />
</Component>
...
</Fragment>
I hope you get the idea.

Dynamically add LinkButton on Panel

I have ext:FileUploadField on the page. After file upload I need to show a link to this file.
I dynamically create a LinkButton, add it on the Panel1, and I can't see the the LinkButton! I dunno why!
<ext:Panel ID="Panel1" runat="server">
<Content>
<ext:FileUploadField ID="FileUploadField1" runat="server" EmptyText="Choose a file" FieldLabel="File" Icon="ImageAdd" />
</Content>
<Buttons>
<ext:Button ID="SaveButton2" runat="server" Text="Upload">
<DirectEvents>
<Click OnEvent="UploadClick"></Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:Panel>
protected void UploadClick(object sender, DirectEventArgs e)
{
if (this.FileUploadField1.HasFile)
{
var attachment = new Attachment { ............ };
if (UploadAttachment(attachment))
{
X.Msg.Show( ...... );
var linkButton = new LinkButton();
linkButton.ID = "fdsfdsfds";
linkButton.Text = attachment.Name;
linkButton.NavigateUrl = "#";
linkButton.Render();
Panel1.Add(linkButton);
// Panel1.Render(true);
Panel1.DoLayout(true,true);
}
else
{
//................
}
}
else
{
//................
}
}
I am guessing you need to add it to the buttons list of the Panel not to the panel itself. You may also have a layout issue if you have fit layout and adding a second item, that wont work.
Try to use this code:
X.Msg.Show( ...... );
var linkButton = new LinkButton();
linkButton.ID = "fdsfdsfds";
linkButton.Text = attachment.Name;
linkButton.NavigateUrl = "#";
linkButton.Render(Panel1, RenderMode.AddTo);
This will add link button directly to Panel1

Resources