as3 .text not working - actionscript-3

So heres the code Im using:
endScreen.scorePrint.text = String(score);
endScreen.distancePrint.text = String(distance);
And it doesent show anything, while the very same code in other places in my app works, I tried to embed fonts and stuff but I still get blank space. what am I doing wrong?
EDIT:
endScreen is a MovieClip without AS linkage, its manipulated by .visible , scorePrint and distancePrint are a part of that MovieClip.
scorePrint and distancePrint are identical in all but names and are as following:
classic text -> dynamic text

Try
endScreen.scorePrint.text = "" + score;
if not, then does
trace("" + score);
show anything?

I fixed it, the problem was anti-aliasing. I changed from anti-aliasing for readability to device fonts. that fixed both fields.
Thanks for support :)

Related

Can you help me fixing this Slider code in ActionScript 3?

I got a dynamic Textfield called txt_nOpp setted to 1, I also got a slider, called Slider1, The slider can only assume values betweed 1 and 6. While the user sets slider value, the text should change.
I've implemented this code:
Slider1.addEventListener(SliderEvent.CHANGE, slHandler);
function slHandler(e:SliderEvent):void{
txt_nOpp.text = String(e.value);
}
Flash doesn't return any error, but the slider/text works only at value 1, the other values of the slider make the text disappear... What's wrong?
SliderEvent.CHANGE only updates when you release the slider, so try
Slider1.addEventListener(Event.ENTER_FRAME, function()
{
txt_nOpp.text = Slider1.value.toString();
});
instead.
I fixed it, it was an anti aliasing problem, just set it as device font and now works

Windows Phone 8 ApplicationBar expanded unchangable transparancy

following Code...
<!--Navigation-Bar-->
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" ForegroundColor="White" IsMenuEnabled="True" BackgroundColor="#002B55">
<shell:ApplicationBarIconButton Click="B_Search_Click" IconUri="Images\Pic_Search.png" Text="Search"/>
<shell:ApplicationBarIconButton Click="B_Media_Click" IconUri="Images\Pic_Media.png" Text="Media"/>
<shell:ApplicationBarIconButton Click="B_Scan_Click" IconUri="Images\Pic_Scan.png" Text="Scanner"/>
<shell:ApplicationBarIconButton Click="B_Charts_Click" IconUri="Images\Pic_Charts.png" Text="Charts"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Click="B_Logout_Click" Text="Logout"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
gives me following ApplicationBar...
http://s14.directupload.net/file/d/3341/4xiadbvz_jpg.htm
(Solid background when expanded)
BUT if I create the AppBar in CodeBehind like this...
private void ResetApplicationBar()
{
ApplicationBar = new ApplicationBar();
ApplicationBar.BackgroundColor = Color.FromArgb(150, 0, 43, 85);;
ApplicationBar.ForegroundColor = Colors.White;
ApplicationBar.Opacity = 1;
ApplicationBarIconButton B_Search = new ApplicationBarIconButton();
B_Search.IconUri = new Uri("/Images/Pic_Search.png", UriKind.Relative);
B_Search.Text = "search";
ApplicationBar.Buttons.Add(B_Search);
B_Search.Click += new EventHandler(B_Search_Click);
(more Buttons...)
then I get that misterios unchangable Transparency...
http://s1.directupload.net/file/d/3341/zjo57e37_jpg.htm
(Half-Transparent when expanded)
How can I change the Background to solid???
-Yes I have mostly overwritten the theme
-Changing global colors doesnt work
-changing background/foreground doesnt work
-changing opacity doesnt work...
I need to generate it from code behind because im changing it dynamically in one window
(or is it possible to define multiple AppBars in markup?)
Thanks in advance!
Please try this one
ApplicationBar.BackgroundColor = Color.FromArgb(52,0,2,181);
ApplicationBar.ForegroundColor = Colors.White;
You will get the same color in designer page by this way.
This (52,0,2,181) is the conversion value of #002B55
On a fresh project, everything seems fine, here.
"- changing background/foreground doesnt work
- changing opacity doesnt work..."
Using the Application Bar sample, you provided in XAML, but with Opacity=0.5, I get this :
After I click the "Change Color" button, which does ApplicationBar.Opacity = 1;, I get this result :
(The background image is slightly moved up, because in first case we provided an opacity and in the second there was none explicitly specified and it seems the app bar didn't layered over the image, but to fix this you can set an Opacity=0.999, close to 1).
It must have something to do with all the theme overwriting you have done or some customization you attempted.
If this isn't quite helpful, provide me more details and I'll try to help as I can.
Thank you very much for effort, but changing opacity didnt to 0.999 didnt help either.
I found a solution!! And its quite simple :)
I Just take the old bar instead of creating a new one:
//Old Code
ApplicationBar = new ApplicationBar();
//New Code
ApplicationBar.Buttons.Clear();
ApplicationBar.MenuItems.Clear();
Hope it helps someone!

Only one instance of a Swiffy conversion works on page with multiple conversions?

Placing multiple swiffy conversions on the same page seems to conflict, only the first one shows up. Is there an area of code, possibly instance names, that I can change on each one so that multiple conversions can appear on the same page?
Here's a link to the page I'm talking about: http://www.ufonies.com/fansmobi.html
The animation in the header works fine, there should be another small animation under the "Space Golf" image but it just appears as a blank space, the conversion code there.
Thanks
I had this problem too with a slider - each slide was a swiffy animation and every time I used two or more animations, swiffy threw an error.
I got around this by using iframe containers for slides instead of divs - this way each animation had its own namespace for variables and scripts.
I hope this helps.
It's pretty simple actually
The swiffyobject should be renamed to anything ex. swiffyobject2, swiffyobject3 and so on.
See in this example the container is renamed to container2 so is the Element id
And then i call swiffyobject2 instead of swiffyobject. that way we can use as much instances of swiffyobjects as we want.
<div id="swiffycontainer2" style="width: 190px; height: 195px">
</div>
<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer2'),
swiffyobject2);
stage.start();
</script>
I like to create separate js files for every object and just call one instance of
<script src="https://www.gstatic.com/swiffy/v5.2/runtime.js"></script>
but that's just a personal taste. Hope this helps.
Try to make new instance.
Example:
var swiffyIntroSlide = new swiffy.Stage(document.getElementById('intro-slide'), introSlide);
swiffyIntroSlide.start();
var swiffyBanquePopulaire = new swiffy.Stage(document.getElementById('top-banner'), banquePopulaire);
swiffyBanquePopulaire.start();
Notes:
introSlide & banquePopulaire are variables of swiffy objects.

AS3 Not Adding Sprite to MovieClip

My code is simply looping through an xml file and creating 'pages' (which are later animated).
This has all worked fine but now I want to add a sprite over the entire contents of the page if the contents of the xml contain a URL.
At run-time I can see that the checks for the URL are being processed correctly and that the overlay is being generated, but I cannot "see" it on the page.
The following code is located in a for loop for every page in the xml file:
var page:Page = new Page(); //MovieClip in my library
// ... other stuff
var textMC:FadeText = new FadeText(xml); //load the text from the xml fragment for this page
//if the text contains a URL (using RegExp)
if(textMC.hasLink())
{
var button:Sprite = new Sprite();
button.graphics.beginFill(0x000000);
button.graphics.drawRect(0, 0, 1, 1);
button.name= textMC.getLink();
button.x = button.y = button.alpha = 0;
button.width = rectangle.width;
button.height = rectangle.height;
button.buttonMode = true;
button.addEventListener(MouseEvent.CLICK, goToUrl, false, 0, true);
page.addChildAt(button, page.numChildren);
}
//... more code - such as add page to stage.
From the console (using FireBug and FlashBug) the button is being created, but I cannot see it on screen so I am guessing the addChild bit is at fault.
What is wrong and how do I fix it?
[edit]
Having set the alpha to 1 I can see that the overlay IS being added to the page, but it is not changing my cursor or responding to mouse clicks.
I now believe it is something wrong with the XML. It is correctly parsed XML (otherwise FlashPlayer would throw exceptions in my face) and it appears that this code works on every page except the second. Further more, if the second page is set as visible (a flag in the XML determins if the page is created or not) then none of the other pages overlay works.
Sorry to necro this thread but one thing I can think of is that because you specify a z-position to place your page it might be that the z-position generated by (i+1) is not the next one in line. AS3 doesn't allow display-objects to be placed on 'layers' with empty 'layers' between them which was allowed in AS2.
My guess is that during the loop at one point or another the loop doesn't generate a page which leaves an empty layer. The reason why the stage.addChild(page) actually works is because it simply searches for the next empty layer in that stack because you don't specify it.
button.x = button.y = button.alpha = 0;
set alpha to 1
button.alpha = 1;
and check for rectangle.width , rectangle.height
last thing, check for textMC.hasLink() if its true or not. If its true, there is another problem with your code that is not related to this sample code.
Illogical answer:
Replaced stage.addChildAt(page,i+1); with stage.addChild(page);.
I was clutching at straws. Have spent FAR too long working on this blip, but it works! I don't know WHY it works, and at this point I don't care; IT WORKS!!! (sorry for the unprofessionalism however I have spent two and a half days working on this and have just got it working!)
If someone wants to explain why it works, feel free. I would VERY much prefer to learn why this occurs that struggle to work around it.

Internet Explorer form input problem

I'm having a ton of problems with every version of IE, one of which is that IE7 won't register input in this text input field.
http://www.flightm8.com/redesign
I'm a bit nervous about posting the link since the site looks a mess and doesn't function properly in any version of IE at the moment, and it is still quite a way off being ready for public consumption. But if anyone can shed any light on this particular problem I'd very much appreciate it.
So the question is: What is causing this problem in IE7?
Update: I've also added an additional textfield at the bottom of the page to try and rule out any CSS wierdness that might be causing the problem.
<form method="post" action="nowhere.php">
<input type='text' name='test' value='testing' />
</form>
And I still can't enter any text, or select the text that is in there. I'm wondering now if it's a problem caused by running a standalone version of IE7 and IE6.
thanks
-t
the function causing problem is this one :
function modalAlert
the call that need to be debugged is this one :
modalAlert("NO SELECTIONS");
in
function findRoutes
the line that bug is :
$("#dialog").css("top", dTop);
first, you should avoid iframes when you can, why don't you do :
var message = $('<div></div>').load('/modal/"+modalpage);
instead of crappy code like this :
var iframe = "<iframe id='modal_frame' width='533' height='292' src='/modal/"+modalpage+"' >You didn't give me any information</iframe>"
If you don't need iframes, don't use them !
$('body').append(message);
I have IE7 on win xp (native), I was able to enter text but after a freeze (when you add all those markers), then when entering text and clicking on "find routes", there's a bug that i just explained to you ...
I would imagine it is because the input box doesn't have a 'name' field, which is used when posting form data.