HTML5 Canvas: Calling a parent function

Hey guys
I'm currently banging my head against a brick wall trying to call a parent function with the HTML5 Canvas.
I have the following code on the stage:
function fromStage()
  console.log("This is on the stage");
fromStage();
This correctly outputs that message to the console in the browser.
However, I have a button within a movie clip that I want to call this function from, my code in that movie clip is as follows:
this.theButton.addEventListener("click", fl_MouseClickHandler.bind(this));
this.theButton.name = "theButton";
function fl_MouseClickHandler(e)
  this.parent.fromStage();
However, this doesn't appear to be working, any ideas?
Thanks

use:
on the stage:
this.fromStage=function()
  console.log("This is on the stage");
this.fromStage();
code in that movie clip is as follows:
this.theButton.addEventListener("click", fl_MouseClickHandler.bind(this));
this.theButton.name = "theButton";
function fl_MouseClickHandler(e)
  this.parent.fromStage();

Similar Messages

  • Calling a parent function when child .swf closes

    I am adding a child .swf from the parent with a simple button. If this button is then clicked multiple times, the child is added multiple times. So I added the ".visible = false"  to the button when clicked so the button cannot be clicked while the child is open.
    Now, there is "Close" button on the child .swf that uses "this.parent.parent.removeChild(this.parent);" and would now need to set the parent button back to ".visible = true".
    I have tried MovieClip.parent.parent.resetButton();  and  parent as MovieClip.resetButton(); and many variations of the code. I get no errors but the code doesn't work either.
    Any ideas?
    Thank you.

    Figured this out on my own (don't believe it) without the child/parent communication.
    When the parent's button is clicked, I'm checking to see if the child already exists. If so, it won't create the child again.
    I'd still like to know how to perform the communication between child and parent.

  • IFRAME in portlet question - possible to call parent function from iframe?

    From the iframe I tried to call the parent function by doing this parent.myFunc(). I got a permission denied javascript message. Just curious if anyone has successfully done this. If so please share your thoughts and comments.

    Hi,
    You will get "Persmission denied" error due to cross site scripting. Either you need to change browser settings to allow cross site scripting or you need to make sure both the URLs fall under same parent domain like both URLs ending with "*.abc.com".
    Thanks

  • Parent function calling a child function with arguments

    Can anyone give examples of a parent function which has at least 1 parameter, and is invoked from the Form Behavior, which in turn , depending on data, invokes 2 or more child functions passing to these functions the same parameter that was passed in to it.
    I am getting 'Object required' and do not know what I am doing wrong. Please let me know if you've done it, and how you've referenced it , if they are BOTH functions. Thank you!

    The best way to do this is probably using delegates, but to do it directly you have to solve the circular dependency problem (as you have discovered). See
    http://en.wikipedia.org/wiki/Circular_dependency
    In case it is not clear to you how the Wikipedia article relates to your case, your files should look something like this:
    // Form1.h
    #include "Watch.h"
    ref class Form1: public Form
    public:
    void SomeMethod()
    // implementation
    private:
    void SomeHandler()
    Watch watchForm(this);
    watchForm.ShowDialog();
    // Watch.h
    ref class Form1; // declaration only
    ref class Watch: public Form
    public:
    Watch(Form1^ f1);
    private:
    Form1^ form1;
    void SomeMethod();
    // Watch.cpp
    #include "Watch.h"
    #include "Form1.h"
    Watch::Watch(Form1^ f1)
    form1 = f1;
    void Watch::SomeMethod()
    form1->SomeMethod();
    David Wilkinson | Visual C++ MVP

  • HTML5 Canvas: Removing EventListeners

    Hey guys
    I'm working on a project using the HTML5 canvas - quite simply, I have a 5x5 grid of squares that disappear when you click on them.
    Adding the listeners is fairly straightforward, I'm using the following code:
    var begin = addEventListeners.bind(this);
    var finish = removeEventListeners.bind(this);
    function addEventListeners()
      for (var i = 1; i < 26; i++)
      this["square"+i].addEventListener('click', squareClicked.bind(this["square"+i]));
    begin();
    This works just fine, there's a function called squareClicked that hides the square.
    The problem comes when I try to remove a listener, I've tried this:
    function removeEventListeners()
      for (var i = 1; i < 26; i++)
      this["square"+i].removeEventListener("click", squareClicked.bind(this["square"+i]));
    But no luck at all, I'm stumped, how would I go about doing this?
    Thanks

    Yes, I already pointed out in the first post that you can change the compression at the individual asset level and that there doesn't seem to be any way to change it in the publish dialog.
    Seems a bit absurd that the ability to change the default compression got left out of HTML5 mode. This has been core Flash functionality since pretty much forever.

  • Box popup onmouseover - Javascript HTML5 Canvas

    Hi !
    I am playing with the onmouseover event with javascript in flash pro cc html5 canvas.
    I would like a box to popup and remain up until there is no onmouseover anymore. I think it's called a description box.
    My two symbols are ‘Box1' and ‘Box2’.
    I want Box2 to popup ontop of Box1 when I put my mouse over Box1, and Box 2 to disappear once I move the mouse off Box 2.
    I am trying to use this code:
    var e = document.getElementById(‘Box1');
    e.onmouseover = function() {
      document.getElementById(‘Box2').style.display = 'block';
    e.onmouseout = function() {
      document.getElementById('Box2').style.display = 'none’;

    HOORAH !
    I figured out my own answer, here it is...
    this.Box2.visible = false;
    this.Box1.addEventListener("mouseover", fl_MouseOverToShow.bind(this));
      function fl_MouseOverToShow() {
      this.Box2.visible = true;
    this.Box2.addEventListener("mouseout", fl_MouseOutToHide.bind(this));
      function fl_MouseOutToHide() {
      this.Box2.visible = false;

  • Is there any way to use video with the new Flash CC HTML5 Canvas?

    I am a long time Flash user trying to determine if this new version of the program is something to add to the workflow again (after the last several years of not being able to use it) and the tutorials I have seen are not well written. Is there a way to use a video file within the animation, like with the AS2 and AS3 versions of Flash where I could insert a video clip into a symbol and animate the symbol while the video played.
    What I need to know is what format of video file I should use and how to add it into the timeline since Flash does not seem to be allowing for any type of import for this.
    Any Thoughts?
    Thanks,
    Brett

    Ok, so there are limitations, are they written down somewhere? I have been looking for a list of do and do not functions and the ways to work around them. Are they in the documentation somewhere I haven't discovered?
    Right now all I am looking to do is create Classic Tweens that animate movement and opacity so I can create a presentation with video that includes these elements. Is that level of functionality available in the HTML5 Canvas, or is that still on the drawing board?
    Is there a specific name for what I am looking to do that would aid my search? HTML5 video is not enough since the answer has not been forthcoming in Google or on Adobe or Stack Overflow. I am starting to think that nobody has thought of this yet, or if they have they decided that it is not currently possible and skipped the part where the rest of us find out.
    Any thoughts on making the connection to either doing this or finding out that it is just not possible yet would be very helpful.

  • Calling an overriden function in a [b]super-super[/b] class

    I have overriden a method in a class that extends a class that extends another class:
    class Parent {
         method A() { ... }
    class Child {
         method A() { ... }
    class GrandChild {
         method A() { ... }
    }I now want to call the Parent.A() function from the Grandchild.A() .
    Is it possible and how?
    Thanks

    I now want to call the Parent.A() function from the Grandchild.A()
    I.e. you want to call the grandparent's A() directly from the grandchild. No can do. You can only access your immediate parent class with "super".
    In fact, you do not want to call Parent.A() directly as above, because the very fact that a GrandChild extends a Child means that the Child() expects its A() to be called in preference to Parent's A() (especially if the GrandChild defers to any other functionality in Child, which could be broken by your bypassing the Child's A()).
    If you really need to do this sort of stuff, then the GrandChild needs to be a sibling of Parent (is your head spinning now? :-) - i.e. directly extend Parent.
    If you then need to share some interface between Child and (the now sibling) GrandChild, use a common interface, and implement it in both GrandChild and Child.

  • Calling a JavaScript function from an JApplet...

    Can anyone help? Is it possible to call a JavaScript function from within a JApplet? If so, what is the syntax? I've seen reference to the Netscape package but I've been led to believe it doesn't always work within Internet Explorer 6 which is the target browser.
    If the above is not possible can anyone tell me if and how it is possible to load images from outside the init() method of a JApplet? This would allow me to work around the problem.
    Thanks in advance - Jim.

    Call javascript you use the JSObject
    Please note the MAYSCRIPT int the html file.
    html file:
         <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                  height="0" width="0" >
            <param name="code" value="someApplet.class" />
            <!--[if !IE]> Mozilla/Netscape and its brethren -->
            <object classid="java:someApplet.class"
                    height="0" width="0"
                    mayscript=true>
            </object>
            <!-- <![endif]-->
          </object>
    <LABEL id="lblOutputText">This text is the HTML text </LABEL>java class:
    // new class for jsObject!!!! compile this: javac -classpath "C:\Program Files\Java\jre1.5.0\lib\plugin.jar" someApplet.java
    // since jaws.jar does not exsist anymore
    // in 1.4.0 to compile: javac -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
    // for msjvm use the -source 1.3 -target 1.1 option so the command looks like this:
    // javac -source 1.3 -target 1.1 -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
    import netscape.javascript.*;
    public class someApplet extends java.applet.Applet {
        JSObject win;
        public void init() {
             try{
                 win = JSObject.getWindow(this);
    // you need win.eval("window.close();"); // to close the window. if the current window is not a popup
    // opened by a parent with window.open than the user will get a waring, your next question probably will
    // be "can I stop this warning" and the answer is simple: NO
                 JSObject textBoxLabel = (JSObject) win.eval("document.getElementById('lblOutputText')");
                 textBoxLabel.setMember("innerHTML", "<center><h1>Some text</h1></center>");
            }catch(Exception e){
                 e.printStackTrace();
    }

  • Why Apple does not provide for call block / blacklist function on iphone?

    If Apple frowns upon jailbreaking the iPhone, why not AT THE LEAST endorse and make available third-party application that can provide a decent call block / blacklist function (like the Call Blocker for BlackBerry)?
    Can an Apple representative provide feedback pls?
    [Most telcos do not provide call-screening as a value-add service. Even if they do, a more cost-effective method is still the better option.]

    Have you asked your service provider if they offer any call blocking service? I know here in the USA, AT&T does, although they do charge $4.99/month for the service (it is part of a parental control package that allows control of both numbers that can be blocked from calling you, and numbers that your iPhone can call to).
    On-phone black list apps typically work by using caller id info and looking it up against the apps own database of numbers you've entered. So your phone still rings at least once, as the phone needs to allow a brief connection for the app to get the caller id info before disconnecting a number flagged for blocking. There really is no way to truly block calls from the phone itself, you need your service provider to be on board with the idea, so they can dis-allow the call at the switch and truly block it from ever reaching your phone.

  • HTML5 Canvas: addChild and position

    Hey Guys
    I have an item on the stage called 'square1', I have added a symbol from the library and given it the name 'circle1'.
    I wish to position circle1 at the exact location of square1, my question is - how would I go about doing that?
    Thanks

    Knowing JavaScript is going to be essential for you to use Canvas. If you really don't want to get your hands into the code you should do your best with the timeline.
    If you're ready to take the canvas plunge then JavaScript has to become a tool for you. The second page of what I linked would show you that for almost every bit of ActionScript you might be used to, there's a translation over to JavaScript that's necessary. So every time you go to do something you're going to be right back here.
    The best option just might be for you to take a look at EaselJS. There's lots of very simple demos that can get you started with HTML5/Canvas and will give you answers you want in Flash. Take a look:
    CreateJS | A suite of Javascript libraries and tools designed for working with HTML5

  • Is there a fix for using the HTML5 Canvas on Safari V5?

    I have just completed my fist site with the new HTML5 Canvas feature on Flash CC and it works beautifully on every browser and at every size except Safari V5. I get that Apple has stopped supporting Safari on the PC and that V5 is where they stopped, and that only .3% of the population view sites on this browser but I would like my site to function properly on all the browsers, not most of them. This error rears its ugly head when using the height:100% attribute on any image out there, something I have had to clean off quite a few sites, even a few of my own, but I do not see anything in the code to suggest that this is being used here. I will dive deeper into the code but this is a weird one, anyone else bump into this one?
    The site is here: http://adept-digital.com
    Thanks,
    Brett

    Google Toolbar
    * https://support.mozilla.com/en-US/questions/837473
    * https://support.mozilla.com/en-US/questions/837464

  • HTML5 Canvas mode audio quality issues

    Trying out the HTML5 Canvas mode of Flash CC 2014, and have banged right into a couple of show-stopping problems with exporting audio--
    Every audio file I've given it, Flash has converted it to MP3 with a loud click at the end that is not present in the original.
    In HTML Canvas mode, it seems there is no option to modify the Default compression setting for audio. So the only way to export MP3s as anything other than 16 kbps mono is to manually change the compression on every single file. Am I overlooking something?

    Yes, I already pointed out in the first post that you can change the compression at the individual asset level and that there doesn't seem to be any way to change it in the publish dialog.
    Seems a bit absurd that the ability to change the default compression got left out of HTML5 mode. This has been core Flash functionality since pretty much forever.

  • Create a "mouse over" interactive button in html5 canvas

    Hi there,
    I’m currently using the HTML5 canvas in flash Professional CC.
    I want to create an animated button that grows when you hover over it and then shrinks when you hover off it.
    I can do this in AS3 but I can’t seem to do it in the HTML5 canvas.
    I’ve placed the animated button in a movieclip and stopped it at the start of the movieclip timeline then added this code to try and activate it when I hover over it but it didn’t work:
    this.movieClip_2.addEventListener(“mouseover, fl_mouseoverToGoToAndPlayFromFrame_3.bind(this));
    function fl_mouseoverToGoToAndPlayFromFrame_3()
        this.gotoAndPlay(2);
    I've also tried to create a standard "button symbol" then added the animation within each action (Up, Over, Down). This didn't work either.
    Any help would be much appreciated!
    Matt

    this.movieClip_2.addEventListener(“mouseover, fl_mouseoverToGoToAndPlayFromFrame_3.bind(this));
    function fl_mouseoverToGoToAndPlayFromFrame_3()
        this.gotoAndPlay(2);
    should be:
    this.movieClip_2.addEventListener(“mouseover", fl_mouseoverToGoToAndPlayFromFrame_3.bind(this));
    function fl_mouseoverToGoToAndPlayFromFrame_3()
        this.gotoAndPlay(2);

  • Error in calling a parent

    i am trying to call a parent and have it do a simple action
    but i always get this error
    TypeError: Error #1006: value is not a function.
    function click_f(e:MouseEvent):void {
    this(this.parent).gotoAndPlay("go");
    btn.addEventListener(MouseEvent.CLICK, click_f);

    if found the solution
    function click_f(e:MouseEvent):void {
    MovieClip(parent).someFunction();
    btn.addEventListener(MouseEvent.CLICK, click_f);

Maybe you are looking for