HTML5 Canvas: appeal to a parent function

Hey guys

I am currently hitting my head against a brick wall, trying to call the function with the HTML5 Canvas parent.

I have the following code on the stage:

function fromStage()

{

Console.log ("it is on the stage");

}

fromStage();

This correctly generates this message to the console in the browser.

However, I have a button in a movie clip that I want to call this function, my code in this clip is as follows:

this.theButton.addEventListener ("click", fl_MouseClickHandler.bind (this));

this.theButton.name = 'information ';

function fl_MouseClickHandler (e)

{

this.parent.fromStage ();

}

However, this doesn't seem to work, any ideas?

Thank you

use:

on the scene:

this.fromStage = function)

{

Console.log ("it 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 = 'information ';

function fl_MouseClickHandler (e)

{

this.parent.fromStage ();

}

Tags: Adobe Animate

Similar Questions

  • HTML5 canvas making reference to a function in different image scripts

    Hi, people,.

    I wrote a custom function in the Framework 1 where I have used successfully. However, "this.functionName ()" does not work in other scripts of framework. How I would write this function so that I don't have to rewrite in each image? How could I do it if I want to make reference to a variable or function declared in a remote part of the frame of the timeline? Please refer me to a previous discussion if this question has already been answered.

    Thank you

    If you want to use this.functionName (), use the following to define your function

    {this.functionName = function ()}

    whatever

    }

  • How to call a function of my html code to js created by animate cc, I had used 'exportRoot.functionName' and said this function in my document of flash pro with html5 canvas, but now on cc animate this way doesn't work.

    My html code created by animate cc was changed to php for me, because I send and received variables via get and catch the cookies and much more. the function that I used to call function on my .fla of the document is passId() and it worked before when animate was Flash pro with html5 canvas.

    Captura de pantalla 2016-09-27 a las 12.19.59 p.m..png

    And function of .fla, I frame_0 only assign to the variable "id_usuario", this is the feature on fla:

    Captura de pantalla 2016-09-27 a las 12.20.12 p.m..png

    First of all, the title of your thread is horrible. Titles are supposed to be securities, not paragraphs.

    As for your problem, you are probably trying to call catchIdUser before it is defined. handleComplete() is raised when the content is ready to run. He did not actually yet. I guess you should have script code call the function of window parent, not the other way around.

  • Cannot add more than one script function to my HTML5 Canvas to animate CC

    I built my project using HTML5 canvas. Everything worked fine until I tried to add a proofreading function to the announcement. Not only it doesn't, actually if I can no longer see the announcement (specifically a gray area appears on the announcement and shows nothing). I was able to add the function stop easily, creating a layer of separate action, make a keyframe and adding the this.stop () to the action.

    The problem when I try to add another code in after it. At first I thought I was just add inefficient code, so I tried to do a simple click to go to the webpage for action, but that would not work either. Any code I want to add this.stop () in addition to the code would kill the ad.

    Does anyone have any suggestions as to why this is?

    Using animate CC 2015.1 edition. Windows 10.

    albertos77769384 wrote:

    function fl_ClickToGoToWebPage_6(event:MouseEvent):void

    {

    navigateToURL (new URLRequest ("http://www.adobe.com"), '_blank');

    }

    It was just the basic action script that should have let me add a link to a button.

    ActionScript does not work using HTML5 Canvas, for what I hope are obvious reasons. There is no such function as navigateToURL() in JavaScript. The equivalent in JS is window.open() to create a new window, or window.location.href = "bla.com" to replace the URL of the current page.

  • HTML5 Canvas (in Flash (CC) button defective functionality - more States out of service do not work

    I've searched and searched and I can't find a solution.

    In CC Flash, creating in a canvas of Actionscript 3.0, buttons work as expected. Up, more, Down, and Hit States desired to produce results.

    I am creating a lively HTML5 Web page and none of the buttons work as expected. Here are the flaws:

    1. There is no hand when scrolling on a button. It is a problem because there are several objects on stage, of which only half are buttons. The user must be able to know which are clickable.

    2 when I have a picture on the up State, all right. But when I add an image to the over State, it causes a loop. Above all loop in the preview and after that I have to publish regardless of the cursor position and the type of browser (IE, FF, Chrome).

    I searched on the web. A lot of people have this problem, but no answers have surfaced. I don't especially want another 100 hours recreating beachfront animate - which I am not as familiar with. Y at - it a code that can stop the madness?

    At the end of the day, all I have to do. I have fixed all through the timeline. Now everything works!

    HTML5 canvas dislikes tween buttons. He'll do it, but if the buttons contain animations, things go wonky. Instead, I got the bitmap of the tween flash button and once the animation is complete, I've changed over the bitmap for the button in the next keyframe, so that the user can click on it. Its softness, you do not see a hiccup. States of flight hover-over worked after that as the hand.

    Hope this helps other people who have this same problem.

  • HTML5 Canvas examples/tutorials content scrolling?

    Since ScrollPane component is not supported in HTML5 Canvas of Animate mode, anyone know how to create scrolling content in other ways?  Online pointers to tutorials or examples or books is appreciated.

    you use something like:

    var m;

    var b;

    var tl = this;

    paramF (mask there, buttons parent there, is mask + mask height, height of parent y-buttons buttons parent + height of mask)

    TL.mask_mc.addEventListener ('pressmove', moveF);

    TL.mask_mc.addEventListener ('pressup', stopF);

    function moveF (e) {}

    {if (TL.mask_mc. HitTest (e.localX, e.localY))}

    buttons parent y = m * (e.localY + 40) + b;

    } else {}

    stopF (e);

    }

    }

    function stopF (e) {}

    TL.mask_mc. RemoveEventListener ('pressmove', stopF);

    TL.mask_mc.addEventListener ('pressmove', stopF);

    }

    function paramF(x1,y1,x2,y2) {}

    m =(Y1-Y2) /(x1-x2);

    b = y1 - m * x 1;

    }

  • How to create seekbar for the generation of animation in flash, html5 canvas

    Hello

    I've created an animation in html5 canvas option in flash CC. I want to control the animation by using the seek bar (progress bar). Can someone guide me how to create the same.

    Thanks in advance.

    var totalFrame;
    var unitFrame;
    var unitSlide;
    var playMode;
    var sliderInitX = 0;
    var currMovie = this.parent;
    var _this = this;
    var BarMc = this["barMc"];
    
    function setSlider()
    {
      totalFrame = currMovie.timeline.duration;
      unitFrame = (totalFrame / (BarMc.nominalBounds.width));
      unitSlide = (BarMc.nominalBounds.width) / totalFrame;
    
      _this.sliderBtn.x = sliderInitX;
    
      playMode = true;
      setInterval(function(){onEnter();}, 33);
    
      BarMc.addEventListener("click", onClick);
    
    }
    
    function onClick(evt)
    {
      var stageXpos = stage.mouseX-(58);
      _this.sliderBtn.x = stageXpos;
      var movFrame = Math.round((_this.sliderBtn.x - (BarMc.x-(BarMc.nominalBounds.width/2))) * unitFrame);
      if ((movFrame< currMovie.timeline.duration) && playMode && (currMovie.timeline.position != currMovie.timeline.duration)) {
      currMovie.gotoAndPlay(movFrame);
      } else if (movFrame > currMovie.timeline.duration) {
      currMovie.gotoAndStop(currMovie.timeline.duration);
      playMode = false;
      } else {
      currMovie.gotoAndStop(movFrame);
      playMode = false;
      }
    }
    
    setSlider();
    
    function onEnter(){
      if (playMode) {
      _this.sliderBtn.x = BarMc.x + (unitSlide * currMovie.timeline.position) - (BarMc.nominalBounds.width/2);
      if (_this.sliderBtn.x > (BarMc.x + (BarMc.nominalBounds.width))) {
      _this.sliderBtn.x = (BarMc.x + (BarMc.nominalBounds.width));
      }
      }
    }
    

    name = barMc bar

    and the handle = sliderBtn

  • HTML5 canvas, animated during a cursor

    Hello everyone, my name is Etienne Deswattenne, I am a beginner flash of France so I apologize for my poor English, my question is this, how can we change the cursor to a symbol of the scene when the mouse is on another symbol? I have a 'this' problem I think

    Here's the code I sketched in HTML5 canvas:

    ========================================================

    Hello all, I do not understand how to use the keyword "this" pour run code of this fight, because the function is in another function so the 'this' don't be referred not to the same chose? I tried for 4 hours I found nothing, please help me!

    =========================================================

    frequency of var = 3;

    stage.enableMouseOver (frequency);

    this.zoneinterdite.addEventListener ('mouseover', fl_MouseOverHandler_17);

    function fl_MouseOverHandler_17()

    {

    internship. Canvas.style.Cursor = 'none ';

    this.movieClip_6.mouseEnabled = false;

    this.addEventListener ('check', fl_CustomMouseCursor_15.bind (this));

    function fl_CustomMouseCursor_15() {}

    this.movieClip_6.x = stage.mouseX;

    this.movieClip_6.y = stage.mouseY;

    }

    }

    you have lost your reference to 'this' in fl_MouseOverHandler_17.  (and you should not the following named functions.)

    Try:

    frequency of var = 3;

    stage.enableMouseOver (frequency);

    this.zoneinterdite.addEventListener ('mouseover', fl_MouseOverHandler_17(this) .bind);

    function fl_MouseOverHandler_17()

    {

    internship. Canvas.style.Cursor = 'none ';

    this.movieClip_6.mouseEnabled = false;

    this.addEventListener ('check', fl_CustomMouseCursor_15.bind (this));

    }

    function fl_CustomMouseCursor_15() {}

    this.movieClip_6.x = stage.mouseX;  Although these two lines will probably end your mouseover zoneinterdite

    this.movieClip_6.y = stage.mouseY;

    }

  • HTML5 canvas settimeout problem

    Hello

    I have a problem with html5 canvas settimeout.

    I created a round drawing object, the instance name is ball. The following code

    Code:

    This.ball.x = 1000;

    setTimeout (calledFun, 500);

    function calledFun()

    {

    Alert ("fun called");

    This.ball.x = 100;

    }

    The function of this code is worked, alert view only. But ball x position not changed.

    So please help me

    Thanks in advance

    you have lost your reference to "this".  Try:

    var tl = this;

    This.ball.x = 1000;

    setTimeout (calledFun, 500);

    function calledFun()

    {

    Alert ("fun called");

    TL.ball.x = 100;

    }

  • "mouseup" does not not in HTML5 canvas

    Hello

    I created a HTML5 canvas where the main timeline is supposed to play so that a button is pressed and stops when the button is released. To do this, I need to stop the "tick" on mouseup event. However, mouseup does not work. I tried to use mouseup on the btn_plus.addEventListener as well (only for debugging purposes), but it does nothing. "mousedown" and "click" works as expected.

    (The next step is to create a back button with similar functionality, this is why I do not use the play/stop to control the timeline.)

    Any input would be much appreciated.

    Thank you.

    This.Stop ();

    This.btn_plus.addEventListener ("mousedown", keyPlus.bind (this));      increase button. "mouseup" does not work here either.

    function keyPlus() {}

    this.addEventListener ('check', increaseDown.bind (this));

    this.removeEventListener ("mouseup", increaseDown.bind (this));      //Trying to remove the ticker here - does not

    }

    function increaseDown() {}

    this.gotoAndStop (this.timeline.position + 1); magic happening here

    Alert ('increase pressed');

    }

    Try, "pressup.

  • Several ' click is needed with HTML5 Canvas script

    I'm learning the script in the HTML5 Canvas, having recently changed dashboard animate and, before AS3

    I have two buttons and I created a simple condition to detect the alpha value of the STM, control buttons, so that the correct MC can be alpha fainted faded and the new faded faded on. The code works, except that:

    on the first click, the MC fades on correctly, the second click on another button takes 2 clicks, and each requires more clicks on the same key. Can someone explain and give me a way to fix this oddity.

    Thanks in advance!

    That's what I have:

    THE STATES OF LOAD

    this.circleGreen_mc.alpha = 0;

    this.circleRed_mc.alpha = 0;

    this.circleTeal_mc.alpha = 0;

    BUTTON GREEN

    This.green_btn.addEventListener ("click", greenClick.bind (this));

    function greenClick() {}

    FADE IN

    this.addEventListener ('check', fadeIn.bind (this));

    function fadeIn() {}

    this.circleGreen_mc.alpha += 0.1;

    }

    Fade OUT

    If (this.circleRed_mc.alpha == 1); {

    this.addEventListener ('check', fadeOut.bind (this));

    function fadeOut() {}

    this.circleRed_mc.alpha-= 0.1;

    }

    }

    Fade OUT

    If (this.circleTeal_mc.alpha == 1); {

    this.addEventListener ('check', fadeOut.bind (this));

    function fadeOut() {}

    this.circleTeal_mc.alpha-= 0.1;

    }

    }

    }

    RED BUTTON

    This.red_btn.addEventListener ("click", redClick.bind (this));

    function redClick() {}

    FADE IN

    this.addEventListener ('check', fadeIn.bind (this));

    function fadeIn() {}

    this.circleRed_mc.alpha += 0.1;

    }

    Fade OUT

    If (this.circleGreen_mc.alpha == 1); {

    this.addEventListener ('check', fadeOut.bind (this));

    function fadeOut() {}

    this.circleGreen_mc.alpha-= 0.1;

    }

    }

    Fade OUT

    If (this.circleTeal_mc.alpha == 1); {

    this.addEventListener ('check', fadeOut.bind (this));

    function fadeOut() {}

    this.circleTeal_mc.alpha-= 0.1;

    }

    }

    }

    /*

    BUTTON TEAL

    This.teal_btn.addEventListener ("click", tealClick.bind (this));

    function tealClick() {}

    }

    }

    */

    Well, then, if I did what I guess you do, I would like this:

    var i;
    var curBtn;
    var circles = [this.circleRed, this.circleGreen, this.circleBlue];
    var buttons = [this.btnRed, this.btnGreen, this.btnTeal];
    var items = circles.length; // assume same number of buttons and circles
    
    // initialize things
    for (i = 0; i < items; i++) {
        circles[i].alpha = 0;
        buttons[i].btnId = i;
        buttons[i].addEventListener("click", buttonClickHandler.bind(this));
    }
    
    // handler for all button clicks
    function buttonClickHandler(evt) {
        var i;
        var btn = evt.target.btnId;
        if (btn == curBtn) {
            return;
        }
        curBtn = btn;
        for (i = 0; i < items; i++) {
            if (i == btn) {
                createjs.Tween.get(circles[i], {override:true}).to({alpha:1}, 500);
            }
            else if (circles[i].alpha > 0) {
                createjs.Tween.get(circles[i], {override:true}).to({alpha:0}, 500);
            }
        }
    }
    
  • How to disable the cc button animate html5 canvas files?

    Hello!

    How to disable the cc button animate html5 canvas files?

    ex:

    this.mc.on('click',function(){alert('this')})
    this.mc.enabled=false
    

    question 1:

    When you click on the 'mc', it always run. How can I control the button of the deactivate and activate?

    question 2:

    The mc is not an image, it's a movieclip. How can I change the colors of the mc? example: default of the mc color red, I want to click change black!

    Thank you!

    use addEventListener instead of 'on '.  You can then use removeEventListener to disable.

    or you can intemperies to use 'on' using the mouseEnabled property to disable this.mc:

    this.mc.mouseEnabled = false;

  • Click and click on &amp; keep in html5 canvas button

    Hello
    I am trying to create a scenario where if I click a button perform a function, but if I click and hold (aka long press) then the service can continue to run as long as I am holding down the button. I have done in building 2 (as below), want to replicate in html5 canvas.


    Please help me out here.

    See you soon...

    launch ticker loop that calls your function on mousedown and stop the loop on mouseup.

  • Fonts/text seems out of HTML5 Canvas pixelated. A way to solve this problem?

    Am to convert an animation Flash in HTML5 using animate CC. But the police/text seems out HTML5 Canvas pixelated. A way to solve this problem?

    It seems that the canvas out put restores all texts like forms so that we can not select the text in the output. Is there any other format to publish and export options to get this resolved?

    [Left the lounge general Forum, troubled for a specific product - Mod support forum]

    There is nothing wrong Bootstrap examples reactive reactive image Images create by adding a .img-sensible class to the tag. Picture dimensionnera then kindly to the parent element. The class favouring the .img apply max-width: 100%, height: auto and display: block, to the image:

  • Animated Navigation CC HTML5 Canvas issues

    I use Adobe animate CC HTML5 Canvas.

    I use some variables and STOP to navigate through the timeline, as if they were pages.

    Go forward through the timeline gives me no problem, however, when I got back in the timeline (from frame_1 to frame_0) when I ask many interactions on the previous page don't work (visibility and hover button) and then when I try to go forward again it does not stop on the frame more.

    An alert using, I found that he jumps in the course although I stops.

    Can someone help me please? I can send the files together if necessary.

    Here is my code for the navigation of the page:

    This.Stop ();

    SECTION INFO & NAVIGATION DRIVE

    VARIABLES FOR NAVIGATION

    var frameNumber = this.currentFrame;

    nextFrame var = frameNumber + 1;

    prevFrame var frameNumber = - 1;

    DISPLAYS CURRENT PAGE NUMBER

    var text = this.currentFrame.toString ();

    var thisText = "Page" + displayText;

    createText var is new createjs. Text (thisText, "" BOLD "44px Myriad Pro", "White");

    this.addChild (createText);

    TEXT OTHER THAN THE WEIGHT/SIZE/COLOR/FONT STYLE

    createText.x = 98;

    createText.y = 1375;

    CLEARS THE PREVIOUS PAGE NUMBER BEFORE MOVING FRAMES

    this.next.addEventListener ("click", removePageNumberNext.bind (this));

    function removePageNumberNext()

    {

    this.removeChild (createText);
    this.gotoAndPlay (nextFrame);

    }

    this.prev.addEventListener ("click", removePageNumberPrev.bind (this));

    function removePageNumberPrev()

    {

    this.removeChild (createText);
    this.gotoAndPlay (prevFrame);

    }

    Hold up... you have the above reproduced code in each single frame? This would explain why your buttons are behaving strangely. Handlers on objects do not replace each other - they are cumulative. If you have only one set of buttons in nav for the entire timeline, you only need to assign handlers once at the beginning.

    Similarly, you should not create a textfield to display page in the code. You just create a dynamic textfield in the editor, name ('pageNum' or whatever), then update its content through the .text property.

    Assuming that you are using the frame 1 (0) to initialize and start your content on frame 2 (1) and have a next button called 'next', a previous page named 'prev' button and a textfield of page number named 'pageNum', all that exists throughout the entire timeline, you can use this code to control your page :

    _root = this; // global handle to root timeline for event listeners
    this._maxPage = _root.timeline.duration - 1; // total pages
    
    // event handlers
    this.navPrev = function() {
        var cur = _root.timeline.position;
        if (cur > 0) {
            _root.navToPage(cur - 1);
        }
    }
    
    this.navNext = function() {
        var cur = _root.timeline.position;
        if (cur < _root._maxPage) {
            _root.navToPage(cur + 1);
        }
    }
    
    // do navigation
    this.navToPage = function(p) {
        // set visibility of nav buttons
        this.prev.visible = p > 1;
        this.next.visible = p < this._maxPage;
        // update page counter
        this.pageNum.text = "Page " + p;
        // navigate
        this.gotoAndStop(p);
    }
    
    // assign event listeners
    this.prev.addEventListener("click", this.navPrev);
    this.next.addEventListener("click", this.navNext);
    
    // get the party started
    this.navToPage(1);
    

Maybe you are looking for