ArgumentError: Error #1063 issue - actionscript-3

This is usually a simple error, yet I cannot find an obvious answer.
The full error is: 'ArgumentError: Error #1063: Argument count mismatch on com::previewSelection/selectionOn(). Expected 2, got 1.'
The obvious issue is that I'm only giving 1 bit of information and not 2, however I am definitely giving 2.
Main code:
function previewOn(e){
previewTile2.selectionOn(holdBar_mc, area1_mc);
previewTile2.removeEventListener(MouseEvent.CLICK, previewOn);
previewTile2.addEventListener(MouseEvent.CLICK, previewOff);
stage.setChildIndex(previews, 1);
var editOpen:Tween = new Tween(editTab, 'x', Strong.easeOut, editTab.x, -215, 1, true);
createTiles();
}
And the class file function:
public function selectionOn(holdBar:MovieClip, area1:MovieClip){
holdBarDown = new Tween(holdBar, 'y', Strong.easeOut, holdBar.y, 518, 1, true);
area1Up = new Tween(area1, 'y', Strong.easeOut, area1.y, area1.y - 300, 1, true);
}
Neither holdBar_mc or area1_mc are 'null' when traced.
The file runs without issue or slow-down, yet the Argument error constantly returns. Any ideas?

Related

How to use Math.LN(x) in ActionScript 3

How to use Math.LN(x) in ActionScript 3?
I have a formula to convert:
17.867 * LN(x)-29.263
How to write in ActionScript 3? I'm confused about how to write it.
What I've tried :
var Kc:Number;
var value_x:Number;
function enterFrameHandler () : void
{
value_x=80;
Kc=(17.867)*Math.LN10(value_x) - 29.263;
value_Kc.text=String(Kc);
trace(Kc);
//y = 17.867ln(x) - 29.263//
}
enterFrameHandler();
Getting error :
Error : Scene 1, Layer 'Layer 1', Frame 1, Line 7, Column 19 1195 :
Attempted access of inaccessible method LN10 through a reference with
static type Class.
thanks for your replied #Organis may be directly show problem in my code
var Kc:Number;
var value_x:Number;
function enterFrameHandler () : void
{
value_x=80;
Kc=(17.867)*Math.LN10(value_x) - 29.263;
value_Kc.text=String(Kc);
trace(Kc);
//y = 17.867ln(x) - 29.263//
}
enterFrameHandler();
///get error Scene 1, Layer 'Layer 1', Frame 1, Line 7, Column 19 1195: Attempted access of inaccessible method LN10 through a reference with static type Class.//

Call Timepicker with data-values

I have trouble calling timepicker with class and passing data-values to the script.
So what i have so far is one loop that for each entry it will create
foreach($data as $value){
$min_hour = $value['minhour']; // returns value from DB like 7 to 12
echo '<td><input type="text" value="" class="schedule-timepicker" data-minhour="'.$min_hour.'" data-minminutes="30" data-maxhour="17" data-maxminutes="00"></td>';
}
Then in js file I have
$(document).ready(function(){
$('.schedule-timepicker').timepicker({
timeFormat: 'HH:mm:ss',
minDate: new Date(1, 1, 1, $('.schedule-timepicker').data('minhour'), 00),
maxDate: new Date(1, 1, 1, $('.schedule-timepicker').data('maxhour'), 00),
});
});
Problem is that the timepicker is called out and works but every input has the same minimum hours value as the first one. Please help how to resolve this.
Thanks.
So help from cyberRobot # forums.phpfreaks.com pointed out that I have made a mistake in the code and I want to share it with others just in case it will help someone else in the future.
$('.schedule-timepicker').each(function () {
$(this).timepicker({
timeFormat: 'HH:mm:ss',
minDate: new Date(1, 1, 1, $(this).data('minhour'), 0),
maxDate: new Date(1, 1, 1, $(this).data('maxhour'), 0)
});
});
PS. Thanks for not helping.!
And to the stupid prick who voted a minus at my help request .. Fu*k you.

Error #2109 half the time

I'm making a platform game in AS3.
Everything is running fine except sometimes (not each time I run the game), I've got this error :
ArgumentError: Error #2109: Frame label null not found in scene null.
at flash.display::MovieClip/gotoAndStop()
at PlatformGame/moveCharacter()[C:\...\PlatformGame.as:581]
at PlatformGame/moveEnemies()[C:\...\PlatformGame.as:360]
at PlatformGame/gameLoop()[C:\...\PlatformGame.as:348]
I don't understand AT ALL why it happens randomly..
Do you know what could be the problem ?
Here's the lines in the error :
line 581 :
char.mc.gotoAndStop(char.walkAnimation[Math.floor(char.animstep)]);
line 360 :
moveCharacter(enemies[i],timeDiff);
line 348 :
moveEnemies(timeDiff);
Thank you for your help,
You ask to 'mc' (contained in 'char') to go to the frame which number
is contained in the array 'walkAnimation' at the index: Math.floor(char.animstep).
The error you have got means that, for some reason, 'Math.floor(char.animstep)' index doesn't exist in the array 'walkAnimation'.
Exactly as if you wrote :
var frame:Array = [1, 2, 3];
gotoAndStop(frame[10]);
frame[0] is 1, frame[1] is 2, frame[2] is 3, but frame[10] is undefined.

AS3 syntax compile errors - expecting semicolon before rightparen

I know this is extremely basic but the following function is generating 2 syntax errors on compile, these are shown below. I can't figure them out. Any help is much appreciated.
Game, Layer 'Actions', Frame 2, Line 5 1086: Syntax error: expecting semicolon before rightparen.
Game, Layer 'Actions', Frame 2, Line 5 1084: Syntax error: expecting rightbrace before semicolon.
function fl_TouchEndHandler_2(event:TouchEvent):void {
// Drag & drop stuff...
contained[i] = Gem1_MC.hitTestObject(Gem4_MC));
contained[i] = Gem2_MC.hitTestObject(Gem4_MC));
contained[i] = Gem3_MC.hitTestObject(Gem4_MC));
if (contained.indexOf(false) == -1) { // This returns -1 if it can't find false
gotoAndStop(1);
}
}
You have extra ')'
try:
function fl_TouchEndHandler_2(event:TouchEvent):void {
// Drag & drop stuff...
contained[i] = Gem1_MC.hitTestObject(Gem4_MC);
contained[i] = Gem2_MC.hitTestObject(Gem4_MC);
contained[i] = Gem3_MC.hitTestObject(Gem4_MC);
if (contained.indexOf(false) == -1) { // This returns -1 if it can't find false
gotoAndStop(1);
}
}

AS3 sortOn woes

I have an Array called alarmQueue. I'm pushing a new arrays in to it with the contents [hours:int, minutes:int, seconds:int] and I'd like to use alarmQueue.sortOn() to sort the queue of alarms Ascending but I'm having problems getting my head around the logic.
// the function to push the alarm in to a queue
public function setAlarm(_hours:int = 0, _minutes:int = 0, _seconds:int = 0):void
{
var alarmAsArray:Array = new Array(_hours, _minutes, _seconds);
alarmQueue.push(alarmAsArray);
alarmQueue.sortOn([0, [1, 2]], Array.NUMERIC | Array.DESCENDING);
trace(alarmQueue);
}
I'm setting these alarms:
clock.setAlarm(1, 0, 31); // alarm 1
clock.setAlarm(12, 1, 21); // alarm 2
clock.setAlarm(12, 1, 19); // alarm 3
and getting the following traces:
1,0,31
12,1,21,1,0,31
12,1,21,12,1,19,1,0,31
I seem to be ordering them as: alarm 2, alarm 3, alarm 1
but I want to be ordering them by hour, then minute and seconds.
Can anyone shed any light on my sorting woes?
Cheers!
thanks for the feedback.
I've tested:
alarmQueue.push(
{
hours: _hours,
minutes: _minutes,
seconds: _seconds
});
alarmQueue.sortOn(
['hours', 'minutes', 'seconds'],
[Array.NUMERIC | Array.ASCENDING, Array.NUMERIC | Array.ASCENDING, Array.NUMERIC | Array.ASCENDING]
);
if(alarmQueue.length == 3)
{
for(var i:int = 0; i SMALLERTHAN alarmQueue.length; i++)
{
trace(alarmQueue[i].hours,alarmQueue[i].minutes, alarmQueue[i].seconds);
}
}
I had to change the trace slightly due to the array items being objects now and used SMALLERTHAN as the < symbol seems to break to code tags here, but the app wouldn't compile as Flex Builder was telling me Array.ASCENDING not being a sort method, so I checked livedocs and found no mention of it there too. Any other guesses?
This should work, but I have not tested it.
public function setAlarm(_hours:int = 0, _minutes:int = 0, _seconds:int = 0):void
{
alarmQueue.push(
{
hours: _hours,
minutes: _minutes,
seconds: _seconds
});
alarmQueue.sortOn(['hours', 'minutes', 'seconds'], Array.NUMERIC);
}
Found the answer after some tinkering. The default method of sorting is ascending but there's no option to set Ascending as a secondry sorting method. So by performing two sorts, the first descending on the minutes and seconds, the second is a sortOn the hours with no parameter applied so it sorts ascending!
var alarmAsArray:Array = new Array(_hours, _minutes, _seconds);
alarmQueue.push(alarmAsArray);
alarmQueue.sortOn([1, 2]);
alarmQueue.sortOn([0], Array.DESCENDING);
if(alarmQueue.length == 3)
{
trace(alarmQueue);
}
this gives the correct output of: 12,1,19 12,1,21 1,0,31
Many thanks all!
ant