Copy link to clipboard
Copied
hello guys, im new to actionscript, i start practice a little and i wrote this code so far:
stop();
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
var touchID:int = 0;
var posXonTouch:int = 0;
var posXmove:int = 0;
var TouchB:int = 0;
var RightShift:int = 0;
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
this.stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
function onTouchBegin (e:TouchEvent):void{
posXonTouch = e.stageX;
}
this.stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
function onTouchMove (e:TouchEvent):void{
posXmove = e.stageX;
if(posXmove > posXonTouch + 50) {
RightShift = posXmove - posXonTouch;
zom.nextFrame();
}
if(posXmove < posXonTouch + 50) {
RightShift = posXmove - posXonTouch;
zom.prevFrame();
}
touchID = e.touchPointID;
}
this.stage.addEventListener(Event.ENTER_FRAME , PlayPrev);
function PlayPrev(e:Event):void {
zom.prevFrame();
}
this.stage.addEventListener(TouchEvent.TOUCH_END, onTouchFinsh);
function onTouchFinsh (e:TouchEvent):void{
if(posXmove > posXonTouch + 50) {
PlayPrev(); <============== THIS IS LINE 56 *********************************
}
if(posXmove < posXonTouch + 50) {
}
}
i am getting an error saying:
Scene 1, Layer 'AS3', Frame 1, Line 56 | 1136: Incorrect number of arguments. Expected 1. |
i not fully understand why, if any1 could help.
thanks
Copy link to clipboard
Copied
When you defined the function PlayPrev() you set it to expect an enterFrame event. So when calling the function you will need to pass an event to it as an argument. PlayPrev() is set to be called at the movie's frame rate, so there's no real reason to call the function inside that onTouchFinish() function. Since the only thing that PlayPrev() does is "zoom.prevFrame()" you could just call that from within onTouchFinish().
Copy link to clipboard
Copied
In extend on Rob's suggestion.
I doubt you can instantiate interactive event like TouchEvent. So, your options are to either
1. make an argument optional: function PlayPrev(e:Event = null):void OR
2. pass null in cases this function is called not as a result of TouchEven: PlayPrev(null); OR
3. pass an event instance - because TouchEvent extends Event like so: PlayPrev(new Event());
Perhaps option 1 is the best for performance sake - this way you don't create unnecessary instances.
Unrelated suggestion - you should consider camel cases for your naming conventions. One of the reasons is that capital casing is reserved to Class names. Thus - code will be more readable with camel cases.
Copy link to clipboard
Copied
mmm i see, well there is somethings i need learn more about ac3 before i can go on i guess, it work little different then scripts i used to <:
thanks alot for take the time to explain it to me, really nice of you...