I have a little project to do in flash and I am new with action script. I am using actionscript 2.0 and I just want to make a alarm app which can ring a sound when the time comes :P.
So I have 2 inputtext's one called alarm_hour and another alarm_min.
So the user enters the hour and the minute when it wants the alarm to ring. I am using Date class to pick the hour and the minute and my checkAlarm function it looks like this:
var my_date:Date = new Date();
var h:Number = my_date.getHours();
var m:Number = my_date.getMinutes();
var mi:String = alarma_minute;
var ora:String = alarma_hour;
if (((ora == h) && (mi == m))){
_root.sunet.start(0, 99);
_root.stare = 'start';
}
sunet its the sound file..
So the problem is that the if statement never activates but I don't know why because I have made a dinamic text and tested the values from ora and hour and mi and m and all are equals... what am I doing wrong?
Thank you!
I have managed to solve the problem by accessing the inputtext variables in this form: "variablename.text" and to do that I've had to change the inputtext instance name to "variablename" and now it works fine :D
Related
The Issue:
I Did use the Vuetify Calendar to build up a calendar.
The daily interval in Day View should be different according to business opening times that day.
The logic works for Firefox and Chrome. But not on Safari.
The working example:
Here is a Codepen i build to demonstrate the issue. When clicking on day View and moving between days there are different time ranges within the day. The Pen works on FF and Chrome, but not on Safari.
https://codepen.io/ttezcan/pen/KKzjEMM
This is the main method that changes interval dynamically:
setIntervalByWeekday(weekday) {
console.log(weekday);
if (weekday === 7) {
weekday = 0;
}
if (weekday === -1) {
weekday = 6;
}
this.weekday = weekday;
let start = this.bussiness_hours[weekday]['start'];
let end = this.bussiness_hours[weekday]['end'];
var timeStart = new Date('2020-05-19 ' + start).getHours();
var timeEnd = new Date('2020-05-19 ' + end).getHours();
var duration = timeEnd - timeStart;
this.firstInterval = start;
this.intervalCount = duration;
},
What i tried:
My research showed that the problem in Safari occurs when changing the values for
:first-interval="firstInterval" and
:interval-count="intervalCount"
dynamically.
I tried using computed props to force rerender of component.
I tried calling this.$refs.calendar.checkChange() to force rerender.
Anyone has an idea how to make this work for Safari?
A Vuetify dev had the answer:
new Date('2020-05-19 ' + start).getHours()
Chrome parses that as the system timezone and returns hours in the system timezone. Safari parses it as UTC and return hours in the system timezone. Use luxon or date-fns if you need to do arithmetic on dates.
Thx #KaelWD
Here I want to write a script that can stabilize the time lapse sequence by adding Warp Stabilizer VFX, then followed by deflicker using DEFlicker Time Lapse, and finally render and export the video, which runs before sleeping so that it does not slow down my computer at working time. However, I cannot find the API that adds effects to a layer in AE scripting documentation, does anyone knows how to do this? thanks in advance!
You can add effects to the layers like this:
if (!theLayer.Effects.property("Warp Stabilizer")){ //add only if no such effect applied
var theEffect = theLayer.property("Effects").addProperty("Warp Stabilizer"); // the regular way to add an effect
}
To test it you can add it to selected layer, full code to apply it to the selected layer can look like this:
var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) { // only proceeds if one comp is active
if (activeItem.selectedLayers.length == 1) { // only proceeds if one layer is selected
var theLayer = activeItem.selectedLayers[0];
if (!theLayer.Effects.property("Warp Stabilizer")){
var theEffect = theLayer.property("Effects").addProperty("Warp Stabilizer"); // the regular way to add an effect
}
}
}
Solution is based on adobe forum: https://forums.adobe.com/thread/1204115
I have a family tree website and want to show all events in our family on the current date (Month and Day). So, if today's April 3rd, I want to show all events in our family that occurred on April 3rd.
I've played with creating a table and hiding rows, etc. but the table's too big and it's taking too long. So, I've decided to create a separate .htm file for each day of the year (i.e., todayinhistory-0101.htm, todayinhistory-0102.htm, etc.).
I have a button which, when clicked, is to get the current date in MMDD format and then open the correct file.
I have the script to get the correct filename using the current date in MMDD format, but I can't figure out how to call it and make it work.
Right now, my button looks like this:
<button onclick="location='GetTodayInHistoryFilename()'">
GetTodayInHistoryFilename() is a function I know works. I just can't get the button format right to call it.
Obviously, I'm a novice and would appreciate anyone's help.
In case you're interested, here's GetTodayInHistoryFilename() - which is loaded in the page's header section:
<script type='text/javascript'>
function GetTodayInHistoryFilename()
{
var Today = new Date();
var TodayMonth = Today.getMonth()+1;
var TodayDay = Today.getDate();
if (TodayMonth < 10) { TodayMonth = '0' + String(TodayMonth); } else { TodayMonth = String(TodayMonth); }
if (TodayDay < 10) { TodayDay = '0' + String(TodayDay); } else { TodayDay = String(TodayDay); }
return 'todayinhistory-' + TodayMonth + TodayDay + '.htm';
}
</script>
Thanks in advance.
I'm not 100% sure this is what you're trying to do but I think you want the button click to navigate to another HTML page in which case - you're not far off:
<button onclick="window.location=GetTodayInHistoryFilename()">
Explanation: You're setting the location property of the window object (your browser's top level frame, in this case) to (a new url). You've defined this using your function which is fine. The only mistake you made was to include the function in quotes. This meant that function name was treated as a literal text string rather than an executable function.
You may or may not need to specify window. (the global object) in window.location. I wasn't sure myself but it's nicely answered here: window.location versus just location
I want to create a scoring system. I have 4 buttons with 4 different but similar scripts and want to share 1 GUI Text for the scores. Example Code:
var something : Sprite;
var SpriteRenderer : SpriteRenderer;
var score : int = 0;
var guiScore : GUIText;
function OnMouseDown () {
if(SpriteRenderer.sprite == something) {
score += 1;
guiScore.text = "Score: " = score;
}
}
Right now, if I pressed a button and got a point then I pressed a different button the score would start from 0 again. How can I share data something like static variables but different scripts? I know this sounds a bit noobie but any help would be much appreciated. Thanks in advance
Static variables won't appear in the inspector so you can't assign the GUIText in the inspector (thanks for making me find out). So try using GetComponent instead:
// make a variable of type GUIText
var guiScore: GUIText;
// assign the gameobject in the inspector
var staticObject: GameObject;
// Again I don't know the name of your script, so I'll name it StaticScript
// get the script
StaticScript scr = staticObject.GetComponent(StaticScript);
// assign local GUIText with the one from above
guiScore = scr.guiScore;
This way you have already shared 1 GUIText for all other scripts.
However you said:
Right now, if I pressed a button and got a point then I pressed a
different button the score would start from 0 again
Doesn't that mean something is wrong with the score, not the GUIText?
I've been looking for an ActionScript 2.0 preloader using the ProgressBar component, and I can't find an example of this. Can anyone direct me to a nice tutorial for this? I just want to add a simple preloader to the beginning of my movie. It doesn't load any external movies. Thanks!!
I finally tracked down the coded I needed to use with the ProgressBar component:
myProgressBarListener = new Object();
myProgressBarListener = function (eventObject) {
myProgressBar._visible = false;
gotoAndPlay(2);
};
myProgressBar.addEventListener("complete", myProgressBarListener);
myProgressBar.mode = "polled";
myProgressBar.source = "_root";
myProgressBar.conversion = "1";
myProgressBar.label = "LOADING %3%%";
myProgressBar.direction = "right";
myProgressBar.labelPlacement = "bottom";
stop();
This is good for AS 2.0 and I'm using CS6. I'm not sure how this works for other versions of Flash.