-
[RESOLVED] getting the mc from the library
the error
Code:
ArgumentError: Error #1063: Argument count mismatch on Pin$iinit(). Expected 0, got 2.
at Timeline0_7b8041c17f3c8a4aa76550e9fbfc4735/::frame1()
i can get the mc to the stage if i leave out the pX,pY parameters. However, i can not interact with the mc and the trace does not work. The mc in the library, has the class set to Pin. My Pin class (nested in com.website directories) looks like this
Code:
package com.website{
import flash.display.MovieClip
import flash.events.EventDispatcher
import flash.events.Event
class Pin extends MovieClip{
var mc:MovieClip
var pX:Number
var pY:Number
public function Pin(pX,pY){
this=mc
trace(mc)
mc.x=pX
mc.y=pY
mc.buttonMode=true
mc.addEventListener("mouseDown",mDown)
mc.addEventListener("mouseUp",mUp)
}
private function mDown(ev:Event){
mc.startDrag()
}
private function mUp(ev:Event){
mc.stopDrag()
}
}
}
in flash,
Code:
import com.website.Pin
var holder:Sprite= new Sprite();
holder.x=300
holder.y=300
this.addChild(holder)
var pin:Pin= new Pin(50,50)
holder.addChild(pin)
-
Senior Member
You have many mistakes in your script.
1. First of all, you should make it a rule to add a ;(semicolon) after each line of script.
2. In AS3 all classes, variables etc are by default private. You need to add "public" to the class declaration.
3. this=mc is wrong. It should be mc=this, since mc is so far not defined.
- The right of the People to create Flash movies shall not be infringed. -
-
thanks cancerinform..i know, the lacking ";" is such a bad/lazy habit. i'll work on that (it always comes back to me when working in PHP!). I went through, mades some changes (";" ,change the mc=this, and public calls). Still getting the same error.Hmmmmm
-
Senior Member
I did not use any holder as you did. Instead I put a class Holder as the Document class:
package {
import flash.display.MovieClip;
public class Holder extends MovieClip
{
public function Holder()
{
this.x=300;
this.y=300;
}
}
}
and in the fla I put:
var pin:Pin= new Pin(50,50);
this.addChild(pin);
That does not give any errors and does what it should do. I think the problem is holder in your movie. Also you don't have a real timeline. I strongly recommend to put an empty script as Document class to have a root. And also to extend it to MovieClip to be able to work with frames. There are other ways to do that but this is one way.
- The right of the People to create Flash movies shall not be infringed. -
-
cancerinform....i am so lame...in fact, the holder was not the issue. i had addressed the Class incorrectly in my linkage box (library). I had simply placed Pin...not com.website.Pin. I'm rolling now...thanks so much for your help though. I learned about all being private before public....and i will use semi-colons!!!
-
Senior Member
Uh, that was partly my fault, since I did not create folders.
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|