jeudi 30 mars 2017

ActionScript 3.0 Add an eventListener to an Image converted in Symbol into the library

I have got another problem with AS3. I have to create an application where there are 11 small image, when I click on one of this small image it will be displayed the video associated to the image that I clicked. I'm creating an AIR file and all the code goes in the first frame. This is my library:

enter image description here

This is the code I wrote. I'm trying to make it work just with an image cause then the code will be the same:


img1.addEventListener(MouseEvent.CLICK, onImg1Click);

function onImg1Click(mClick:MouseEvent):void {
        vid.source =            "C:/Users/sfelab/Desktop/BricoCenter/VidDimensioniOriginali/I Quaderni del Fare - Addio alla muffa! (muri esterni)_1.mp4";

If I run the AIR I get this error:

ReferenceError: Error #1065: Variable img1 is not defined. at bricoCenter_fla::MainTimeline/frame1()

I don't want to create all the image from code. I don't want to instanciate them, because if I instanciate and create them from code I have to set all the coordinates of all the images from code. There is a way to accessing directly the Symbole of the image in the library without create a variable for each image and put them in the right place from code? Thank you!

Aucun commentaire:

Enregistrer un commentaire