Error With Fuse Inside A Class
Hello, I have a class file "Slider.as" which I import the fuse classes into. When i publish my FLA, everything works, but if I try and check syntax in the class file itself, I get an error saying "There is no method with the name 'ZigoEngine'." I've tried putting things like "var ZigoEngine:Object;" at top to kill the errors...but then when I save and test the movie again, it doesn't work. Anyone? Is there a proper way to import the fuse class into another class? thanks in advance...
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 03-04-2007, 11:23 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
PLEASE HELP *Error Loading Fuse* ?
OK... Loosing it...
Please, can someone explain why I'm getting this error?
**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 9: The class 'Fuse' could not be loaded.
var f:Fuse = new Fuse();
I'm going through the video tutorial on "Advance Fuse Animation". I think the code is correct.. ?
Running MX04 on OSX...
Thanks
HERE iS the code:
___________
import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse,PennerEasing);
this.creatEmpyMovieClip("leader",1);
function moveLeader():Void
{
var f:Fuse = new Fuse();
f.push({target:leader, x:grp, y:grp, controlX:grp, controlY:grp, time:1, ease:"easeOutQuad"});
f.push({func:moveLeader});
f.start();
}
moveLeader();
function grp():Number
{
return Math.random()*600;
}
this.onEnterFrame = function()
{
var t:MovieClip = this.attachMovie("circle","c"+this.getNextHighestDepth(),this.getNextHighestDepth());
t._x = leader._x;
t._y = leader._y;
}
Fuse Class
I was wondering how you could use mosesSupposes fuse class to execute the commands simultaneously, not by line.
Code:
var x:Fuse = new Fuse();
x.push({target:nav5, rotation:0, size:140, alpha:20, x:postop+postop*0, y:100, time:0.5, ease:"easeOutExpo"});
x.push({target:nav2, rotation:0, size:140, alpha:20, x:postop+postop*1, y:100, time:0.5, ease:"easeOutExpo"});
x.push({target:nav3, rotation:0, size:140, alpha:20, x:postop+postop*2, y:100, time:0.5, ease:"easeOutExpo"});
x.push({target:nav6, rotation:0, size:140, alpha:20, x:postop+postop*3, y:100, time:0.5, ease:"easeOutExpo"});
x.push({target:nav4, rotation:0, size:140, alpha:20, x:postop+postop*4, y:100, time:0.5, ease:"easeOutExpo"});
x.start();
when x.start() is executed, the pushes are executed one by one, one after another finishes. how can u animate them simultaneously? Tnx
Fuse Used In Class?
Hey, I've tried searching around a bit, but haven't found anything.
Has anyone tried to incorporate the Fuse engine into a custom class? I've been trying to find an easy way to do it, but so far I've only come up with convoluted ways to access the Fuse functionality. Any ideas?
Slideshow With FUse / Error 'undefined'
Hi,
Am just starting to get into both Flash and Fuse and wanted to create a small slideshow... But when I run it in the output window I get 'undefinied' if anyone has any ideas would be much appreciated!
Code:
import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse, PennerEasing);
for (i=1;i<11;i++) {
var tmpClip:MovieClip = eval ("Pic" + i)
tmpClip.loadMovie("images/"+i+".jpg")
}
// Start the slideshow on a setInterval
var slideShowTimer:Number = setInterval(nextImage, 5000);
var counter:Number = 0;
// The workhorse function, gets called by setInterval, and should run every 5 seconds.
function nextImage():Void {
var img:MovieClip = images[counter % 3];
img.swapDepths(counter);
trace(img.getDepth());
img._alpha = 0;
img._visible = true;
img.alphaTo(100, 2, "easeOutSine", null, {func:cleanUpPrevious, args:[(counter-1) % 3]});
counter++;
}
// A function to be used in the tween callback to make the image that was just covered up invisible.
function cleanUpPrevious(image:Number):Void {
images[image]._visible = false;
}
// Show first image immediately.
nextImage();
Can't Use Fuse In My Custom Class?
a real quick question.
when i try to use Fuse class in my custom class. I check out the class, it says there's no error. but when i use the class in flash, I got this error message as below:
"ActionScript 2.0 class scripts may only define class or interface constructs"
is that true I can't use Fuse in my custom class?
thanks guys.
- mark
AS2 - Fuse In A Custom Class
I'm having difficulties figuring out how to use Fuse with functions and pointers I've created in a custom class. Right now, I'm just creating a simple slideshow between 3 movieclips. I'm getting errors back from fuse that it's "unable to parse callback" and "No targets found!". I have included "import com.mosesSupposes.fuse.*" in the class and have it registered on the first frame before the custom class is imported.
Here is the code (main.as)
Code:
import com.mosesSupposes.fuse.*;
class as.greenworks.main {
public var currentpic:Number = new Number();
public var nextpic:Number = new Number();
public var pictures:Array = [];
var slideshow:Number = new Number();
var slideshowDelay:Number = new Number(2000);
public function main(){
loadPictures();
initSlideshow();
}
public function loadPictures():Void {
pictures[0] = _root.loader_mc.attachMovie("pic1","pic1_mc",_root.loader_mc.getNextHighestDepth(),{_x:0, _y:0});
pictures[0]._alpha = 0;
pictures[1] = _root.loader_mc.attachMovie("pic2","pic2_mc",_root.loader_mc.getNextHighestDepth(),{_x:0, _y:0});
pictures[1]._alpha = 0;
pictures[2] = _root.loader_mc.attachMovie("pic3","pic3_mc",_root.loader_mc.getNextHighestDepth(),{_x:0, _y:0});
pictures[2]._alpha = 0;
}
public function initSlideshow():Void {
currentpic = pictures.length-1;
trace("[is] currentpic = " + currentpic);
pictures[currentpic]._alpha = 100;
slideshow = setInterval(nextPic,slideshowDelay,currentpic);
//clearInterval(slideshowDelay);
}
public function nextPic(currentpic:Number):Void {
nextpic = currentpic+1;
if(nextpic >= pictures.length) nextpic = 0;
trace("[np] currentpic = " + currentpic);
trace("[np] pictures[currentpic] = " + pictures[currentpic]);
var f:Fuse = new Fuse();
f.push({scope:this, func:"nextPicInitDepths"});
f.push({scope:this, target:pictures[currentpic], alpha:0, time:1, ease:"easeOutQuad"});
f.push({scope:this, target:pictures[nextpic], alpha:100, time:1, ease:"easeOutQuad"});
f.push({scope:this, func:"updateCurrentPic"});
f.start();
}
public function nextPicInitDepths():Void {
pictures[nextpic].swapDepths(_root.loader_mc.getNextHighestDepth());
pictures[currentpic].swapDepths(_root.loader_mc.getNextHighestDepth());
}
public function updateCurrentPic():Void {
pictures[currentpic].swapDepths(_root.loader_mc.getNextHighestDepth());
pictures[nextpic].swapDepths(_root.loader_mc.getNextHighestDepth());
currentpic++;
}
}
Fuse Not Making Callbacks In Class
Running into a real problem here. Wonder if it's because I need do use Delegate (which I have no experience with), because if I put a trace in the move function, it gets called again, but nothing animates :(
Please help!
Code:
import com.mosesSupposes.fuse.*;
class Floater2 extends MovieClip {
private var _me:MovieClip;
private var _ani:Fuse;
public function Floater2() {
ZigoEngine.register(Fuse, PennerEasing);
_me = this;
_ani = new Fuse();
move();
}
private function move():Void {
_ani.push({target: _me, x:grp, y:grp, controlX:grp, controlY:grp, time: 5, ease:"easeOutQuad"});
_ani.push({func: move});
_ani.start();
}
private function grp():Number {
return Math.random() * 600;
}
}
Can You Tween/fuse Abitmap Data Class Tile?
Hi!
I have watched Lee's bitmap data class tutorial (Full Browser Flash) and have created my own tiled background:
Code:
import flash.display.BitmapData;
var tile2:BitmapData = BitmapData.loadBitmap ("tile2");
function fillBG2() {
this.beginBitmapFill(tile2);
this.moveTo(0,245);
this.lineTo(Stage.width,245);
this.lineTo(Stage.width,439);
this.lineTo(0,439);
this.lineTo(0,245);
this.endFill();
}
fillBG2();
However, this just displays the tile when the frame is played. I would like to create a tween (preferrably fuse kit) to fade the tiled background over the old one... something like:
Code:
var f7:Fuse = new Fuse();
f7.push ({target:fill,start_alpha:0,alpha:100,seconds:1,ease:"easeOutQuad",func:afterFuse});
f7.start();
Is this possible? How do I stop the bitmap tile from appearing automatically and how do I assign it to a target for the fuse tween?
Please help!
Thanks, Matthew.
[F8] Referencing A Static Class Inside Another Class's Instance
I've got a movie loading into a framework.
This framework has 1 instance of the class main called main.
Inside this class, another class is used, but it is used directly, not as an instance. E.g.:
code:
import com.StaticClass;
class main {
private function UseStaticClass():void {
StaticClass.init();
}
}
From my movie, I can reference the main instance as _root.main. Can I reference StaticClass at all if there's no explicit instance created or it's not assigned to a public variable?
I can't modify main to include getter/setter methods, that's why I ask.
Thanks.
Instantiating Character Class Inside Of Game Class
I am having a problem instantiating a Character class inside of a game class.
P.S. I am working on converting http://oos.moxiecode.com/tut_01/index.html these tutorials to A.S. 2.0.
Game:
ActionScript Code:
if ( i == charPos[1] && j == charPos[0] ) {
var char:Character = new Character();
char._x = (j*tileWidth)+tileWidth/2;
char._y = (i*tileHeight)+tileHeight/2;
}
Character:
ActionScript Code:
class classes.Character extends MovieClip {
function Character() {
var h = createEmptyMovieClip("holder", getNextHighestDepth());
var char = h.attachMovieClip("char", "char", getNextHighestDepth());
trace("new character created");
}
}
**Error** ActionScript 2.0 Class Scripts May Only Define Class........
**Error** ActionScript 2.0 class scripts may only define class or interface constructs.
b2.onPress = function() {
**Error** ActionScript 2.0 class scripts may only define class or interface constructs.
b3.onPress = function() {
**Error** ActionScript 2.0 class scripts may only define class or interface constructs.
b4.onPress = function() {
ok this is what i have.
1 Movie clip with links to a .as file all is working fine the above error occurs when i publish the 1 movie clip which is getting pulled into the main movie
Any idea's it does not happen when 1 movie clip is published on its own just when 1 move clip is pulled into my main movie clip.
Can I Get The MouseX From One Class's Stage From Inside A Different Class?
I'm working on a first time game using Flash CS3 ActionsScript 3.0 that has a crow class placed on the stage of a main gameStage class. I need to access the mouseX coordinate from the stage of the gameStage class from inside my crow class. I'm attempting to do it via a getter function but seem to be having trouble tracking down the exact proper syntax to avoid errors. Is there any chance I could get an exact syntax example as apposed to hours of online research and study.................8-)
Call Class Method Inside Another Class.
Hello, I have one class that creates another object from another custom class. Then it calls a method from the newly created class. I want this class to then call a parent's method after it's completed.
Something like this:
PHP Code:
//First Class
class FirstClass{
function FirstClass(){
var newClass:SecondClass = new SecondClass();
newClass.doSometing();
}
public function doSomethingAfter():Void{
// Do this after newClass.doSomethign is done
}
}
// Second Class
class SecondClass{
private var _mc:MovieClip;
private var _incrVar:Number;
function SecondClass(){
_mc = _root.createEmptyMovieClip(...);
_incVar = 0;
}
public function doSomthing():Void{
_mc.onEnterFrame = function():Void{
_incVar++;
if(_incVar > 10){
delete this.onEnterFrame;
// This is where I would now like to call
// a method of First Class.. but How?
}
}
}
}
I know that I could pass the FirstClass object as a parameter to the SecondClass's doSomething function.. but I was wondering if there was another easier way I do not know about to call the parent or calling classes methods. Or maybe there is a way for FirstClass to detect when SecondClass is finished with what it must do before moving on without having to have SecondClass call a FirstClass method?
Thanks!
Instance Of Class Inside Of Different Class
I am trying to make an instance of a class inside of a different class. But I am getting an error:
**Error** C:Documents and SettingsOwnerDesktopSlideshowsFlashReminderE vent.as: Line 8: A class's instance variables may only be initialized to compile-time constant expressions.
var s1:Step = new Step();
**Error** C:Documents and SettingsOwnerDesktopSlideshowsFlashReminderE vent.as: Line 9: A class's instance variables may only be initialized to compile-time constant expressions.
var s2:Step = new Step();
**Error** C:Documents and SettingsOwnerDesktopSlideshowsFlashReminderE vent.as: Line 10: A class's instance variables may only be initialized to compile-time constant expressions.
var s3:Step = new Step();
**Error** C:Documents and SettingsOwnerDesktopSlideshowsFlashReminderE vent.as: Line 11: A class's instance variables may only be initialized to compile-time constant expressions.
var s4:Step = new Step();
**Error** C:Documents and SettingsOwnerDesktopSlideshowsFlashReminderE vent.as: Line 12: A class's instance variables may only be initialized to compile-time constant expressions.
var s5:Step = new Step();
**Error** C:Documents and SettingsOwnerDesktopSlideshowsFlashReminderE vent.as: Line 13: A class's instance variables may only be initialized to compile-time constant expressions.
var s6:Step = new Step();
The code for the first class is:
code:
class Event {
var type:String = new String();
var oName:String = new String();
var description:String = new String();
var steps:Number = new Number();
var dueDate:String = new String();
var percent:Number;
var s1:Step = new Step();
var s2:Step = new Step();
var s3:Step = new Step();
var s4:Step = new Step();
var s5:Step = new Step();
var s6:Step = new Step();
function createNewEvent(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11) {
type = d1;
oName = d2;
description = d3;
steps = d4;
dueDate = d5;
percent = 0;
if (steps == 6) {
s1.createNewStep(d6);
s2.createNewStep(d7);
s3.createNewStep(d8);
s4.createNewStep(d9);
s5.createNewStep(d10);
s6.createNewStep(d11);
} else if (steps == 5) {
s1.createNewStep(d6);
s2.createNewStep(d7);
s3.createNewStep(d8);
s4.createNewStep(d9);
s5.createNewStep(d10);
} else if (steps == 4) {
s1.createNewStep(d6);
s2.createNewStep(d7);
s3.createNewStep(d8);
s4.createNewStep(d9);
} else if (steps == 3) {
s1.createNewStep(d6);
s2.createNewStep(d7);
} else if (steps == 2) {
s1.createNewStep(d6);
s2.createNewStep(d7);
} else if (steps == 1) {
s1.createNewStep(d6);
}
}
function showPercent() {
for (var p = 1; p<=steps; p++) {
percent += this["s"+p+""].percent;
}
percent /= steps;
return percent;
}
function done(stepN) {
this["s"+stepN+""].done();
}
function setStepPercent(stepN, p) {
this["s"+stepN+""].setPercent(p);
}
}
The class being loaded is:
code:
class Step{
var completed:Boolean = new Boolean();
var sName:String = new String();
var percent:Number = new Number();
function createNewStep(d1){
completed = false;
sName = d1;
percent = 0;
}
function setPercent(tbs){
percent = tbs;
}
function done(){
completed = true;
percent = 100;
}
}
Please help!!!
Button Inside Movieclip Error
Hi i have designed a site where the user can move elements around the stage, and within some of these elements(movieclips) there are buttons insde them that link to various frame labels that are located on the main movieclips time line. The action to control the button is on the main movieclip time line and not within the element itself. These code used is:
Code:
paper2.webBttn.addEventListener(MouseEvent.CLICK, webButton);
function webButton(e:MouseEvent):void
{
gotoAndPlay("web");
}
the error i keep getting is:
Code:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/setChildIndex()
at FlashAS3Portfolio2_fla::holder_14/doDrag()
Button Inside Movieclip Error
Hi i have designed a site where the user can move elements around the stage, and within some of these elements(movieclips) there are buttons insde them that link to various frame labels that are located on the main movieclips time line. The action to control the button is on the main movieclip time line and not within the element itself. These code used is:
Code:
paper2.webBttn.addEventListener(MouseEvent.CLICK, webButton);
function webButton(e:MouseEvent):void
{
gotoAndPlay("web");
}
the error i keep getting is:
Code:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/setChildIndex()
at FlashAS3Portfolio2_fla::holder_14/doDrag()
Inside Class
i am creating my own component. in the Class of the component how can i access the
movieClips i am creating at runtime. inorder to access these movieClips i have to
follow the syntax
_root.myComponentName.myMovieClip
how can i avoid the name of the component in the class file.
Faraz
Inside Class
i am creating my own component. in the Class of the component how can i access the
movieClips i am creating at runtime. inorder to access these movieClips i have to
follow the syntax
_root.myComponentName.myMovieClip
how can i avoid the name of the component in the class file.
Faraz
[F8] NAN Error In Class
here on key UP/DOWN i get cIndex = NaN
why?? it's used as number everywhere
please help...
instance of this is created by attachMovie
because this class is linked with movieClip symbol in library
class CViewMENU extends MovieClip{
var cIndex:Number = 0;
var keyList:Object = null;
var this_mc:MovieClip = null;
//--------------------------------------------
function CViewMENU(){
trace("CViewMENU constructor");
this_mc = this;
setActive();
}
//----------------------------------------------------------
function setActive(){
trace("CViewMENU.setActive");
keyList = new Object();
keyList.onKeyDown = fOnKeyDown;
Key.addListener(keyList);
}
//----------------------------------------------------------
function setInactive(){
trace("CViewMENU.setInactive");
Key.removeListener(keyList);
}
//----------------------------------------------------------
function fOnKeyDown(){
trace("CViewMENU.onKeyDown");
switch(Key.getCode()) {
case Key.UP :
trace("onKeyDown UP");
cIndex--;
break;
case Key.DOWN :
trace("onKeyDown DOWN");
cIndex++;
break;
}
trace("cIndex = "+ Number(cIndex));
}
//----------------------------------------------------------------------
}
NAN Error In Class
here on key UP/DOWN i get cIndex = NaN
why?? it's used as number everywhere
please help...
instance of this is created by attachMovie
because this class is linked with movieClip symbol in library
class CViewMENU extends MovieClip{
var cIndex:Number = 0;
var keyList:Object = null;
var this_mc:MovieClip = null;
//--------------------------------------------
function CViewMENU(){
trace("CViewMENU constructor");
this_mc = this;
setActive();
}
//----------------------------------------------------------
function setActive(){
trace("CViewMENU.setActive");
keyList = new Object();
keyList.onKeyDown = fOnKeyDown;
Key.addListener(keyList);
}
//----------------------------------------------------------
function setInactive(){
trace("CViewMENU.setInactive");
Key.removeListener(keyList);
}
//----------------------------------------------------------
function fOnKeyDown(){
trace("CViewMENU.onKeyDown");
switch(Key.getCode()) {
case Key.UP :
trace("onKeyDown UP");
cIndex--;
break;
case Key.DOWN :
trace("onKeyDown DOWN");
cIndex++;
break;
}
trace("cIndex = "+ Number(cIndex));
}
//----------------------------------------------------------------------
}
Class Error
Hey. I am creating a simple game for school using flash. I am trying out classes since I haven't done them in flash yet. I'm getting this error:
Code:
**Error** Scene=Scene 1, layer=Actionscript, frame=1:Line 1: Classes may only be defined in external ActionScript 2.0 class scripts.
class Player
Total ActionScript Errors: 1 Reported Errors: 1
With this code:
Code:
class Player
{
// data members
var pos_x:Number;
var pos_y:Number;
var sprite_size_x:Number;
var sprite_size_y:Number;
var nam:String;
var hp:Number;
var str:Number;
// member functions
function walk(direction:Number)
{
switch(direction)
{
// up
case 0:
{
if((pos_y - 1) >= 0)
pos_y -= 1;
else
pos_y = 0;
}
// down
case 1:
{
if((pos_y + 1) < 500)
pos_y += 1;
else
pos_y = 500;
}
// left
case 2:
{
if((pos_x - 1) >= 0)
pos_x -= 1;
else
pos_x = 0;
}
// right
case 3:
{
if((pos_x + 1) < 500)
pos_x += 1;
else
pos_x = 500;
}
}
}
}
So how and where does this "external script" go? (This code is on it's own layer in frame 1).
How To Fix This AS2 Error (class Already In Use)
Does anyone has a clue on how to fix the AS2 class error that says the name of the class is in use?
Quote:
**Error** Z:CarinhosoFLApicMotions.as: Line 4: The name of this class, 'picMotions', conflicts with the name of another class that was loaded, 'picMotions'.
{
Total ActionScript Errors: 1 Reported Errors: 1
Also, I have a code like this...
PHP Code:
var aaa:picMotion = new picMotion(img, "foto2", 5);
When I update the class with and error on porpouse it doesnt tell me anything... it keeps using the "old class build" that works and does not update it...
Flash MX2004 was all good, im having !¨%@¨%# nightmares with this problema in Flash 8, anyone else here?
AS 2.0: Class Error
Hi. This is my class definition:
Code:
import flash.xml.XMLDocument;
class mngXML {
var xmlHandle:Object;
var myXML:XML;
var count;
function mngXML() {
trace('constructor');
this.myXML = new XML();
this.myXML.ignoreWhite = true;
//this.myXML.onLoad = loadData();
}
private function loadData(loaded) {
trace('load data');
if (loaded) {
trace('ok');
this.xmlHandle = this.myXML.firstChild;
this.count = this.myXML.childNodes.length;
}
else {
trace('shhhh');
}
}
public function loadFile(filename:String,count) {
this.myXML.onLoad = loadData();
trace('load file');
this.myXML.load(filename);
}
}
in 1st frame i have:
Code:
var manager:mngXML = new mngXML();
manager.loadFile("file.xml",2);
can anybody tell me what I'm doing wrong?
Help With AS2.0 Class Error In Fl8
I have spent the better part of the day writing a script that implements the new static Zigo Engine and MosesSupposes Fuses and I get almost completely finished when I get the weirdest error suddenly:
**Error** P:Web ProjectsinProgresssectionButton.as: Type mismatch.
No line number or anything. Any Suggestions? I'll post my code if need be (and risk being harrassed to death for my inept coding skills), but I was hoping that someone else had experienced this rather obtuse error and could tell me how to fix it easily.
Oh, and btw, I've tried the ASO cache clearing thing and rebooting and it didn't help.
Thanks in advance for your support,
best wishes,
jase
Class Error
G'day
I am attempting to use Lee's reflection, read the forum pages but still can't get it to work. I put the folder com in the en/first run/classes in the c-program/flash8 folder. Did not work. syntax error.
Made sure export flash8, action script 2. Went to preferences and showed it the path. Did not work.
Then put the com folder in the same folder as the fla still did not work the last error was
**Error** C:Documents and SettingsStephenMy Documentslees_reflectioncomleebrimelowutilsReflection.as: Line 1: Syntax error.
Code:
Total ActionScript Errors: 1 Reported Errors: 1
What am I doing wrong? The lees_reflection is the folder I have the fla and com folder in.
Thaks
easy
Variables On The Fly Inside A Class-how
If we need to declare all variables in a class like
var aR:Array;
for example , then how can i avoid the error message created when i try to dynamicly create a variable within that class...
this["c"+i]=i;
trace(this.c1);
error is that c1 has not been declared. This is very helpful to create these properties within the object then i can delete them later, i dont want to create a variable on the root.
thanks
mojito
Variables Inside Class
hi,
i am creating my own component. the problem is how can i access the variables inside the Class without using _root.myComponentName.variableName.
check out the code.
class Loader extends MovieClip {
private var __maskHeight:Number = 450;
Loader(){
//create some movieClip here
movieClip.onLoad = function():Void{
//how can i access the __maskHeight variable here
//when i trace it, it shows me undefined
}
}
}
Faraz
Scope Inside A Class AGAIN
Code:
private function mServerValidate() {
var xmlOUT:XML = new XML(schema00);
var xmlRTN:XML = new XML();
xmlRTN.ignoreWhite = true;
xmlRTN.onLoad = myOnLoad;
xmlOUT.sendAndLoad(this.path, xmlRTN);
//xmlOUT.sendAndLoad = Delegate.create(this, myOnLoad);
function myOnLoad(success:Boolean) {
var xmlpath = "/server/body";
var aTempXML = mx.xpath.XPathAPI.selectNodeList(this.firstChild, xmlpath);
trace(aTempXML[0].firstChild.attributes.success);
if (success) {
if (String(aTempXML[0].firstChild.attributes.success) == "1") {
trace("good login"+this);
//cant see this !!!!
im loosing scope after the "if (success) { " bit if i use delegate i cant pass the attributes i think.
??also can send it a ref to where it currently is..
Help With Using The MovieClipLoader Inside A Class
Any ideas why the following code is not returning the
height and width of the image when it is loaded?
ActionScript Code:
class imageLoader extends MovieClip {
var mclListener:Object;
var picHolder:MovieClip;
var frameHolder:MovieClip;
var picWidth:Number;
var picHeight:Number;
var image_mcl:MovieClipLoader;
function imageLoader() {
image_mcl=new MovieClipLoader();
picHolder=this.createEmptyMovieClip("picture",this.getNextHighestDepth());
trace(picHolder);
mclListener.onLoadInit = init(picHolder);
image_mcl.addListener(mclListener);
image_mcl.loadClip("1.jpg", picHolder);
}
function init(mc:MovieClip){
trace("clip has finished loading");
picWidth = mc._width;
picHeight = mc._height;
trace(picWidth+" "+picHeight);
}
}
thanks
OnEnterFrame Inside A Class
I don't have a problem as much as just a lack of understanding:
Question: Will I run into any problems using onEnterFrame inside a class? I know that onEnterFrame events can overwrite each other if they are written dynamically, but I'm not sure how this effects classes...
Also, onEnterFrame is an event of the movie clip class right? ...does that even matter...? What happens if I declare an onEnterFrame event inside a method inside my class: will it even work? will it effect the movie clip from which the class.method is being called?
Sigh... Hopefully you get the idea of what I'm having trouble grasping. Please explain any concepts you think I appear to be missing. I'm new to classes - thanks for your help.
Problem With XML Inside A Class
OK. This is a setter function in one of my classes. It's supposed to load an xml document into an array when i call it with the address of the xml document. When I debug i see the array but there's no data in it.
I'm pretty sure i'm doing something just really dumb that's probably really easy to spot... sorry - i'm new to this!
Thanks so much!
(i've included the code, and the xml file under the code so you can see what I'm aiming at...)
Attach Code
========================setter function in class=======================
public function set xmlVideoList(sXML:String):Void {
//set up the xml data
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
//load xml data into _aVideoList
xmlData.onLoad = function(bSuccess:Boolean):Void {
var xnVideo:XMLNode = this.firstChild.firstChild;
while(xnVideo.nodeName != undefined) {
var oVideo:Object = xnVideo.attributes;
oVideo.description = xnVideo.firstChild.nodeValue;
_aVideoList.push(oVideo);
xnVideo = xnVideo.nextSibling;
trace(oVideo.toString());
}
}
xmlData.load(sXML);
}
============================== xml file ===============================
<data>
<video
path="couch_400.flv"
title="the couch"
>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.................</video>
<video
path="promo_400.flv"
title="promo video"
>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.................</video>
<video
path="distracted_400.flv"
title="distracted"
>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.................</video>
</data>
Using HitTest Inside A Class
Could someone please point me in the right direction here?
I have a class that I want to use to instantiate 'hit-able' movieclips on the screen. I want to create them on the fly. I want to have these 'widgets' watch for a hit of another object that is 'fired' from another object. I can't figure out a way to have the 'widget' watch for the fired object? I'd like to pass the hit object at the time I create the 'widget'. I have tried a few different ways to pass the 'hitObject' (below) but I can't seem to figure out a way to do that. the code below is an example of what I want to do but obviously the 'hitObject' in the function watchForHit is not passed. Is there a way I can pass it at the time I create the widget?
QUESTION #2...What if you don't know the name of the object that is going to hit? Is there a way to test what object has hit my listening object if I don't know what object I'm listening for That way I could just listen to see if anything has hit. THANKS!
public class widget extends MovieClip{
public var counter:int;
public function widget(){
counter = 0;
This.addEventListener(Event.ENTER_FRAME, watchForHit);
}
private watchForHit(event:Event):void {
if(this.hitTest(hitObject)) this.counter++;
}
}
LoadVars Inside Class - How?
How can I use LoadVars inside a class?
I mean, if I assign the method name to onLoad of LoadVars, the method will be override, and will not pertence to my class.
look this:
ActionScript Code:
class myClass{var lv:LoadVars;function myClass(){lv = new LoadVars();lv.onLoad = onLoad;}function onLoad(sucess:Boolean):Void{trace(this);}function trigger(){lv.sendAndLoad("testeURL",lv,"POST");}}
this at onLoad function points to loadVars not to myClass.
the only solution I found to this was to myClass extends LoadVars, but it limit me since AS 2 does not support multiple-Inheritance.
I think I will face the same problem with all others components that does not has addEventListener capabilitie.
Getting XML Content Inside A Class
Take a look at these example:
ActionScript Code:
function loadMap():Void { var xdata:XML = new XML(); xdata.ignoreWhite = true; xdata.load(this.source_map); var var_temp:String; xdata.onLoad = function(success:Boolean) { if(success) { var_temp = xdata.firstChild; } else { trace("Cannot load xml file = " + this.source_map); } } }
Now, im creating a local variable var var_temp:String; cause, there is no way that i can pass the values, inside the onLoad handler to a property of the class.
If i try some this.some_var its reference to escope inside the onLoad handler...
Any solution to get the values to a class property?
Variables Inside Class
hi,
i am creating my own component. the problem is how can i access the variables inside the Class without using _root.myComponentName.variableName.
check out the code.
class Loader extends MovieClip {
private var __maskHeight:Number = 450;
Loader(){
//create some movieClip here
movieClip.onLoad = function():Void{
//how can i access the __maskHeight variable here
//when i trace it, it shows me undefined
}
}
}
Faraz
Key Events Inside AS 2.0 Class
I am curious in what strategies people are using (if they are using) the Key events inside of their classes. I am trying to build up a character class and I wanted to encapsulate the movement inside of the class.
LoadVars Inside Class - How?
How can I use LoadVars inside a class?
I mean, if I assign the method name to onLoad of LoadVars, the method will be override, and will not pertence to my class.
look this:
ActionScript Code:
class myClass{var lv:LoadVars;function myClass(){lv = new LoadVars();lv.onLoad = onLoad;}function onLoad(sucess:Boolean):Void{trace(this);}function trigger(){lv.sendAndLoad("testeURL",lv,"POST");}}
this at onLoad function points to loadVars not to myClass.
the only solution I found to this was to myClass extends LoadVars, but it limit me since AS 2 does not support multiple-Inheritance.
I think I will face the same problem with all others components that does not has addEventListener capabilitie.
SetInterval Inside AS2 Class
hi
I'm trying to use a setInterval inside an AS2 class, but curiously, when inside the called function "this" is undefined.
Here's an excerpt of what I'm using, when testing this, "this" is resolved to undefined. Anything special with setInterval inside a class ? The interval itself works, cause the trace is there, but prints "undefined"...
Code:
class Blip extends MovieClip {
private var trackerID:Number;
public function drawBlip() {
(...)
this.trackerID = setInterval(realMove, 2);
}
private function realMove() {
trace("this:"+this);
}
}
OnMotionFinshed Inside Class
I am trying to call a function after a onMotionFinished, but it wont work because the script is embedded in a class. My code is:
ActionScript Code:
var Tween1:Object = new Tween(mask, "_y", Regular.easeInOut, mask._y, 200, .5, true);
Tween1.onMotionFinished = function() {
_parent.loadTopic("home");
};
This works fine embedded in an mc.
When I run a trace(this) inside the onMotionFinish, it returns [Tween].
How do i get it to return a path out of the object?
thx
Reference Inside Class
Hello,
I posted this subject in other section because I didn't see this section dedicated to actionscript. Sorry.
Hope this time to be more lucky in help.
I'd like to have an indication on referencing variable or function.
I post this piece of code:
class myclass {
private var myXML:XML;
private var myObj:Object;
function myclass() {
//constructor
myObj=new Object();
myObj.IDClient=29;
trace(myObj); //This works!
myXML=new XML();
myXML.load("DataPath.xml");
myXML.onLoad=function(success) {
--> trace(myObj);
--> trace(this.myObj);
}
}
}
From inside the event, I can't reference any variable or function inside the class but outside the event. The 2 traces always says undefinied.
Can anyone suggest me a solution?
Very Thanks, Dario.
Using CreateEmptyMovieClip Inside Of A Class
ok I am trying to create a movie clip from with in my class. But I keep getting an error:
There is no method with the name 'createEmptyMovieClip'.
var thumb:MovieClip = this.createEmptyMovieClip("thumb", this.getNextHighestDepth());
can I not create a movieclip from within the class or is there a special syntax or target path that needs to be used?
Using Listeners From Inside A Class
Hey Guys. I am pretty new to using classes and ran into this issue. I have a class that needs to add mouse events to specific movie clips. I am not getting any error however no action seems to take place. If anyone has any thoughts to why this may be or what I am doing wrong please point me in the right direction. Thank you!!
this is the code for my class, it is given the movieclip name in the first parameter. Changing the alpha for it works fine so "mystmcname" seems to be refrencing the movieclip correctly, I am just not sure if I am able to have the listener function within this class. I tried it a few ways from the main document class as well but could not get it.
Code:
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class states extends Sprite {
public function states(mystmcname:MovieClip,stabbrev:String, stname:String,stscalenum:int, stmapx:int, stmapy:int, stavailable:int) {
if (stavailable==0) {
mystmcname.alpha=.65;
}
mystmcname.buttonMode=true;
mystmcname.useHandCursor=true;
mystmcname.addEventListener(MouseEvent.CLICK, mouseclick);
function mouseclick(e:MouseEvent):void {
trace("over");
}
trace(stabbrev);
}
}
}
Handling A MC Inside A Class
I'm learning ActionScript. I've ran into a couple of problems that I can't seem to solve. I'm hoping you guys can help me.
I have a class that has a movieclip as a member. The movie clip is created in the constructor of the class. It looks something like this:
PHP Code:
class MyClass
{
private var mc:MovieClip;
function MyClass(image)
{
_mc = _root.createEmptyMovieClip("foo_mc",_root.getNextHighestDepth());
_mc.loadMovie(image);
/*
// commented out because it doesn't work
_mc.onMouseDown = function()
{
trace("_mc.onMouseDown is good.");
}
_mc._visible = false;
*/
_mc._alpha = 0; // since visible doesn't work, I have to use this.
}
// move the clip around
function translate():Void
{
_mc._x += 5; // this doesn't work either.
}
}
PHP Code:
// Example of usage. This is located in the first frame
// of the timeline. The timeline is one frame long.
myMC = new MyClass("./test.jpg");
_root.onEnterFrame = function()
{
trace("Working...");
myMC.translate(); // doesnt' do anything.
}
My problems are:
1) I don't know how to override the mc's handlers, such as "onMouseDown" or "onPress".
2) Why doesn't mc._visible = false works? I saw the documentation and according to it this should work.
3) The translate() function doesn't work. Why not?
Thanks
Class Naming Get Me An Error
hi,
i want to call my class "CompName.Components.TextFeeder",
but in my movie, when i do -
Code:
var t:TextFeeder = new TextFeeder();
i get this error -
The class 'Ts.Components.TextFeeder' needs to be defined in a file whose relative path is 'TsComponentsTextFeeder.as'.
why is that
Avi.
Weird Class Error.
I've got some code in a file called kitchenVideo.as.
The code starts as follows:code: function initialisation()
{
kitchenVideo = "kitchenVideo.flv";
...
...
There are a few insignificant lines aboe the kitchenVideo = ... line...
And there are other bits of code below.
The compiler just throws an error saying something about AS2 classes.
But... after much time and damn effort...
I've tracked down the problem to this line.
I've read Penner's book. I can't remember, but I think he mentions something about a class referencing itself or something by calling it's own name??
I've got Moock's AS2 book... just starting to read...
The problem is that even if the line kitchenVideo = ... isn't the same as the file name, it still throws an error. It's only when I call the variable a completely non related name does it stop throwing an error.
WHAT'S HAPPENING!?
Thanks.
OM
|