Copy link to clipboard
Copied
Hi,
This is my first attempt with AS3...now I am well aware of OOPs concepts and am comfortable with programming, but I am not able to wrap my head around the whole connecting the classes to the display objects on screen thing [linkages and class names n all]..now I managed to fix most errors in my file, which has cbIntro as the base class [set up successfully]...now cbIntro extends MovieClip as it links to an external fla [cbFlash]...but within cbFLash I am calling the following...
import CBClasses.cbIntro;
var flipped:Boolean = false;
var jobs:jobsBtn_mc = new jobsBtn_mc(); //not a button a movieclip within the library
var flip:cbIntro;
function callFlip(e:MouseEvent):void
{
trace("in call flip");
if (!flipped)
{
//some button code
flip = new cbIntro(evnts, jobs, 2, "left", true); //evnts is a mc on stage
addChild(flip);
flipped = true;
}
else if (flipped)
{
flip = new cbIntro(jobs, evnts, 2, "right", true);
addChild(flip);
flipped = false;
evnts.nxt.visible = true;
}
}
evnts.nxt.addEventListener(MouseEvent.MOUSE_DOWN, callFlip); //Adds the listeners to the buttons
jobs.bck.addEventListener(MouseEvent.MOUSE_DOWN, callFlip);
cbIntro has one constructor which takes 5 parameters, defined within a separate .as file.....now I am getting an error
Error #1063: Argument count mismatch on CBClasses::cbIntro(). Expected 5, got 0
How can this happen, the only time an object is created, I am sending the right number of parameters...?? declaring a cbIntro variable should not call the constructor....?? Is that what is happening?? Or am I missing something important????
There may be more wrong with the code, but for starters, if you have an object on the stage that you assigned an instance name of eventsmc, then you cannot declare a variable with that same name. Also, since you declare the vanish function as private, you cannot have anything outside of the class attempt to use it, so you need to either make it public or have some other public function within the class file that calls it.
You appear to have posted regarding two entirely unrelated attempts at cod
...Copy link to clipboard
Copied
Ok, I tried to gather my bearings a little with AS3..and tried out a trial class....ALL that the class does is create an object of the external class, and then call a function which displays the alpha value of a movieclip passed to it. The movieclip is on the stage of the swf file.
Code in swf:
var iMain:introMain = new introMain();
var isVanished:Boolean = false;
var eventsmc:MovieClip;
function callVanish(e:MouseEvent):void {
trace("inside callVanish");
iMain.vanish(eventsmc);
isVanished = true;
}
eventsmc.nxt.addEventListener(MouseEvent.MOUSE_DOWN, callVanish);
code within introMain class:
package {
import flash.display.*; //all this for later
import fl.transitions.easing.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import flash.events.MouseEvent;
public class introMain extends MovieClip{
public function introMain(){
trace("inside intromain constructor");
}
private function vanish(mcName:MovieClip):void{
trace("inside vanish " + mcName.alpha);
}
}
}
The error I am getting
: Error #2136: The SWF file path/introduction.swf contains invalid data.
at introMain/frame1()
why is this happening?????
Copy link to clipboard
Copied
There may be more wrong with the code, but for starters, if you have an object on the stage that you assigned an instance name of eventsmc, then you cannot declare a variable with that same name. Also, since you declare the vanish function as private, you cannot have anything outside of the class attempt to use it, so you need to either make it public or have some other public function within the class file that calls it.
You appear to have posted regarding two entirely unrelated attempts at coding. You do everyone a favor if you keep different topics in different postings.
Copy link to clipboard
Copied
Hi Ned,
Sorry about posting two different topics thing...I was just trying to figure out the first problem by creating a stripped down version of the sending an on stage movieclip to an external class thing. I don't know how I can break up this post now...but since you have mentioned a few points...the problem is not with the private function declaration..you are correct of course..and that error was fixed..but I am still getting the error....
inside intromain constructor
Error: Error #2136: The SWF file file:///E|/Adobe/Flash%20CS5/Projects/trial/introduction.swf contains invalid data.
at introMain/frame1()
the introMain class only contains a constructor and a vanish function, which only shows a trace. I removed the problem with the on stage instance name, and tried to access it directly...but I don't think the code is even getting to that point...or may be it is...I am at a loss here...
Code within introduction.swf
var iMain:introMain = new introMain();
var isVanished:Boolean = false;
trace("events alpha" + eventsmc.alpha);
I am not even calling the vanish function anymore...is something wrong with the constructor call???
Code within introMain
package {
import flash.display.*;
import fl.transitions.easing.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import flash.events.MouseEvent;
public class introMain extends MovieClip{
public function introMain(){
trace("inside intromain constructor");
}
public function vanish(mcName:MovieClip):void{
trace("inside vanish");
}
}
}
Copy link to clipboard
Copied
Who is introduction.swf? What you might try is to create an entirely new file (not the as file) , only for the sake of making sure you are not dealing with a corrupted file.