Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

This is simple cast type, but null

Community Beginner ,
Jun 15, 2012 Jun 15, 2012

I don't know what i just miss here, I think I do this for a thousand time but it's just didn't work!

adobe_cast_null.jpg

as you can see when i use...

PCButton(event.target); // i get null, but...

var pcButton:PCButton = event.target as PCButton; // i get what i want

and fyi when i cast type

var pcButton:PCButton = new PCButton(id);

trace(PCButton(pcButton).id);

this work too! never get null before, so i'm confuse now

what so wrong with my code or it's bug?

TOPICS
ActionScript
735
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 15, 2012 Jun 15, 2012

try

var pcButton:PCButton=event.target as PCButton

switch(pcButton.id);

or

switch(event.target.id)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 15, 2012 Jun 15, 2012
LATEST

yes, i know i can do that, but i just want to know why PCButton(event.target); didn't work

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines