How can I reset clicks made while page loading - windows-store-apps

I have window store application. I try to navigate to a page, which is loading for some time (few seconds). The page contains several big pictures therefore it's loading for some time especially at weak devices. The problem appears when I click while the page is loading - the click will be processed when page is loaded. If user click in point where will be a button when page is loaded, button will be clicked.
How can I turn this feature off? Is there any way to reset clicks while loading?

Instead of resetting the clicks on page load this can be taken care of by a better design approach.
On page load, show an indeterminate progress bar and once the image load finishes hide the progress bar and show your actual screen.
Below is an example to achieve this by putting the progress bar in a PopUp control in the
navigationHelper_LoadState(object sender, LoadStateEventArgs e) event
//Progress Bar
ProgressBar bar = new ProgressBar();
bar.IsIndeterminate = true;
//Downloading Data text
TextBlock txt = new TextBlock();
txt.Text = "Downloading data...";
txt.FontSize = 17;
txt.Foreground = new SolidColorBrush(Colors.White);
txt.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
//This could take a few seconds
TextBlock txt2 = new TextBlock();
txt2.Text = "This could take a few seconds.";
txt2.FontSize = 17;
txt2.Foreground = new SolidColorBrush(Colors.White);
txt2.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
//Please do not close the application.
TextBlock txt3 = new TextBlock();
txt3.Text = "Please do not close the application.";
txt3.FontSize = 17;
txt3.Foreground = new SolidColorBrush(Colors.White);
txt3.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
StackPanel stk = new StackPanel();
stk.Children.Add(bar);
stk.Children.Add(txt);
stk.Children.Add(txt2);
stk.Children.Add(txt3);
stk.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
Grid contentGrid = new Grid();
contentGrid.Height = Window.Current.Bounds.Height;
contentGrid.Width = Window.Current.Bounds.Width;
// or from LayoutGrid
//contentGrid.Height = LayoutRoot.ActualHeight;
//contentGrid.Width = LayoutRoot.ActualWidth;
contentGrid.Width -= 40; // it seems that ContentDialog has some defaul margin
contentGrid.Children.Add(stk);
Popup dlg = new Popup();
dlg.Child = contentGrid;
SolidColorBrush color = new SolidColorBrush(Colors.Black);
color.Opacity = 0.7;
//dlg.Background = color;
dlg.IsOpen = true;
Once the images have loaded you can choose to close this PopUp

Related

Disable Focus - AS3

I'm relatively new to Flash, and I was just wondering if there was any way to keep the focus off certain elements (specifically, a button, but also input text areas and such alike).
It's nothing to drastic, but it annoys me having the tab key focus on a button rather than other things. I'd rather just be able to disable the focus on that object permanently if that possible.
Thank you so much!
To disable that your component (object) get the focus when the Tab key is pressed, you can use the tabEnabled property and set it to false, like this :
// button control
var button:Button = new Button(); // fl.controls.Button
button.tabEnabled= false;
addChild(button);
// input text field
var text_field:TextField = new TextField();
text_field.type = 'input';
text_field.tabEnabled = false;
addChild(text_field);
Also, for a UIComponent like fl.controls.ColorPicker, fl.controls.ComboBox, ..., you can use the focusEnabled property like this :
// color picker control
var color_picker:ColorPicker = new ColorPicker(); // fl.controls.ColorPicker
color_picker.focusEnabled = false;
addChild(color_picker);
// slider control
var slider:Slider = new Slider(); // fl.controls.Slider
slider.focusEnabled = false;
addChild(slider);
Hope that can help.

How can buttons, in a table, be set to the same size?

I'm trying to make the UI more appealing by setting the main menu buttons to be the same size.
So the "Play" button is a bit bigger than the "Quit" button, and I tried :
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/myfont.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 22;
mButtonSpacefont = generator.generateFont(parameter);
generator.dispose();
// Table for Buttons
Table table=new Table();
table.setSize(800, 480);
// Button Skin
Skin skin = new Skin();
TextureAtlas buttonAtlas = new TextureAtlas(Gdx.files.internal("gfx/buttons.pack"));
skin.addRegions(buttonAtlas);
// BUTTON PLAY
TextButtonStyle textButtonStyle = new TextButtonStyle();
textButtonStyle.font = mButtonSpacefont;
textButtonStyle.up = skin.getDrawable("button_top");
textButtonStyle.down = skin.getDrawable("button_bottom");
final TextButton buttonPlay = new TextButton("Play", textButtonStyle);
table.add(buttonPlay);
table.row();
// BUTTON QUIT
final TextButton buttonQuit = new TextButton("Quit", textButtonStyle);
buttonQuit.setWidth(buttonPlay.getWidth());// make the Quit button same size as Play button
table.add(buttonQuit).padTop(50);
table.row();
However, this doesn't work! The Quit button is still smaller than the Play button
Is there anything I did wrong ?
To size all your buttons you could use the width method from the Cell class instead, like for example:
table.add(buttonPlay).width(100);
table.row();
table.add(buttonQuit).width(100);
then your buttons should end up having all the same width.

Flash ScrollPane confusion, scrolling down scrolls to the right

I have a confusing ScrollPane issue that I hope someone has encountered before!
I have a movie clip called Inner_Area, which gets a number of other smaller movie clips loaded into it. The end effect is that it looks like a list of strings.
After the Inner_Area movieclip is populated with its additional information, I set the source of a ScrollePane object to it.
scroll_area.source = Inner_Area;
When I play the movieclip, the list loads up successfully, and a scroll bar appears on the right hand side. This is where the strange part happens.
If I click the scroll down arrow, to try to see the items at the bottom of the list, the Inner_Area actually seems to scroll to the RIGHT. Not down at all. I've looked over my actionscript and I cannot for the life of me see how this could be.
I've not included any code, of course, because I am initially hoping that someone may have experienced a similar situation before. How can I get a scrollpane area such that when you scroll down, it actually goes down instead of in a different direction?
Any hints, tips, or advice is much appreciated!
Some Code:
public class MenuBackground extends MovieClip
{
scroll_area = new ScrollPane();
scroll_area.x = -275;
scroll_area.y = -77;
scroll_area.width = 250;
scroll_area.height = 175;
addChild(scroll_area);
inner_area = new Inner_ZoneScrollArea();
spacing = 0;
for (i= 0; i < numthings; i++)
{
_field = new _Field();
_field.y = spacing;
spacing = spacing + 20;
inner_area.addChild(_field);
}
scroll_area.source = inner_area;
}
And in a different file, is the _Field code:
public function _Field()
{
_Format = new TextFormat();
_Format.size = 16;
_TextField = new TextField();
_TextField.x = 50;
_TextField.y = 4;
_TextField.textColor = 0xFFFFFF;
_TextField.defaultTextFormat = _Format;
_TextField.autoSize = "left";
_TextField.multiline = true; // Just added these last two on suggestion in this thread
_TextField.text = "Name"; // some text
addChild(_TextField);
}
not sure if you have got this one fixed yet mate but I think I had a similar issue trying to add Dynamic content to a ScrollPane if your having an issue with the scrollbars not coming up you need to do an update to the ScrollPane I had to put mine on a Timer so that it gave the content time to append and then update. like so
var timer:Timer = new Timer(3000,1);
timer.addEventListener(TimerEvent.TIMER, updateEvent);
timer.start();
function updateEvent(e:TimerEvent):void
{
ScrollPane.update();
timer.stop();
}
hope this helps any one else with a similar issue loading Dynamic content into a ScrollPane
The following simple example produces a ScrollPane that scrolls down:
var tf:TextField = new TextField();
tf.text = "Lorem \nIpsum dolor \nsit amet \nthese are \nmany\nmany \nmany \nmanylines of \ntext";
tf.autoSize = "left";
tf.multiline = true;
var sp:ScrollPane = new ScrollPane();
sp.source = tf;
addChild(sp);

Windows Phone 8: How can I make a map's pushpin textbox to stay on top of any other elements on the map?

I have a map with 100 pushpins. Every time I tap a pushpin, a textbox with description is opened near that pushpin (only 1 textbox can be opened at a time, when you tap a pushpin, the previous opened textbox is closed first), but sometimes the textbox is not on top of other pushpins, other pushpins appear above the textbox, making it hard to read the description. I've tried using Canvas and Canvas.ZIndex, but nothing worked properly.
I had a similar issue, and I solved it my removing and adding the object again whenever it was tapped.
MapLayer theLayer = new MapLayer();
MapOverlay theOverlay = new MapOverlay()
{
GeoCoordinate = new GeoCoordinate(lat, lng)
};
var pp = new StackPanel { Background = new SolidColorBrush(Colors.Black), Orientation = System.Windows.Controls.Orientation.Vertical };
var img = new Image()
{
Source = new BitmapImage(new Uri(url, UriKind.Absolute)),
Width = 50,
Height = 50
};
pp.Children.Add(img);
img.Tap += (object emitter, System.Windows.Input.GestureEventArgs e) => {
theLayer.Remove(theOverlay);
theLayer.Add(theOverlay);
};
theOverlay.Content = pp;
theLayer.Add(theOverlay);
Hope this helps!

Toggle Mute sound in Actionscript 3

I have several tracks of audio that are in sinc. I would like to have one "TitleMusic" ON from the start, And allow the user to toggle ON and off the other tracks. My code As it stands has the "TitleMusic" playing from the start with all the other tracks playing too. I need to switch "track8" and all the other tracks (not showing) around so they are off at the start.This took me a long time to get to this point, I just need some help turning it around. Thanks
import flash.media.Sound;
import flash.media.SoundChannel;
var soundOn:Boolean = true;//This music is ON when we start
var myMusic:TitleMusic = new TitleMusic();
var myChannel1:SoundChannel = myMusic.play(0,1000);//endless loop, in effect
var soundOn3:Boolean = true; //music is ON when we start
var myMusic3:track8 = new track8();
var myChannel3:SoundChannel = myMusic3.play(0,1000); // endless loop, in effect
var myTransform3:SoundTransform;
mySoundButton3.addEventListener(MouseEvent.CLICK,toggleSound3);
mySoundButton3.buttonMode = true;
mySoundButton3.mouseChildren = false;
function toggleSound3(e:MouseEvent)
{
if(soundOn3)
{
// turn sound off
myTransform3 = new SoundTransform();
myTransform3.volume = 0; // silent
myChannel3.soundTransform = myTransform3;
soundOn3 = false;
mySoundButton3.myButtonText.text = "click to turn sound ON";
}
else // sound is off
{
// turn sound on
myTransform3 = new SoundTransform();
myTransform3.volume = 1; // full volume
myChannel3.soundTransform = myTransform3;
soundOn3 = true;
mySoundButton3.myButtonText.text = "click to turn sound OFF";
}
}
Couldn't you just put this line right after mySoundButton3.mouseChildren = false;:
toggleSound3(null);
Or, to be more efficient with memory, you could do this:
Take this line:
var myChannel3:SoundChannel = myMusic3.play(0,1000);
and change it to:
var myChannel3:SoundChannel;
This makes it so you're not actually starting the sound right away, but just creating the pointer for it (var)
Then, in your turn on block right after // turn sound on:
if(!myChannel13){
myChannel3 = myMusic3.play(0,1000);
}
This checks to see if you've started the sound yet, if not, it creates/starts the sound
You'll also want to change this line in your sound off block:
myChannel3.soundTransform = myTransform3;
to this
if(myChannel13){
myChannel3.soundTransform = myTransform3;
}
That way, if the off button is clicked before the on button, it won't throw an error.