Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8594565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:13:43+00:00 2026-06-12T00:13:43+00:00

Hi i m trying to implement a simple button on my as3. but this

  • 0

Hi i m trying to implement a simple button on my as3.
but this is not working.

i just added bouton1 to my scene but when i click on it nothing happen ( trace function doesnt show my message

this is my code

package {

import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.display.SimpleButton;






//import org.papervision3d.core.animation.clip.AnimationClip3D;
import org.papervision3d.objects.parsers.DAE;
//import org.papervision3d.objects.parsers.Max3DS;
//import org.papervision3d.objects.parsers.KMZ;
import org.papervision3d.view.BasicView;    
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.view.BasicView;

//added color to objects
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;

import org.papervision3d.core.math.Matrix3D;
import org.papervision3d.core.math.Number3D;
import org.papervision3d.lights.PointLight3D;

public class ExternalModelsExample extends BasicView

{
    private static const FORWARD:Number3D = new Number3D(0, 0, 1);
    private var model:DisplayObject3D;
    private var model2:DisplayObject3D;
    private var model3:DisplayObject3D;/*
    private var model4:DisplayObject3D;
    private var model5:DisplayObject3D;
    private var model6:DisplayObject3D;
    private var model7:DisplayObject3D;
    private var model8:DisplayObject3D;
    private var model9:DisplayObject3D;
    private var model10:DisplayObject3D;*/
    private var rotX:Number = 0.2;
    private var rotY:Number = 0.2;
    private var camPitch:Number = 90;
    private var camYaw:Number = 270;
    private var easeOut:Number = 0.1;


    // definition de la propriété couleur
    private var color:ColorMaterial;
    private var color2:ColorMaterial;
    private var color3:ColorMaterial;/*
    private var color4:ColorMaterial;
    private var color5:ColorMaterial;
    private var color6:ColorMaterial;
    private var color7:ColorMaterial;
    private var color8:ColorMaterial;
    private var color9:ColorMaterial;
    private var color10:ColorMaterial;*/

    private var previousMousePoint:Point = new Point();
    private var isMouseDown:Boolean = false;

    var bouton1:SimpleButton = new SimpleButton();




    public function ExternalModelsExample()
    {   
        stage.frameRate = 40;
        init();
        startRendering();
        addChild(bouton1);
        bouton1.addEventListener(MouseEvent.CLICK, test);
        stage.addEventListener(MouseEvent.MOUSE_DOWN, stage_mouseDownHandler);
        stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler);




    }
    public function test(){
        trace("test");
    }


    private function init():void
    {




        //Declaration color material
        color = new ColorMaterial(0x65b5ff);
        color2 = new ColorMaterial(0xffffff);
        color3 = new ColorMaterial(0x757575);/*
        color4 = new ColorMaterial(0x65b5ff);
        color5 = new ColorMaterial(0xffffff);
        color6 = new ColorMaterial(0x874630);
        color7 = new ColorMaterial(0xbe0da7);
        color8 = new ColorMaterial(0x3107bb);
        color9 = new ColorMaterial(0xff4448);
        color10 = new ColorMaterial(0xc7c7c7);*/


        //COLLADA Utah Teapot
        //Add import on top: import org.papervision3d.objects.parsers.DAE;
        model = new DAE();
        model.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model).load("assets/Z1.DAE", new MaterialsList ( { all:color } ));
        model2 = new DAE();
        model2.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model2).load("assets/Z2.DAE", new MaterialsList ( { all:color2 } ));
        model3 = new DAE();
        model3.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model3).load("assets/Z3.DAE", new MaterialsList ( { all:color3 } ));
        /*model = new DAE();
        model.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model).load("assets/Z4.DAE", new MaterialsList ( { all:color } ));
        model2 = new DAE();
        model2.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model2).load("assets/Z5.DAE", new MaterialsList ( { all:color2 } ));
        model3 = new DAE();
        model3.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model3).load("assets/Z6.DAE", new MaterialsList ( { all:color3 } ));
        model = new DAE();
        model.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model).load("assets/Z7.DAE", new MaterialsList ( { all:color } ));
        model2 = new DAE();
        model2.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model2).load("assets/Z9.DAE", new MaterialsList ( { all:color2 } ));
        model3 = new DAE();
        model3.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model3).load("assets/Z12-cockpit.DAE", new MaterialsList ( { all:color3 } ));
        model = new DAE();
        model.addEventListener(FileLoadEvent.LOAD_COMPLETE,modelLoaded);
        DAE(model).load("assets/Z13-barres.DAE", new MaterialsList ( { all:color } ));*/



    }

    private function modelLoaded(e:FileLoadEvent):void
    {

        scene.addChild(model);
        scene.addChild(model2);
        scene.addChild(model3);/*
        scene.addChild(model4);
        scene.addChild(model5);
        scene.addChild(model6);
        scene.addChild(model7);
        scene.addChild(model8);
        scene.addChild(model9);
        scene.addChild(model10);*/

    }




    private function stage_mouseDownHandler(event:MouseEvent):void
    {
        isMouseDown = true;
    }

    private function stage_mouseUpHandler(event:MouseEvent):void
    {
        isMouseDown = false;    
    }


    override protected function onRenderTick(e:Event=null):void
    {   

        var currentMousePoint:Point = new Point(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);

        if(isMouseDown)
        {
            var difference:Point = currentMousePoint.subtract(previousMousePoint);
            var vector:Number3D = new Number3D(difference.x, difference.y, 0);
            var rotationAxis:Number3D = Number3D.cross(vector, FORWARD);
            rotationAxis.normalize();
            var distance:Number = Point.distance(currentMousePoint, previousMousePoint);
            var rotationMatrix:Matrix3D = Matrix3D.rotationMatrix(rotationAxis.x, -rotationAxis.y, rotationAxis.z, distance/250);

            model.transform.calculateMultiply3x3(rotationMatrix, model.transform);
            model2.transform.calculateMultiply3x3(rotationMatrix, model2.transform);
            model3.transform.calculateMultiply3x3(rotationMatrix, model2.transform);
        }

        previousMousePoint = currentMousePoint;
        super.onRenderTick();
    }

}

}

di you know why my trace(“test”), doesn t work ??

there is a conflict with the object drag ?

flash doesn t show error

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:13:44+00:00Added an answer on June 12, 2026 at 12:13 am

    A SimpleButton object is more complex than just “add and forget”, you need to fill its properties, which is normally done at design time. There are four DisplayObject type objects, namely upState, overState, downState, hitTestState that determine the shape and contents of that button. In order to make a button visible and hittable, you need to specify 4 Sprites (or other DisplayObjects) as parameters to SimpleButton constructor. The hitTestState object is used to capture events, and is always invisible, so you just need to draw a correct shape on it. Other states are visible when the button is up, when the mouse is over a button, and when the mouse is pressed on the button respectively.

    var upSprite:Sprite=new Sprite();
    upSprite.graphics.lineStyle(2,0,1);
    upSprite.graphics.drawRect(0,0,50,20);
    var hitSprite:Shape=new Shape();
    hitSprite.graphics.beginFill(0,1);
    hitSprite.graphics.drawRect(3,3,44,14); // a bit smaller rect to make the button narrow
    var bouton1:SimpleButton=new SimpleButton(upSprite,upSprite,upSprite,hitSprite);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a simple login servlet but it's not working properly.
This maybe a very noobish question but I am trying to implement a simple
I am trying to implement a simple subscribe button using Paypal. I have used
Iam trying to implement a simple JMS(traditional not using springs) code in eclipse using
Just trying to implement a simple audit logging solution with Grails 2.0.2 and it
I’m trying to implement a simple fixed headers table. I know this can in
Trying to implement an Attending button. It's simple (or so I thought). A user
I'm trying to implement something quite simple but I'm on my first steps in
I am trying what should be a simple line of code but isn't working.
I'm trying to implement simple Comet chat example and for this I implemented Long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.