logo       

Extending SWFButton: msg#00019

web.ming.general

Subject: Extending SWFButton

Hi all-


I have a feeling something like this came up before, apologies if so, but I
can't find anything in the archives so...

The question is: why can't I successfully add a function to a class which
inherits from SWFButton (or indeed SWFMovie, SWFSprite etc)?

For example, this works nicely:

<?php

class ParentClass {
function ParentClass()
{
echo "creating ParentClass<br />";
}
}

class ChildClass extends ParentClass {
function newfunc()
{
echo "in newfunc<br />";
}
}

$cc = new ChildClass();
$cc->newfunc();

?>

produces the expected output:

creating ParentClass
in newfunc

and yet, if ChildClass extends SWFButton, I discover:

Fatal error: Call to undefined function: newfunc() in /path/to/script.php etc

Maybe it's my understanding of OO principles which is lacking, but I never came
across this before. Any ideas?

I've made that example as short as possible, but I also get exactly the same
whether or not I create a constructor for ChildClass and call
$this->SWFButton() within it. So if I would have:

<?php

class ChildClass extends SWFButton{

function ChildClass()
{
$this->SWFButton(); // or $this = new SWFButton();
//optional other stuff
}
function newfunc()
{
echo "in newfunc<br />";
}
}

$cc = new ChildClass();
$cc->newfunc();

?>

This throws exactly the same fatal error. Again, I switch it back to extend
from ParentClass and all works fine.


Cheers for any help guys,
Simon


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise